-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile.server
90 lines (70 loc) · 2.62 KB
/
Dockerfile.server
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
FROM rust:1.80-slim-bookworm AS rust-bookworm-slim
# ----------------------------------
FROM rust-bookworm-slim AS chef
# Create regular user
ARG USER=docker
ARG UID=1000
ARG GID=1000
RUN echo "#### USER=${USER}, UID=${UID}, GID=${GID}"
RUN test -n "${USER}" && test -n "${UID}" && test -n "${GID}"
RUN groupadd -f ${USER} --gid=${GID}
RUN useradd -m ${USER} --uid=${UID} --gid=${GID} || true
# Install cargo chef (Rust build cache for Docker)
USER ${UID}:${GID}
# RUN cargo install cargo-chef
RUN cargo install cargo-deb
USER root
# Add deb-multimedia repository (for a more recent ffmpeg)
RUN apt-get -qy update
RUN apt-get -qy install gnupg2 wget
RUN wget -q https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb
RUN dpkg -i deb-multimedia-keyring_2016.8.1_all.deb
RUN echo "deb https://www.deb-multimedia.org bookworm main non-free" > /etc/apt/sources.list.d/deb-multimedia.list
RUN apt-get -qy update
# Install system packages
RUN apt-get -qy update
RUN apt-get -qy install acl sudo logrotate >/dev/null
# Install system packages
RUN apt-get -qy update >/dev/null
RUN apt-get -qy install make git >/dev/null
RUN apt-get -qy install ffmpeg >/dev/null
RUN apt-get -qy install mediainfo >/dev/null
RUN apt-get -qy install mscgen >/dev/null
RUN apt-get -qy install sqlite3 >/dev/null
# Rust build deps
RUN apt-get -qy install libssl-dev >/dev/null
RUN apt-get -qy install libsqlite3-dev >/dev/null
RUN apt-get -qy install protobuf-compiler >/dev/null
RUN apt-get -qy install python3 python3.11 python3.11-venv >/dev/null
# Switch to regular user
RUN mkdir -p /app
RUN chown -R ${UID}:${GID} /app
USER ${UID}:${GID}
# ----------------------------------
FROM chef AS planner
RUN mkdir -p /app/server
WORKDIR /app/server
# COPY --chown=${UID}:${GID} server/Cargo.toml .
# RUN cargo chef prepare --recipe-path recipe.json
#
# RUN mkdir -p /app/protobuf/libs/rust
# WORKDIR /app/protobuf/libs/rust
# COPY --chown=${UID}:${GID} ../protobuf/libs/rust/Cargo.toml .
# RUN cargo chef prepare --recipe-path recipe.json
# ----------------------------------
FROM chef AS builder
# Prebuild dependencies (build cache)
WORKDIR /app/protobuf/libs/rust
# COPY --from=planner /app/protobuf/libs/rust/recipe.json ./
# RUN cargo chef cook --recipe-path recipe.json
WORKDIR /app/server
# COPY --from=planner /app/server/recipe.json ./
# RUN cargo chef cook --recipe-path recipe.json
# Copy dep sources
COPY --chown=${UID}:${GID} protobuf /app/protobuf
COPY --chown=${UID}:${GID} organizer /app/organizer
COPY --chown=${UID}:${GID} server /app/server
# -- config entrypoint --
WORKDIR /app/server
EXPOSE 8095
CMD ["make", "run-local"]