-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
56 lines (40 loc) · 1.57 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
48
49
50
51
52
53
54
55
56
###### FRONTEND ######
# Build frontend resources in node container
FROM node:20-slim AS frontend-build
# Build with npm
COPY frontend /build/flugbuech/
RUN cd /build/flugbuech && npm install && npm run build
###### BACKEND ######
# Build server resources in rust container
FROM docker.io/rust:1-buster AS backend-build
# Build binary
COPY . /build/flugbuech/
RUN cd /build/flugbuech && cargo build --release
###### RUNTIME ######
FROM debian:11-slim
# Install init process and other dependencies
RUN apt-get update -q \
&& apt-get -y -q install --no-install-recommends dumb-init libpq5 \
&& rm -rf /var/lib/apt/lists/*
# Create users and directories
RUN addgroup --gid 1000 flugbuech \
&& adduser --disabled-password --gecos "" --uid 1000 --gid 1000 flugbuech
RUN mkdir /flugbuech \
&& chown flugbuech:flugbuech /flugbuech/ \
&& chmod 0700 /flugbuech/
RUN mkdir /static \
&& chown flugbuech:flugbuech /static/ \
&& chmod 0700 /static/
# Copy backend files
COPY --from=backend-build --chown=flugbuech:flugbuech /build/flugbuech/target/release/flugbuech-api /flugbuech/flugbuech-api
COPY --from=backend-build --chown=flugbuech:flugbuech /build/flugbuech/Rocket.toml /flugbuech/Rocket.toml
# Copy frontend files
COPY --from=frontend-build --chown=flugbuech:flugbuech /build/flugbuech/build /flugbuech/static
# Specify workdir and user
WORKDIR /flugbuech
USER flugbuech
# Create volumes
VOLUME ["/static"]
ENV RUST_BACKTRACE=1
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/bin/bash", "-c", "rm -rf /static/* && cp -Rv /flugbuech/static/* /static/ && exec ./flugbuech-api --migrate"]