|
1 |
| -# Use the official Alpine-based Rust image as a parent image |
2 |
| -FROM rust:1.80-alpine AS builder |
| 1 | +# Use the official Rust image as a parent image |
| 2 | +FROM rust:1.80 AS builder |
3 | 3 |
|
4 | 4 | # Set the working directory in the container
|
5 | 5 | WORKDIR /usr/src/app
|
6 | 6 |
|
7 | 7 | # Install build dependencies
|
8 |
| -RUN apk add --no-cache \ |
9 |
| - musl-dev \ |
10 |
| - openssl-dev \ |
11 |
| - openssl-libs-static \ |
12 |
| - pkgconfig \ |
13 |
| - patch |
14 |
| - |
15 |
| -# Set environment variables for static linking |
16 |
| -ENV OPENSSL_STATIC=yes |
17 |
| -ENV OPENSSL_DIR=/usr |
| 8 | +RUN apt update && apt install -y \ |
| 9 | + libssl-dev \ |
| 10 | + pkg-config \ |
| 11 | + && rm -rf /var/lib/apt/lists/* |
18 | 12 |
|
19 | 13 | # Copy the current directory contents into the container
|
20 | 14 | COPY . .
|
21 | 15 |
|
22 |
| -# Determine the target architecture and build the application |
23 |
| -RUN RUST_TARGET=$(rustc -vV | sed -n 's/host: //p') && \ |
24 |
| - rustup target add $RUST_TARGET && \ |
25 |
| - RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target $RUST_TARGET |
| 16 | +# Build the application |
| 17 | +RUN cargo build --release |
26 | 18 |
|
27 | 19 | # Stage for creating the non-privileged user
|
28 |
| -FROM alpine:3.20 AS user-stage |
| 20 | +FROM debian:12.6-slim AS user-stage |
29 | 21 |
|
30 |
| -RUN adduser -u 10001 -S appuser |
| 22 | +RUN adduser --uid 10001 --system appuser |
31 | 23 |
|
32 | 24 | # Stage for a smaller final image
|
33 | 25 | FROM scratch
|
34 | 26 |
|
35 |
| -# Copy necessary files from the builder stage, using the correct architecture path |
36 |
| -COPY --from=builder /usr/src/app/target/*/release/inv_sig_helper_rust /app/inv_sig_helper_rust |
| 27 | +# Copy necessary files from the builder stage |
| 28 | +COPY --from=builder /usr/src/app/target/release/inv_sig_helper_rust /app/inv_sig_helper_rust |
37 | 29 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
38 | 30 |
|
39 | 31 | # Copy passwd file for the non-privileged user from the user-stage
|
|
0 commit comments