Skip to content

Instantly share code, notes, and snippets.

@Cally99
Created November 13, 2020 21:40
Show Gist options
  • Save Cally99/ecd2fb1ce50af2532b59ca7a3a259efe to your computer and use it in GitHub Desktop.
Save Cally99/ecd2fb1ce50af2532b59ca7a3a259efe to your computer and use it in GitHub Desktop.
version: "3.4"
services:
db:
restart: always
image: postgres
volumes:
- pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
expose:
- 5432
networks:
- random_name
redis:
restart: always
image: redis
ports:
- "6379:6379"
volumes:
- redisdata:/data
networks:
- random_name
django: &backend
container_name: django
build:
context: ./backend
dockerfile: scripts/dev/Dockerfile
env_file: .env_prod
environment:
- DEBUG=True
command: bash -c "cd autobets && uwsgi --socket :8001 --module autobets.wsgi"
# sh -c "./wait-for-it.sh db:5432 &&
# ./autobets/manage.py collectstatic --no-input &&
# ./autobets/manage.py makemigrations &&
# ./autobets/manage.py migrate --no-input &&
# cd autobets && gunicorn --workers=2 --bind=0.0.0.0:8000 autobets.wsgi:application &&
# ./autobets/manage.py createsuperuser2 --username mac --password Shakespeare021 --noinput --email 'tomirl2008@gmail.com'
# "
# command: >
# sh -c "./wait-for-it.sh db:5432 &&
# cd autobets && python manage.py collectstatic --noinput &&
# gunicorn --workers=2 --bind=0.0.0.0:8000 autobets.wsgi:application"
ports:
- "8000:8000"
volumes:
- ./backend:/app
depends_on:
- db
- rabbitmq
restart: on-failure
networks:
- random_name
rabbitmq:
hostname: rabbitmq
image: rabbitmq:latest
ports:
- "5672:5672"
restart: on-failure
networks:
- random_name
celeryworker:
build:
context: ./backend
dockerfile: scripts/dev/Dockerfile
env_file: .env_prod
volumes:
- ./backend:/app
depends_on:
- db
- django
- rabbitmq
command: sh -c "./wait-for-it.sh db:5432 && cd autobets && celery -A autobets worker -l info"
networks:
- random_name
celerybeat:
build:
context: ./backend
dockerfile: scripts/dev/Dockerfile
env_file: .env_prod
volumes:
- ./backend:/app
depends_on:
- db
- django
- rabbitmq
command: >
sh -c "./wait-for-it.sh db:5432 && cd autobets && celery -A autobets beat -l info"
networks:
- random_name
nuxt:
build:
context: ./frontend
env_file: .env_prod
environment:
- API_URI=${API_URI}
command: sh -c "npm install && npm run build && npm run start"
volumes:
- ./frontend:/app
ports:
- "3000:3000"
depends_on:
- django
- redis
networks:
- random_name
nginx:
image: nginx
container_name: nginx
ports:
- "80:80"
restart: always
depends_on:
- nuxt
- django
volumes:
- ./nginx/conf:/etc/nginx/conf.d
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
- ./backend/static:/static
networks:
- random_name
flower:
build:
context: ./backend
command: >
sh -c "./wait-for-it.sh db:5432 && cd autobets && celery flower -A autobets --address=0.0.0.0 --port=5555"
ports:
- 5555:5555
restart: on-failure
env_file: .env_prod
environment:
- CELERY_BROKER_URL=${CELERY_BROKER_URL}
- CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND}
networks:
- random_name
depends_on:
- rabbitmq
- celerybeat
- celeryworker
- django
volumes:
pgdata:
redisdata:
networks:
random_name:
##############################
nginx
path to file
autobets/nginx/conf/autobets_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
ip_hash;
server django:8001;
}
upstream nuxt {
ip_hash;
server nuxt:3000;
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name 127.0.0.1 0.0.0.0; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /static/ {
alias /static/;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
proxy_pass http://nuxt;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host;
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment