Skip to content

Commit ceabfb7

Browse files
committed
better configuration
1 parent e963631 commit ceabfb7

15 files changed

+156
-121
lines changed

Dockerfile

+4-12
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,19 @@ RUN ./install-packages.sh
3030
# ----------------------------------------------------
3131
# Install dependencies
3232
# ----------------------------------------------------
33-
FROM common-base AS dependencies
33+
FROM common-base AS app-run
34+
3435
ENV PATH="/opt/venv/bin:$PATH"
3536

36-
# apt-get install build-essential -y
3737
COPY requirements.txt /app/
38-
39-
RUN pip install --target /opt/packages -r requirements.txt
40-
41-
# ----------------------------------------------------
42-
# Copy project
43-
# ----------------------------------------------------
44-
FROM common-base AS app-run
45-
COPY --from=dependencies /opt/packages /opt/packages
46-
ENV PYTHONPATH "${PYTHONPATH}:/opt/packages"
47-
# ENV PYTHONPATH="$PYTHONPATH:/app/lemarche:/app/config"
4838
COPY ./ark ./ark
4939
COPY ./ark_import ./ark_import
5040
COPY ./arklet ./arklet
5141
COPY ./manage.py ./manage.py
5242
COPY ./docker/entrypoint.sh ./entrypoint.sh
5343

44+
RUN pip install -r requirements.txt
45+
5446
# ----------------------------------------------------
5547
# Run Dev
5648
# ----------------------------------------------------

docker-compose.nginx.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: "3.7"
2+
3+
services:
4+
arklet-minter:
5+
container_name: arklet_minter
6+
restart: always
7+
build:
8+
context: .
9+
target: prod
10+
dockerfile: ./Dockerfile
11+
command: /app/entrypoint.sh
12+
volumes:
13+
- ./ark:/app/ark
14+
- ./arklet:/app/arklet
15+
- static_volume:/app/static
16+
env_file:
17+
- ./docker/env.prod
18+
env:
19+
- ARKLET_PORT: 8001
20+
expose:
21+
- 8001
22+
23+
arklet-resolver:
24+
container_name: arklet_resolver
25+
restart: always
26+
build:
27+
context: .
28+
target: prod
29+
dockerfile: ./Dockerfile
30+
command: /app/entrypoint.sh
31+
volumes:
32+
- ./ark:/app/ark
33+
- ./arklet:/app/arklet
34+
- static_volume:/app/static
35+
env_file:
36+
- ./docker/env.prod
37+
env:
38+
- ARKLET_PORT: 8000
39+
- RESOLVER: true
40+
expose:
41+
- 8000
42+
43+
nginx:
44+
build: ./nginx
45+
ports:
46+
- 80:80
47+
- 8080:8080
48+
depends_on:
49+
- arklet-minter
50+
- arklet-resolver
51+
volumes:
52+
- static_volume:/app/static
53+
54+
volumes:
55+
static_volume:

docker-compose.prod.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ services:
88
context: .
99
target: prod
1010
dockerfile: ./Dockerfile
11-
command: /app/entrypoint.sh
11+
command: /app/entrypoint.prod.sh
1212
volumes:
1313
- ./ark:/app/ark
14-
- ./ark_import:/app/ark_import
1514
- ./arklet:/app/arklet
1615
env_file:
1716
- ./docker/env.postgres.prod
@@ -26,10 +25,9 @@ services:
2625
context: .
2726
target: prod
2827
dockerfile: ./Dockerfile
29-
command: /app/entrypoint.sh
28+
command: /app/entrypoint.prod.sh
3029
volumes:
3130
- ./ark:/app/ark
32-
- ./ark_import:/app/ark_import
3331
- ./arklet:/app/arklet
3432
env_file:
3533
- ./docker/env.postgres.prod

docker/entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ while ! pg_isready -h $ARKLET_POSTGRES_HOST -p $ARKLET_POSTGRES_PORT; do
99
sleep 1
1010
done
1111

12-
# Following rules depend on what you expect from django dev docker
13-
# ./manage.py collectstatic --noinput
14-
# ./manage.py compress --force
15-
1612
./manage.py migrate
17-
./manage.py createsuperuser
1813

