Skip to content

Commit

Permalink
Optimised dockerfile for slightly smaller build image. It is still qu…
Browse files Browse the repository at this point in the history
…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.
32 changes: 22 additions & 10 deletions Dockerfile
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"]

0 comments on commit ec6b927

Please sign in to comment.