Skip to content

Commit

Permalink
update Dockerfile to reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
Hampton Moore authored and ezrizhu committed Jan 20, 2024
1 parent 1eebef6 commit 685335d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kuchiki = "0.8.1"
maud = { version = "0.25.0", features = ["axum"] }
minifier = "0.2.2"
rand = "0.8.5"
reqwest = { version = "0.11.18", features = ["rustls", "serde_json", "json"] }
reqwest = { version = "0.11.23", features = ["rustls-tls", "serde_json", "json"], default-features = false }
ructe = "0.16.1"
serde = { version = "1.0.174", features = ["derive"] }
sitemap = "0.4.1"
Expand Down
29 changes: 25 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
FROM rust:1.70
# Build stage
FROM rust:1.75-slim-bullseye as builder

RUN apt-get update
RUN apt-get install pkg-config libssl-dev -y

# Copy the source code
ADD . .

# Build the project
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target \
cargo build --release

# Final stage
FROM debian:bullseye-slim

ARG REF=""
ARG COMMIT=""
Expand All @@ -8,9 +23,15 @@ ENV COMMIT=${COMMIT}
ENV REF=${REF}
ENV TIME=${TIME}
ENV CT=${CT}
ENV TZ="America/New_York"

ADD . .
# Copy the binary from the build stage
COPY --from=builder /target/release/www /usr/local/bin/www

RUN cargo build --release
COPY ./assets /usr/local/bin/assets
COPY ./content /usr/local/bin/content

CMD ["./target/release/www"]
# Set the command to run the binary
WORKDIR /usr/local/bin
CMD ["www"]
EXPOSE 3000

0 comments on commit 685335d

Please sign in to comment.