Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,34 @@ ENV WORKDIR=/app
WORKDIR ${WORKDIR}

RUN apk add --update --no-cache make

RUN apk add --update --no-cache musl-dev
# cargo-chef to cache dependencies https://crates.io/crates/cargo-chef
RUN cargo install cargo-chef

COPY ./Makefile ${WORKDIR}/
COPY ./src ${WORKDIR}/src
COPY ./Cargo.lock ${WORKDIR}/Cargo.lock
COPY ./Cargo.toml ${WORKDIR}/Cargo.toml
RUN cargo chef prepare --recipe-path recipe.json

FROM init AS cacher

# COPY --from=init ${WORKDIR}/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

###############################################################################

FROM init AS builder

RUN apk add --no-cache musl-dev
RUN cargo install cargo-chef
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

# sources
COPY ./src ${WORKDIR}/src
COPY ./Cargo.lock ${WORKDIR}/Cargo.lock
COPY ./Cargo.toml ${WORKDIR}/Cargo.toml
COPY ./Makefile ${WORKDIR}/

# dependencies
RUN make dependencies
# Copy over the cached dependencies
COPY --from=cacher ${WORKDIR}/target target
COPY --from=cacher $CARGO_HOME $CARGO_HOME

# build
RUN ls -alhR && \
Expand All @@ -36,9 +46,10 @@ CMD ["make", "build"]

FROM builder AS development

# CMD []
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

CMD ["make", "build"]
CMD []

###############################################################################

Expand All @@ -65,7 +76,6 @@ COPY ./.yamllint ${WORKDIR}/
COPY ./.yamlignore ${WORKDIR}/
COPY ./.gitignore ${WORKDIR}/

RUN cargo chef cook --release --recipe-path recipe.json

CMD ["make", "lint"]

Expand Down
Loading