3
3
# Stage 1: Build Rust app on platform-specific image
4
4
FROM --platform=${BUILDPLATFORM} rust:bullseye AS builder
5
5
6
+ # Install required build tools
6
7
RUN apt-get update && apt-get install -y \
7
8
build-essential bash pkg-config libssl-dev libpq-dev curl git \
8
9
--no-install-recommends && rm -rf /var/lib/apt/lists/*
9
10
10
11
WORKDIR /usr/src/app
11
12
13
+ # Copy workspace and packages
12
14
COPY Cargo.toml Cargo.lock ./
13
15
COPY ./entity/Cargo.toml ./entity/Cargo.toml
14
16
COPY ./entity_api/Cargo.toml ./entity_api/Cargo.toml
@@ -17,25 +19,30 @@ COPY ./service/Cargo.toml ./service/Cargo.toml
17
19
COPY ./web/Cargo.toml ./web/Cargo.toml
18
20
COPY . .
19
21
22
+ # Build release binaries for the current platform only
20
23
RUN cargo build --release --workspace
21
24
22
- # Stage 2: Minimal runtime image using non-root user
25
+ # Stage 2: Minimal runtime image
23
26
FROM debian:bullseye-slim
24
27
28
+ # Install Bash to support entrypoint.sh
25
29
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*
26
30
31
+ # Create non-root user
27
32
RUN useradd -m -s /bin/bash appuser
28
33
WORKDIR /app
29
34
35
+ # Copy only the necessary release binaries
30
36
COPY --from=builder /usr/src/app/target/release/refactor_platform_rs .
31
37
COPY --from=builder /usr/src/app/target/release/migration .
32
38
COPY --from=builder /usr/src/app/target/release/seed_db .
33
39
40
+ # Copy entrypoint script and make it executable
34
41
COPY entrypoint.sh /entrypoint.sh
35
42
RUN chmod +x /entrypoint.sh && chown -R appuser:appuser /app /entrypoint.sh
36
43
37
44
USER appuser
38
45
39
46
EXPOSE 8000
40
47
41
- ENTRYPOINT ["/entrypoint.sh" ]
48
+ ENTRYPOINT ["/entrypoint.sh" ]
0 commit comments