This repository was archived by the owner on Oct 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
106 lines (85 loc) · 2.01 KB
/
Dockerfile
File metadata and controls
106 lines (85 loc) · 2.01 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# artifacts: false
# platforms: linux/amd64,linux/arm64/v8
FROM python:3.12-slim-bookworm AS base
FROM base AS build
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install build dependencies
RUN <<_DEPS
#!/bin/bash
set -e
dependencies=(
"build-essential"
"libjpeg-dev" # pillow
"npm" # web dependencies
"pkg-config"
"libopenblas-dev"
"zlib1g-dev" # pillow
)
apt-get update -y
apt-get install -y --no-install-recommends "${dependencies[@]}"
apt-get clean
rm -rf /var/lib/apt/lists/*
_DEPS
# python virtualenv
RUN python -m venv /opt/venv
# use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
# setup app directory
WORKDIR /build
COPY . .
# setup python requirements
RUN <<_REQUIREMENTS
#!/bin/bash
set -e
python -m pip install --no-cache-dir --upgrade pip setuptools wheel
python -m pip install --no-cache-dir -r requirements.txt
_REQUIREMENTS
# compile locales
RUN python scripts/_locale.py --compile
# setup npm and dependencies
RUN <<_NPM
#!/bin/bash
set -e
npm install
mv -f ./node_modules/ ./web/
_NPM
# compile docs
WORKDIR /build/docs
RUN sphinx-build -M html source build
FROM base AS app
# copy app from builder
COPY --from=build /build/ /app/
# copy python venv
COPY --from=build /opt/venv/ /opt/venv/
# use the venv
ENV PATH="/opt/venv/bin:$PATH"
# site-packages are in /opt/venv/lib/python<version>/site-packages/
# setup remaining env variables
ENV RETROARCHER_DOCKER=True
# network setup
EXPOSE 9696
# setup user
ARG PGID=1000
ENV PGID=${PGID}
ARG PUID=1000
ENV PUID=${PUID}
ENV TZ="UTC"
ARG UNAME=lizard
ENV UNAME=${UNAME}
ENV HOME=/home/$UNAME
# setup user
RUN <<_SETUP_USER
#!/bin/bash
set -e
groupadd -f -g "${PGID}" "${UNAME}"
useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}"
mkdir -p ${HOME}/.config/retroarcher
ln -s ${HOME}/.config/retroarcher /config
chown -R ${UNAME} ${HOME}
_SETUP_USER
# mounts
VOLUME /config
USER ${UNAME}
WORKDIR ${HOME}
ENTRYPOINT ["python", "./src/retroarcher.py"]
HEALTHCHECK --start-period=90s CMD python ./src/retroarcher.py --docker_healthcheck || exit 1