forked from 5afe/safe-client-gateway
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
47 lines (37 loc) · 1.23 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Build Image
# We use a stable rust image as we will switch to nightly via the toolchain file.
FROM rust:1.52.0-slim-buster as builder
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
pkg-config ca-certificates libssl-dev \
&& rm -rf /var/lib/apt/lists/*
ENV USER=root
WORKDIR "/app"
# Cache dependencies
# We copy the toolchain requirements first.
# This will make it possible that all the stages after the init can be cached.
COPY rust-toolchain rust-toolchain
RUN cargo init
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
RUN cargo build --release --locked
COPY . .
ARG VERSION
ARG BUILD_NUMBER
# Remove fingerprint of app to force recompile (without dependency recompile)
RUN rm -rf target/release/.fingerprint/safe-client-gateway*
RUN cargo build --release --locked
# Runtime Image
FROM debian:buster-slim
WORKDIR "/app"
ENV APP_USER=rust ROCKET_ENV=production ROCKET_ADDRESS=0.0.0.0 ROCKET_PORT=3666
EXPOSE $ROCKET_PORT
RUN useradd $APP_USER
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates libssl-dev \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder --chown=rust:rust /app/target/release/safe-client-gateway ./
CMD ["./safe-client-gateway"]