-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile.web
69 lines (56 loc) · 1.96 KB
/
Dockerfile.web
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
FROM python:3.11-slim-bullseye AS build-python
RUN apt-get update \
# dependencies for building Python packages
&& apt-get install -y build-essential libpq-dev
COPY ./requirements /requirements
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels \
-r /requirements/requirements.txt \
-r /requirements/prod-requirements.txt
FROM node:18-bullseye AS build-node
RUN nodejs -v && npm -v
WORKDIR /code
# keep in sync with tailwind.config.js
COPY *.json *.js .babelrc /code/
COPY gpt_playground/settings.py /code/gpt_playground/settings.py
COPY templates /code/templates/
COPY assets /code/assets/
RUN npm install
RUN npm run build
FROM python:3.11-slim-bullseye
ENV PYTHONUNBUFFERED=1
ENV DEBUG=0
RUN apt-get update && apt-get install -y \
# psycopg2 dependencies
libpq-dev \
# Translations dependencies
gettext \
# audio/video dependencies
ffmpeg \
# Azure cognitive audio dependencies
build-essential libssl-dev ca-certificates libasound2 wget \
# curl for heroku log shipping
curl \
# mimetype detection (creates /etc/mime.types)
mailcap \
# mimetype detection from content
libmagic1 \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
RUN addgroup --system django \
&& adduser --system --ingroup django django
COPY --from=build-node /code/static /code/static
COPY --from=build-python /wheels /wheels
COPY ./requirements /requirements
RUN pip install --no-index --find-links=/wheels \
-r /requirements/requirements.txt \
-r /requirements/prod-requirements.txt \
&& rm -rf /wheels \
&& rm -rf /root/.cache/pip/*
WORKDIR /code
COPY --chown=django:django . /code
RUN python manage.py collectstatic --noinput --settings=gpt_playground.settings_production
RUN chown django:django -R static_root
USER django
ENV PORT=8000
CMD ["sh", "-c", "gunicorn --bind 0.0.0.0:${PORT} --workers 1 --threads 8 --timeout 0 gpt_playground.wsgi:application"]