-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
119 lines (96 loc) · 2.92 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
ARG BASE_IMAGE=jammy
FROM ubuntu:${BASE_IMAGE} AS base
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV TZ=UTC
ENV COLLECTSTATIC=1
ENV TIMEOUT=60
ENV WORKERS=1
ENV MAX_REQUESTS=250
ENV PUPPETEER_CACHE_DIR=/app/puppeteer/
RUN useradd -ms /bin/bash django
RUN mkdir -p /app/static /opt
RUN chown django:django /app /opt
RUN apt-get -qq update && apt-get install -qq -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
ca-certificates \
fonts-liberation \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
git wget less nano curl \
ca-certificates \
gettext \
libgbm-dev && \
apt-get -q -y full-upgrade && \
apt-get clean all && rm -rf /var/apt/lists/* && rm -rf /var/cache/apt/*
COPY .docker/entrypoint.sh /usr/local/bin
EXPOSE 8000
WORKDIR /app/src
ENTRYPOINT ["entrypoint.sh"]
FROM base AS build
ARG NODE_ENV=production
RUN apt-get -qq update && apt-get install -qq -y \
build-essential \
python3-dev python3-venv python3-distutils libmagic1 && \
apt-get clean all && rm -rf /var/apt/lists/* && rm -rf /var/cache/apt/*
# install pip & requirements
RUN wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py && rm get-pip.py
USER django
RUN python3 -m venv /opt/venv
RUN /opt/venv/bin/pip3 install --no-cache-dir pip setuptools wheel -U
COPY requirements.txt /app/
RUN /opt/venv/bin/pip3 install --no-cache-dir -r /app/requirements.txt -U && rm /app/requirements.txt
RUN /opt/venv/bin/nodeenv /app/venv/ -C '' -p -n 20.9.0
# upgrade npm & requirements
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
RUN . /opt/venv/bin/activate && npm ci && rm /app/*.json
FROM build AS dev
COPY requirements-dev.txt /app/
RUN /opt/venv/bin/pip3 install --no-cache-dir -r /app/requirements-dev.txt -U && rm /app/requirements-dev.txt
CMD ["./manage.py", "runserver", "0.0.0.0:8000"]
FROM base
COPY --from=build /opt/venv /opt/venv
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/puppeteer /app/puppeteer
COPY src /app/src
RUN mkdir -p /app/static && chown django:django /app/static
RUN apt-get -qq update && apt-get upgrade -qq -y && \
apt-get clean all && rm -rf /var/apt/lists/* && rm -rf /var/cache/apt/*
VOLUME /app/static
USER django
CMD gunicorn screamshotter.wsgi:application -w $WORKERS --max-requests $MAX_REQUESTS --timeout `expr $TIMEOUT + 10` --bind 0.0.0.0:8000 --worker-tmp-dir /dev/shm