19-
./manage.py runserver 0.0.0.0:$ARKLET_PORT
20-
# gunicorn config.wsgi:application -w 2 -b :8880 --reload
14+
if [ "$ENV" = "dev" ]; then
15+
./manage.py runserver 0.0.0.0:$ARKLET_PORT
16+
else
17+
./manage.py collectstatic --noinput
18+
gunicorn arklet.wsgi:application --bind 0.0.0.0:$ARKLET_PORT
19+
fi

docker/env.local

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARKLET_DJANGO_SECRET_KEY=local-test-secret ##ggignore
2+
ARKLET_DEBUG=True
3+
ARKLET_HOST=127.0.0.1
4+
5+
# Would be nice to undup these eventually
6+
POSTGRES_DB=arklet
7+
ARKLET_POSTGRES_NAME=arklet
8+
9+
POSTGRES_USER=postgres
10+
ARKLET_POSTGRES_USER=postgres
11+
12+
POSTGRES_PASSWORD=postgres # ggignore
13+
ARKLET_POSTGRES_PASSWORD=postgres # ggignore
14+
15+
POSTGRES_HOST=postgres
16+
ARKLET_POSTGRES_HOST=postgres
17+
18+
POSTGRESQL_PORT=5432
19+
ARKLET_POSTGRES_PORT=5432

docker/env.minter.local

-12
This file was deleted.

docker/env.minter.prod

-12
This file was deleted.

docker/env.postgres.local

-23
This file was deleted.

docker/env.postgres.prod

-23
This file was deleted.

docker/env.prod.example

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ARKLET_DJANGO_SECRET_KEY=
2+
3+
ARKLET_DEBUG=False
4+
ARKLET_HOST=ark.frick.org
5+
6+
# Would be nice to undup these eventually
7+
POSTGRES_DB=arklet
8+
ARKLET_POSTGRES_NAME=arklet
9+
10+
POSTGRES_USER=arklet_user
11+
ARKLET_POSTGRES_USER=arklet_user
12+
13+
POSTGRES_PASSWORD=
14+
ARKLET_POSTGRES_PASSWORD=
15+
16+
POSTGRES_HOST=
17+
ARKLET_POSTGRES_HOST=
18+
19+
POSTGRESQL_PORT=25060
20+
ARKLET_POSTGRES_PORT=25060

docker/env.resolver.local

-12
This file was deleted.

docker/env.resolver.prod

-12
This file was deleted.

makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
default: prod
1+
default: local
22

3-
prod:
4-
docker-compose -f docker-compose.prod.yml up
3+
local:
4+
docker-compose up --build
5+
6+
nginx:
7+
docker-compose -f docker-compose.nginx.yml up --build
58

69
dev-cmd:
710
docker exec -it arklet_minter /bin/bash
811

912
dev-psql:
10-
source docker/env.postgres.local && docker exec -it arklet_db psql -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
13+
source docker/env.local && docker exec -it arklet_db psql -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"

nginx/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:1.25
2+
3+
RUN rm /etc/nginx/conf.d/default.conf
4+
COPY nginx.conf /etc/nginx/conf.d

nginx/nginx.conf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
upstream arklet_resolver {
2+
# matches the container name and port in docker-compose.nginx.yml
3+
server arklet_resolver:8000;
4+
}
5+
6+
upstream arklet_minter {
7+
# matches the container name and port in docker-compose.nginx.yml
8+
server arklet_minter:8001;
9+
}
10+
11+
12+
server {
13+
14+
listen 80;
15+
16+
location / {
17+
proxy_pass http://arklet_resolver;
18+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19+
proxy_set_header Host $host;
20+
proxy_redirect off;
21+
}
22+
23+
}
24+
25+
server {
26+
listen 8080;
27+
28+
location / {
29+
proxy_pass http://arklet_minter;
30+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31+
proxy_set_header Host $host;
32+
proxy_redirect off;
33+
}
34+
35+
location /static/ {
36+
alias /app/static/;
37+
}
38+
39+
}

0 commit comments

Comments
 (0)