forked from mosaicdao/rust-mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
32 lines (25 loc) · 946 Bytes
/
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
# Using the official rust image as a builder stage
FROM rust:1.31.1-stretch as builder
# Copying the source and compiling it with cargo
WORKDIR /usr/src/rust-mosaic
COPY . .
RUN cargo build --release
# Second stage for distribution.
# Based on debian, as the rust image is based on debian and libraries
# are dynamically linked. We could use musl instead to use a smaller
# base image, e.g. alpine, for distribution.
FROM debian:stretch
# libssl-dev is a dependency of rust-mosaic.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libssl-dev
# Creating a user mosaic with group and home dir.
ENV HOME /home/mosaic
RUN groupadd -r mosaic && \
useradd --no-log-init -r -m -g mosaic mosaic
WORKDIR $HOME
# Copying the binary from the build stage to the home directory.
COPY --from=builder /usr/src/rust-mosaic/target/release/mosaic .
RUN chown -R mosaic:mosaic $HOME
USER mosaic:mosaic
ENTRYPOINT ["./mosaic"]