forked from ministryofjustice/fala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
87 lines (61 loc) · 2.06 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
FROM node:10 as node_build
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN ./node_modules/.bin/gulp build --production
#################################################
# BASE IMAGE USED BY ALL STAGES
#################################################
FROM python:3.12-bullseye as base
COPY --from=node_build ./fala/assets /home/app/fala/assets
ENV LC_CTYPE=C.UTF-8
# Runtime User
RUN useradd --uid 1000 --user-group -m -d /home/app app
# Install python and build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
libpcre3 \
libpcre3-dev
ENV HOME /home/app
ENV APP_HOME /home/app
WORKDIR /home/app
#################################################
# DEVELOPMENT
#################################################
FROM base AS development
# Install Python dependencies for development, includes tests.
COPY ./requirements/generated/requirements-dev.txt ./requirements.txt
RUN pip3 install --user --requirement ./requirements.txt
# Add .local/bin to PATH to allow playwright command execution
ENV PATH=/home/app/.local/bin:$PATH
RUN playwright install --with-deps
COPY fala/ fala/
COPY manage.py manage.py
RUN ./manage.py collectstatic --noinput
# Project permissions
RUN chown -R app: /home/app
USER 1000
EXPOSE 8000
CMD ["/home/app/docker/run.sh"]
#################################################
# PRODUCTION
#################################################
FROM base AS production
# Install Python dependencies
COPY ./requirements/generated/requirements-production.txt ./requirements.txt
RUN pip3 install --user --requirement ./requirements.txt
# Copy migrate_db.sh to the /home/app/fala directory
COPY fala/migrate_db.sh /home/app/fala/migrate_db.sh
# Ensure the correct ownership
RUN chown app:app /home/app/fala/migrate_db.sh
# Ensure the script has execute permissions
RUN chmod +x /home/app/fala/migrate_db.sh
COPY . .
RUN ./manage.py collectstatic --noinput
# Project permissions
RUN chown -R app: /home/app
USER 1000
EXPOSE 8000
CMD ["/home/app/docker/run.sh"]