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

Commit 06302b2

Browse files
author
Athos Couto
committed
Optimize runtime container layers
1 parent 146df90 commit 06302b2

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

Dockerfile

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
FROM rust:slim-bullseye AS chef
33
RUN apt update \
44
&& apt install -y libclang-dev clang \
5-
build-essential tcl protobuf-compiler file \
6-
libssl-dev pkg-config git\
7-
&& apt clean \
8-
&& cargo install cargo-chef
5+
build-essential tcl protobuf-compiler file \
6+
libssl-dev pkg-config git\
7+
&& apt clean && rm -rf /var/lib/apt/lists/*
8+
99
# We need to install and set as default the toolchain specified in rust-toolchain.toml
1010
# Otherwise cargo-chef will build dependencies using wrong toolchain
1111
# This also prevents planner and builder steps from installing the toolchain over and over again
1212
COPY rust-toolchain.toml rust-toolchain.toml
1313
RUN cat rust-toolchain.toml | grep "channel" | awk '{print $3}' | sed 's/\"//g' > toolchain.txt \
1414
&& rustup update $(cat toolchain.txt) \
1515
&& rustup default $(cat toolchain.txt) \
16-
&& rm toolchain.txt rust-toolchain.toml
16+
&& rm toolchain.txt rust-toolchain.toml \
17+
&& cargo install cargo-chef
1718

1819
FROM chef AS planner
1920
COPY . .
@@ -27,14 +28,19 @@ RUN cargo build -p sqld --release
2728

2829
# runtime
2930
FROM debian:bullseye-slim
30-
COPY --from=builder /target/release/sqld /bin/sqld
31+
32+
EXPOSE 5001 8080
33+
VOLUME [ "/var/lib/sqld" ]
34+
3135
RUN groupadd --system --gid 666 sqld
3236
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" ]
3737
WORKDIR /var/lib/sqld
3838
USER sqld
39-
EXPOSE 5001 8080
39+
40+
COPY docker-entrypoint.sh /usr/local/bin
41+
42+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
43+
COPY --from=builder /target/release/sqld /bin/sqld
44+
45+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
4046
CMD ["/bin/sqld"]

0 commit comments

Comments
 (0)