-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
34 lines (26 loc) · 1 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
# 1: Build the exe
FROM rust:1.63 as builder
WORKDIR /usr/src
# 1a: Prepare for static linking
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends pkg-config graphviz libpq-dev musl-tools ca-certificates wget gcc libssl-dev libc6-dev
# 1b: Download and compile Rust dependencies (and store as a separate Docker layer)
RUN USER=root cargo new lowestbins
WORKDIR /usr/src/lowestbins
COPY Cargo.toml Cargo.lock ./
RUN cargo install --path .
# 1c: Build the exe using the actual source code
COPY src ./src
RUN cargo install --no-default-features --path .
# 2: Copy the exe and extra files ("static") to an empty Docker image
FROM debian:stable-slim
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
RUN addgroup --gid 1000 runner && \
adduser --uid 1000 --home /data --ingroup runner --disabled-password runner
USER runner
VOLUME /data
WORKDIR /data
EXPOSE 8080/tcp
COPY --from=builder /usr/local/cargo/bin/lowestbins .
CMD ["./lowestbins"]