Merge pull request #43 from PeterDaveHelloKitchen/ImproveDockerfile
Remove redundent `apk --no-cache update` in Dockerfile
This commit is contained in:
+3
-6
@@ -1,8 +1,7 @@
|
|||||||
# Stage 1: Cache dependencies
|
# Stage 1: Cache dependencies
|
||||||
FROM rust:1.85-alpine AS cacher
|
FROM rust:1.85-alpine AS cacher
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk --no-cache update && \
|
RUN apk --no-cache upgrade && \
|
||||||
apk --no-cache upgrade && \
|
|
||||||
apk add --no-cache musl-dev openssl-dev pkgconfig postgresql-dev
|
apk add --no-cache musl-dev openssl-dev pkgconfig postgresql-dev
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
# Create a minimal project to download and cache dependencies
|
# Create a minimal project to download and cache dependencies
|
||||||
@@ -14,8 +13,7 @@ RUN mkdir -p src && \
|
|||||||
# Stage 2: Build the application
|
# Stage 2: Build the application
|
||||||
FROM rust:1.85-alpine AS builder
|
FROM rust:1.85-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk --no-cache update && \
|
RUN apk --no-cache upgrade && \
|
||||||
apk --no-cache upgrade && \
|
|
||||||
apk add --no-cache musl-dev openssl-dev pkgconfig postgresql-dev
|
apk add --no-cache musl-dev openssl-dev pkgconfig postgresql-dev
|
||||||
# Copy cached dependencies
|
# Copy cached dependencies
|
||||||
COPY --from=cacher /app/target target
|
COPY --from=cacher /app/target target
|
||||||
@@ -31,8 +29,7 @@ RUN cargo build --release
|
|||||||
# Stage 3: Create minimal final image
|
# Stage 3: Create minimal final image
|
||||||
FROM alpine:3.21.3
|
FROM alpine:3.21.3
|
||||||
# Install only necessary runtime dependencies and update packages
|
# Install only necessary runtime dependencies and update packages
|
||||||
RUN apk --no-cache update && \
|
RUN apk --no-cache upgrade && \
|
||||||
apk --no-cache upgrade && \
|
|
||||||
apk add --no-cache libgcc openssl ca-certificates libpq tzdata
|
apk add --no-cache libgcc openssl ca-certificates libpq tzdata
|
||||||
|
|
||||||
# Copy only the compiled binary
|
# Copy only the compiled binary
|
||||||
|
|||||||
Reference in New Issue
Block a user