Skip to content

Commit ff9a378

Browse files
committed
Dockerfile: Switch to Debian-based images and simplify build command
- rust:1.80-alpine replaced with rust:1.80 for the builder stage - alpine:3.20 replaced with debian:12.6-slim for the user-stage - Build command simplified to use default target architecture
1 parent 1329745 commit ff9a378

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

Dockerfile

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
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
33

44
# Set the working directory in the container
55
WORKDIR /usr/src/app
66

77
# 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/*
1812

1913
# Copy the current directory contents into the container
2014
COPY . .
2115

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
2618

2719
# Stage for creating the non-privileged user
28-
FROM alpine:3.20 AS user-stage
20+
FROM debian:12.6-slim AS user-stage
2921

30-
RUN adduser -u 10001 -S appuser
22+
RUN adduser --uid 10001 --system appuser
3123

3224
# Stage for a smaller final image
3325
FROM scratch
3426

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
3729
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
3830

3931
# Copy passwd file for the non-privileged user from the user-stage

0 commit comments

Comments
 (0)