-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
60 lines (47 loc) · 1.63 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
FROM python:3.11-slim-bookworm 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/base.txt \
-r /requirements/production.txt
FROM node:18-bullseye AS build-node
#RUN apt-get update && apt-get -y install curl
#RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
#RUN apt-get install -y nodejs
RUN nodejs -v && npm -v
WORKDIR /app
COPY . /app
RUN npm install
RUN npm run build
FROM python:3.11-slim-bookworm
ENV PYTHONUNBUFFERED 1
ENV DEBUG 0
RUN apt-get update \
# psycopg2, gettext etc dependencies
&& apt-get install -y libpq-dev gettext curl \
# 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
ENV DJANGO_SETTINGS_MODULE=config.settings.staging
COPY --from=build-node /app/commcare_connect/static/bundles /app/commcare_connect/static/bundles
COPY --from=build-python /wheels /wheels
COPY ./requirements /requirements
RUN pip install --no-index --find-links=/wheels \
-r /requirements/base.txt \
-r /requirements/production.txt \
&& rm -rf /wheels \
&& rm -rf /root/.cache/pip/*
WORKDIR /app
COPY ./docker/* /
RUN chmod +x /entrypoint /start*
RUN chown django /entrypoint /start*
COPY --chown=django:django . /app
RUN python /app/manage.py collectstatic --noinput
RUN chown django:django -R staticfiles
USER django
EXPOSE 8000
ENTRYPOINT ["/entrypoint"]