Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 340e278

Browse files
author
Athos
authored
Make cargo-chef effective for CI builds (#763)
* Optimize runtime container layers * Use Github Actions cache for Docker * Move rm -rf /var/lib/apt/lists/* to its own line
1 parent 915964e commit 340e278

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

Diff for: .github/workflows/pr-images.yml

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
with:
2323
submodules: recursive
2424

25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
2528
- name: Log in to the Container registry
2629
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
2730
with:
@@ -42,3 +45,7 @@ jobs:
4245
push: true
4346
tags: ${{ steps.meta.outputs.tags }}-${{ github.event.pull_request.head.sha }}
4447
labels: ${{ steps.meta.outputs.labels }}
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max
50+
51+

Diff for: .github/workflows/publish.yml

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
with:
2525
submodules: recursive
2626

27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
2730
- name: Log in to the Container registry
2831
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
2932
with:
@@ -44,3 +47,6 @@ jobs:
4447
push: true
4548
tags: ${{ steps.meta.outputs.tags }}
4649
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max
52+

Diff for: Dockerfile

+15-8
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ RUN apt update \
55
build-essential tcl protobuf-compiler file \
66
libssl-dev pkg-config git\
77
&& apt clean \
8-
&& cargo install cargo-chef
8+
&& rm -rf /var/lib/apt/lists/*
9+
910
# We need to install and set as default the toolchain specified in rust-toolchain.toml
1011
# Otherwise cargo-chef will build dependencies using wrong toolchain
1112
# This also prevents planner and builder steps from installing the toolchain over and over again
1213
COPY rust-toolchain.toml rust-toolchain.toml
1314
RUN cat rust-toolchain.toml | grep "channel" | awk '{print $3}' | sed 's/\"//g' > toolchain.txt \
1415
&& rustup update $(cat toolchain.txt) \
1516
&& rustup default $(cat toolchain.txt) \
16-
&& rm toolchain.txt rust-toolchain.toml
17+
&& rm toolchain.txt rust-toolchain.toml \
18+
&& cargo install cargo-chef
1719

1820
FROM chef AS planner
1921
COPY . .
@@ -27,14 +29,19 @@ RUN cargo build -p sqld --release
2729

2830
# runtime
2931
FROM debian:bullseye-slim
30-
COPY --from=builder /target/release/sqld /bin/sqld
32+
33+
EXPOSE 5001 8080
34+
VOLUME [ "/var/lib/sqld" ]
35+
3136
RUN groupadd --system --gid 666 sqld
3237
RUN adduser --system --home /var/lib/sqld --uid 666 --gid 666 sqld
33-
RUN apt-get update && apt-get install -y ca-certificates
34-
COPY docker-entrypoint.sh /usr/local/bin
35-
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
36-
VOLUME [ "/var/lib/sqld" ]
3738
WORKDIR /var/lib/sqld
3839
USER sqld
39-
EXPOSE 5001 8080
40+
41+
COPY docker-entrypoint.sh /usr/local/bin
42+
43+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
44+
COPY --from=builder /target/release/sqld /bin/sqld
45+
46+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
4047
CMD ["/bin/sqld"]

0 commit comments

Comments
 (0)