forked from OpenLEADR/openleadr-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtn.Dockerfile
30 lines (23 loc) · 957 Bytes
/
vtn.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
FROM rust:1.80 as base
RUN apt-get update && apt-get install -y --no-install-recommends curl && apt-get clean
FROM base as builder
ADD . /app
WORKDIR /app
COPY . .
# Don't depend on live sqlx during build use cached .sqlx
RUN SQLX_OFFLINE=true cargo build --release --bin openleadr-vtn
RUN cp /app/target/release/openleadr-vtn /app/openleadr-vtn
FROM debian:bookworm-slim as final
RUN apt-get update && apt-get install curl -y
# create a non root user to run the binary
ARG user=nonroot
ARG group=nonroot
ARG uid=2000
ARG gid=2000
RUN addgroup --gid ${gid} ${group} && adduser --uid ${uid} --gid ${gid} --system --disabled-login --disabled-password ${user}
EXPOSE 3000
# get the pre-built binary from builder so that we don't have to re-build every time
COPY --from=1 --chown=nonroot:nonroot /app/openleadr-vtn/openleadr-vtn /home/nonroot/openleadr-vtn
RUN chmod 777 /home/nonroot/openleadr-vtn
USER $user
ENTRYPOINT ["./home/nonroot/openleadr-vtn"]