Skip to content

Commit 028583c

Browse files
committed
Merge branch 'move-compose' of ../../tmp-reg3 into dockerfile
2 parents c7023bb + e854604 commit 028583c

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM python:3.12.7 AS base
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
RUN apt-get update \
9+
&& apt-get install -y \
10+
git \
11+
netcat-openbsd \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
COPY ./requirements.txt .
15+
COPY ./requirements-dev.txt .
16+
RUN pip install -r requirements-dev.txt
17+
18+
19+
FROM base AS collectstatic
20+
COPY . .
21+
RUN DJANGO_STATIC_ROOT=/static python manage.py collectstatic --no-input
22+
RUN find /static -ls
23+
24+
FROM ghcr.io/static-web-server/static-web-server:2.33.1 AS static-server
25+
WORKDIR /srv/http
26+
ENV SERVER_ROOT=/srv/http
27+
28+
COPY --from=collectstatic /static /srv/http/static
29+
30+
31+
FROM base AS dev
32+
ENV RUN_MODE=dev
33+
COPY ./entrypoint.sh .
34+
ENTRYPOINT ["/app/entrypoint.sh"]
35+
36+
37+
FROM dev AS server
38+
ENV RUN_MODE=prod
39+
40+
COPY . .

Dockerfile.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Don't include react app in Django container
2+
/registration-frontend-react
3+
4+
.env
5+
/docker-compose.yaml
6+
/compose.yaml
7+
/Dockerfile
8+
/Dockerfile.dockerignore
9+
/*.sqlite3

entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
if [ "$DJANGO_DATABASE_ENGINE" = "django.db.backends.postgresql" ]; then
4+
echo "Waiting for postgres..."
5+
while ! nc -z $DJANGO_DATABASE_HOST "${DJANGO_DATABASE_PORT:-5432}"; do
6+
sleep 0.1
7+
done
8+
9+
echo "PostgreSQL is running chief!"
10+
fi
11+
12+
python manage.py migrate
13+
14+
python manage.py check --deploy
15+
16+
exec "$@"
17+

0 commit comments

Comments
 (0)