1- FROM dappforce/cargo-chef:latest AS chef
1+ FROM phusion/baseimage:jammy-1.0.1 AS builder
2+
3+ ENV DEBIAN_FRONTEND=noninteractive
4+
25WORKDIR /subsocial
36
4- FROM chef AS planner
5- COPY . .
6- RUN cargo chef prepare --recipe-path recipe.json
7+ COPY . /subsocial
8+
9+ RUN apt-get update && \
10+ apt-get upgrade -y -o Dpkg::Options::="--force-confold"
11+
12+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
13+ RUN ./scripts/init.sh nosudo
714
8- FROM chef AS builder
9- COPY --from=planner /subsocial/recipe.json recipe.json
15+ SHELL [ "/bin/bash" , "-o" , "pipefail" , "-c" ]
16+ RUN . "$HOME/.cargo/env" && cargo build --release
1017
11- # Build dependencies - this is the caching Docker layer!
12- RUN cargo chef cook --release --recipe-path recipe.json
18+ # ==== SECOND STAGE ====
1319
14- # Build application
15- COPY . .
16- RUN cargo build --release
20+ FROM phusion/baseimage:jammy-1.0.1
21+
22+ RUN mv /usr/share/ca* /tmp && \
23+ rm -rf /usr/share/* && \
24+ mv /tmp/ca-certificates /usr/share/ && \
25+ useradd -m -u 1000 -U -s /bin/sh -d /subsocial subsocial && \
26+ mkdir -p /data && chown -R subsocial:subsocial /data
1727
18- FROM debian:buster-slim
1928COPY --from=builder /subsocial/target/release/subsocial-collator /usr/local/bin
2029
21- RUN useradd -m -u 1000 -U -s /bin/sh -d /subsocial subsocial && \
22- apt update && apt install curl -y && \
23- mkdir -p /subsocial/.local/share && \
24- mkdir /data && \
25- chown -R subsocial:subsocial /data && \
26- chown -R subsocial:subsocial /bin && \
27- ln -s /data /subsocial/.local/share/subsocial-collator
30+ # checks
31+ RUN ldd /usr/local/bin/subsocial-collator && \
32+ /usr/local/bin/subsocial-collator --version
33+
34+ # Shrinking
35+ RUN rm -rf /usr/lib/python* && rm -rf /usr/share/man
2836
2937USER subsocial
30- EXPOSE 40333 8833 8844
3138VOLUME ["/data" ]
3239
33- ENTRYPOINT ["/usr/local/bin/subsocial-collator" ]
40+ ENTRYPOINT ["/usr/local/bin/subsocial-collator" ]
0 commit comments