-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
68 lines (46 loc) · 1.83 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
57
58
59
60
61
62
63
64
65
66
67
68
# Cochar - create a random character for Call of Cthulhu RPG 7th ed.
# Copyright (C) 2023 Adam Walkiewicz
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM python:3.11-bullseye AS build
# Add non root user
RUN useradd -u 1001 nonroot
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN <<EOT
apt-get update
apt-get install -y --no-install-recommends gcc
EOT
COPY requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
# Clone randname repo with full database with names
RUN git clone https://github.com/ajwalkiewicz/randname.git /app/randname
# Copy the scripts to the folder
COPY . .
FROM python:3.11-slim-bullseye
WORKDIR /app
RUN <<EOT
apt-get update
apt-get install python3-libxml2 -y
EOT
# Copy the passwd file
COPY --from=build /etc/passwd /etc/passwd
COPY --link --from=build /app/wheels /wheels
COPY --link --from=build /app/requirements.txt .
RUN pip install --no-cache /wheels/*
COPY --link --from=build /app .
RUN cp -r /app/randname/full_database/* /usr/local/lib/python3.11/site-packages/randname/data
# Use nonroot user
USER nonroot
EXPOSE 80
# Start the server
CMD ["uwsgi", "--http", "0.0.0.0:80", "--master", "-p", "4", "-w", "wsgi", "--py-autoreload", "3"]