Skip to content

Commit

Permalink
Add production ready VaaS instance in docker-compose (#512)
Browse files Browse the repository at this point in the history
* PLUTON-19054 | add docker-compose base

* Update vaas/vaas/resources/base-data.yaml

Co-authored-by: awmackowiak <[email protected]>

* Update docs/quick-start/docker_compose.md

Co-authored-by: awmackowiak <[email protected]>

* Update docs/quick-start/docker_compose.md

Co-authored-by: awmackowiak <[email protected]>

---------

Co-authored-by: ziollek <[email protected]>
Co-authored-by: awmackowiak <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2024
1 parent 51b19fd commit d98e9a3
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 165 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ COPY ./vaas/requirements /home/app/vaas/requirements

RUN pip install -r ./requirements/base.txt

#copy uwsgi config
COPY ./docker/uwsgi.cfg /etc/

#copy mime types used by uwsgi
COPY ./docker/mime.types /etc/

# copy project
COPY ./vaas /home/app/vaas

# copy entrypoints.sh
COPY \
docker/entrypoint-uwsgi.sh \
docker/entrypoint-uwsgi-dev.sh \
docker/entrypoint-celery-worker.sh \
docker/entrypoint-celery-routes-test.sh \
Expand Down
131 changes: 131 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
services:
celery-worker:
entrypoint: [ '/entrypoint-celery-worker.sh' ]
env_file: ./envs/dev.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
celery-cron-worker:
entrypoint: [ '/entrypoint-celery-cron-worker.sh' ]
env_file: ./envs/dev.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
celery-routes-test:
entrypoint: [ '/entrypoint-celery-routes-test.sh' ]
env_file: ./envs/dev.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
uwsgi:
entrypoint: ['/wait-for-it.sh', 'mysql:3306', '-t', '30', '--', '/entrypoint-uwsgi-dev.sh' ]
env_file: ./envs/dev.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
celery-scheduler:
entrypoint: ['/wait-for-it.sh', 'uwsgi:3030', '-t', '60', '--', '/entrypoint-celery-scheduler.sh' ]
env_file: ./envs/dev.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default

# Varnishes & nginx
nginx-0:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.10
nginx-1:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.11
nginx-2:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.12
nginx-3:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.13
nginx-4:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.14
nginx-5:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.15
varnish-4.1:
build: ./docker/varnish-4.1
image: allegro/vaas-varnish-4.1
expose:
- "6082"
- "6081"
networks:
vaas:
ipv4_address: 192.168.199.4
varnish-6.0.2:
build: ./docker/varnish-6.0.2
image: allegro/vaas-varnish-6.0.2
expose:
- "6082"
- "6081"
networks:
vaas:
ipv4_address: 192.168.199.6
varnish-7.0:
build: ./docker/varnish-7.0
image: allegro/vaas-varnish-7.0
expose:
- "6082"
- "6081"
networks:
vaas:
ipv4_address: 192.168.199.7
networks:
vaas:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.199.0/24
gateway: 192.168.199.1
102 changes: 6 additions & 96 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,131 +1,41 @@
services:
celery-worker:
entrypoint: [ '/entrypoint-celery-worker.sh' ]
env_file: ./envs/dev.env
env_file: ./envs/base.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
celery-cron-worker:
entrypoint: [ '/entrypoint-celery-cron-worker.sh' ]
env_file: ./envs/dev.env
env_file: ./envs/base.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
celery-routes-test:
entrypoint: [ '/entrypoint-celery-routes-test.sh' ]
env_file: ./envs/dev.env
env_file: ./envs/base.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
uwsgi:
entrypoint: ['/wait-for-it.sh', 'mysql:3306', '-t', '30', '--', '/entrypoint-uwsgi-dev.sh' ]
env_file: ./envs/dev.env
entrypoint: ['/wait-for-it.sh', 'mysql:3306', '-t', '30', '--', '/entrypoint-uwsgi.sh' ]
env_file: ./envs/base.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default
celery-scheduler:
entrypoint: ['/wait-for-it.sh', 'uwsgi:3030', '-t', '60', '--', '/entrypoint-celery-scheduler.sh' ]
env_file: ./envs/dev.env
env_file: ./envs/base.env
volumes:
- ./vaas:/home/app/vaas
- ./plugins:/home/app/plugins
networks:
- vaas
- default

# Varnishes & nginx
nginx-0:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.10
nginx-1:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.11
nginx-2:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.12
nginx-3:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.13
nginx-4:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.14
nginx-5:
build: ./docker/nginx
image: vaas-nginx
expose:
- "80"
networks:
vaas:
ipv4_address: 192.168.199.15
varnish-4.1:
build: ./docker/varnish-4.1
image: allegro/vaas-varnish-4.1
expose:
- "6082"
- "6081"
networks:
vaas:
ipv4_address: 192.168.199.4
varnish-6.0.2:
build: ./docker/varnish-6.0.2
image: allegro/vaas-varnish-6.0.2
expose:
- "6082"
- "6081"
networks:
vaas:
ipv4_address: 192.168.199.6
varnish-7.0:
build: ./docker/varnish-7.0
image: allegro/vaas-varnish-7.0
expose:
- "6082"
- "6081"
networks:
vaas:
ipv4_address: 192.168.199.7
networks:
vaas:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.199.0/24
gateway: 192.168.199.1
2 changes: 1 addition & 1 deletion docker/entrypoint-celery-cron-worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exec celery --workdir=/home/app/vaas \
-A vaas.settings worker \
--loglevel=DEBUG \
--loglevel=$LOG_LEVEL \
--concurrency=1 \
-Q cron_queue
2 changes: 1 addition & 1 deletion docker/entrypoint-celery-routes-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exec celery --workdir=/home/app/vaas \
-A vaas.settings worker \
--loglevel=DEBUG \
--loglevel=$LOG_LEVEL \
--concurrency=1 \
-Q routes_test_queue
2 changes: 1 addition & 1 deletion docker/entrypoint-celery-scheduler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ echo "Migrating Scheduler"

exec celery --workdir=/home/app/vaas \
--app=vaas.settings beat \
--loglevel=DEBUG \
--loglevel=$LOG_LEVEL \
--scheduler=beatx.schedulers.Scheduler
2 changes: 1 addition & 1 deletion docker/entrypoint-celery-worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exec celery --workdir=/home/app/vaas \
-A vaas.settings worker \
--loglevel=DEBUG \
--loglevel=$LOG_LEVEL \
--concurrency=1 \
-Q worker_queue
2 changes: 1 addition & 1 deletion docker/entrypoint-uwsgi-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ echo "Migrating"
python /home/app/vaas/manage.py migrate --run-syncdb

echo "Loading test_data"
python /home/app/vaas/manage.py loaddata ./vaas/resources/data.yaml
python /home/app/vaas/manage.py loaddata ./vaas/resources/dev-data.yaml

echo "Install the test requirements to allow [manage.py test] to be called within the container"
pip install -r /home/app/vaas/requirements/test.txt
Expand Down
16 changes: 16 additions & 0 deletions docker/entrypoint-uwsgi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

echo "Collect static files"
python /home/app/vaas/manage.py collectstatic --no-input

echo "Migrating"
python /home/app/vaas/manage.py migrate --run-syncdb

echo "Loading base-data"
python /home/app/vaas/manage.py loaddata ./vaas/resources/base-data.yaml

echo "Install the test requirements to allow [manage.py test] to be called within the container"
pip install -r /home/app/vaas/requirements/base.txt

echo "Start uwsgi server"
exec uwsgi --ini /etc/uwsgi.cfg --http-socket :3030
Loading

0 comments on commit d98e9a3

Please sign in to comment.