mirror of
https://github.com/iv-org/inv_sig_helper.git
synced 2025-02-17 04:17:31 +00:00
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
This commit is contained in:
parent
1329745627
commit
ff9a378564
32
Dockerfile
32
Dockerfile
@ -1,39 +1,31 @@
|
|||||||
# Use the official Alpine-based Rust image as a parent image
|
# Use the official Rust image as a parent image
|
||||||
FROM rust:1.80-alpine AS builder
|
FROM rust:1.80 AS builder
|
||||||
|
|
||||||
# Set the working directory in the container
|
# Set the working directory in the container
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apt update && apt install -y \
|
||||||
musl-dev \
|
libssl-dev \
|
||||||
openssl-dev \
|
pkg-config \
|
||||||
openssl-libs-static \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
pkgconfig \
|
|
||||||
patch
|
|
||||||
|
|
||||||
# Set environment variables for static linking
|
|
||||||
ENV OPENSSL_STATIC=yes
|
|
||||||
ENV OPENSSL_DIR=/usr
|
|
||||||
|
|
||||||
# Copy the current directory contents into the container
|
# Copy the current directory contents into the container
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Determine the target architecture and build the application
|
# Build the application
|
||||||
RUN RUST_TARGET=$(rustc -vV | sed -n 's/host: //p') && \
|
RUN cargo build --release
|
||||||
rustup target add $RUST_TARGET && \
|
|
||||||
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target $RUST_TARGET
|
|
||||||
|
|
||||||
# Stage for creating the non-privileged user
|
# Stage for creating the non-privileged user
|
||||||
FROM alpine:3.20 AS user-stage
|
FROM debian:12.6-slim AS user-stage
|
||||||
|
|
||||||
RUN adduser -u 10001 -S appuser
|
RUN adduser --uid 10001 --system appuser
|
||||||
|
|
||||||
# Stage for a smaller final image
|
# Stage for a smaller final image
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
# Copy necessary files from the builder stage, using the correct architecture path
|
# Copy necessary files from the builder stage
|
||||||
COPY --from=builder /usr/src/app/target/*/release/inv_sig_helper_rust /app/inv_sig_helper_rust
|
COPY --from=builder /usr/src/app/target/release/inv_sig_helper_rust /app/inv_sig_helper_rust
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
# Copy passwd file for the non-privileged user from the user-stage
|
# Copy passwd file for the non-privileged user from the user-stage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user