-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.dev
70 lines (50 loc) · 1.4 KB
/
Dockerfile.dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Builder stage
FROM rust:1.78.0-slim-bullseye AS builder
ARG APP_NAME=indexers
WORKDIR /app
# Install build dependencies
RUN apt-get update && \
apt-get install -y \
ca-certificates \
pkg-config \
libssl-dev \
libclang-dev \
clang \
cmake \
build-essential && \
rm -rf /var/lib/apt/lists/*
# Set environment variables for libclang
ENV LIBCLANG_PATH=/usr/lib/llvm-11/lib
ENV LLVM_CONFIG_PATH=/usr/bin/llvm-config-11
# Copy only the Cargo.toml and Cargo.lock files
COPY Cargo.toml Cargo.lock ./
# Create a dummy main.rs to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies
RUN cargo build --release
# Remove the dummy main.rs
RUN rm src/main.rs
# Copy the actual source code
COPY . .
ENV SQLX_OFFLINE=true
# Build the application
RUN touch src/main.rs && cargo build --release
# Strip the binary to reduce size
RUN strip target/release/$APP_NAME
# Final stage
FROM debian:bullseye-slim AS release
ARG APP_NAME=indexers
ENV APP_NAME=$APP_NAME
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /app/target/release/$APP_NAME ./$APP_NAME
# Copy the config file
COPY --from=builder /app/config.json ./config.json
# Install only the necessary runtime dependencies
RUN apt-get update && \
apt-get install -y \
ca-certificates \
libssl1.1 && \
rm -rf /var/lib/apt/lists/*
EXPOSE 3000
CMD /app/$APP_NAME