Skip to content

Commit 633a5ad

Browse files
authored
Merge pull request #10 from sir-gon/feature/docker
New Docker strategy.
2 parents d4cca92 + 02600f9 commit 633a5ad

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

Dockerfile

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,34 @@ ENV WORKDIR=/app
55
WORKDIR ${WORKDIR}
66

77
RUN apk add --update --no-cache make
8-
8+
RUN apk add --update --no-cache musl-dev
99
# cargo-chef to cache dependencies https://crates.io/crates/cargo-chef
10+
RUN cargo install cargo-chef
11+
12+
COPY ./Makefile ${WORKDIR}/
13+
COPY ./src ${WORKDIR}/src
14+
COPY ./Cargo.lock ${WORKDIR}/Cargo.lock
15+
COPY ./Cargo.toml ${WORKDIR}/Cargo.toml
16+
RUN cargo chef prepare --recipe-path recipe.json
17+
18+
FROM init AS cacher
19+
20+
# COPY --from=init ${WORKDIR}/recipe.json recipe.json
21+
RUN cargo chef cook --release --recipe-path recipe.json
1022

1123
###############################################################################
1224

1325
FROM init AS builder
1426

15-
RUN apk add --no-cache musl-dev
16-
RUN cargo install cargo-chef
27+
ENV WORKDIR=/app
28+
WORKDIR ${WORKDIR}
1729

1830
# sources
1931
COPY ./src ${WORKDIR}/src
20-
COPY ./Cargo.lock ${WORKDIR}/Cargo.lock
21-
COPY ./Cargo.toml ${WORKDIR}/Cargo.toml
22-
COPY ./Makefile ${WORKDIR}/
2332

24-
# dependencies
25-
RUN make dependencies
33+
# Copy over the cached dependencies
34+
COPY --from=cacher ${WORKDIR}/target target
35+
COPY --from=cacher $CARGO_HOME $CARGO_HOME
2636

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

3747
FROM builder AS development
3848

39-
# CMD []
49+
ENV WORKDIR=/app
50+
WORKDIR ${WORKDIR}
4051

41-
CMD ["make", "build"]
52+
CMD []
4253

4354
###############################################################################
4455

@@ -65,7 +76,6 @@ COPY ./.yamllint ${WORKDIR}/
6576
COPY ./.yamlignore ${WORKDIR}/
6677
COPY ./.gitignore ${WORKDIR}/
6778

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

7080
CMD ["make", "lint"]
7181

0 commit comments

Comments
 (0)