-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimised dockerfile for slightly smaller build image. It is still qu…
…ite large due to rust cache
- Loading branch information
Matt Hamilton
committed
Nov 8, 2023
1 parent
bdb6313
commit ec6b927
Showing
1 changed file
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Use a multi-stage build to compile the application | ||
FROM rust:alpine as builder | ||
|
||
WORKDIR /usr/src/fendermint | ||
# Install dependencies required for the build | ||
RUN apk add --no-cache clang musl-dev git curl jq bash \ | ||
&& git clone https://github.com/consensus-shipyard/fendermint.git . \ | ||
&& cargo install --force cargo-make | ||
|
||
|
||
# Start with a new, clean base image to reduce size | ||
FROM docker:cli | ||
|
||
RUN apk add --no-cache clang musl-dev git curl jq bash | ||
RUN apk add --no-cache bash jq curl libgcc | ||
|
||
WORKDIR /app | ||
# Copy only the compiled binaries and any other necessary files from the builder image | ||
COPY --from=builder /usr/local/cargo/bin /usr/local/cargo/bin | ||
COPY --from=builder /usr/src/fendermint /app/fendermint | ||
|
||
COPY . . | ||
# Set any environment variables needed | ||
ENV PATH="/usr/local/cargo/bin:${PATH}" | ||
|
||
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
RUN cargo install --force cargo-make | ||
# Set the work directory | ||
WORKDIR /app | ||
|
||
RUN git clone https://github.com/consensus-shipyard/fendermint.git && \ | ||
cd fendermint && \ | ||
cargo make --makefile ./infra/Makefile.toml info | ||
RUN cd fendermint && cargo make --makefile ./infra/Makefile.toml info | ||
|
||
ENTRYPOINT ["/bin/bash", "-c"] | ||
# Set the entrypoint | ||
ENTRYPOINT ["/bin/bash", "-c"] |