diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml new file mode 100644 index 0000000..436833b --- /dev/null +++ b/docker-compose-prod.yml @@ -0,0 +1,39 @@ +version: '3' +services: + nginx: + image: nginx:latest + container_name: nginx + restart: always + ports: + - "8000:8000" + volumes: + - ./nginx:/etc/nginx/conf.d + - .:/usr/src/app + depends_on: + - web + web: + build: . + container_name: prod_django + restart: always + command: bash -c "pip install -r requirements.txt && python manage.py collectstatic --noinput && python manage.py migrate && gunicorn zod_bank.wsgi -b 0.0.0.0:8000 -t 300 --log-level=info" + volumes: + - .:/usr/src/app + + broker: + image: rabbitmq:3.7 + container_name: prod_rabbitmq + volumes: + - .:/usr/src/app + ports: + - 5673:5673 + + worker: + build: . + image: celery + container_name: prod_celery + restart: "always" + command: bash -c " celery -A zod_bank.celery worker --concurrency=1 -B -l DEBUG -E" + volumes: + - .:/usr/src/app + depends_on: + - broker diff --git a/docker-compose-qa.yml b/docker-compose-qa.yml new file mode 100644 index 0000000..6e3f4d5 --- /dev/null +++ b/docker-compose-qa.yml @@ -0,0 +1,39 @@ +version: '3' +services: + nginx: + image: nginx:latest + container_name: nginx + restart: always + ports: + - "8000:8000" + volumes: + - ./nginx:/etc/nginx/conf.d + - .:/usr/src/app + depends_on: + - web + web: + build: . + container_name: qa_django + restart: always + command: bash -c "pip install -r requirements.txt && python manage.py collectstatic --noinput && python manage.py migrate && gunicorn zod_bank.wsgi -b 0.0.0.0:8000 -t 300 --log-level=info" + volumes: + - .:/usr/src/app + + broker: + image: rabbitmq:3.7 + container_name: qa_rabbitmq + volumes: + - .:/usr/src/app + ports: + - 5673:5673 + + worker: + build: . + image: celery + container_name: qa_celery + restart: "always" + command: bash -c " celery -A zod_bank.celery worker --concurrency=1 -B -l DEBUG -E" + volumes: + - .:/usr/src/app + depends_on: + - broker diff --git a/docker-compose-stage.yml b/docker-compose-stage.yml new file mode 100644 index 0000000..39db221 --- /dev/null +++ b/docker-compose-stage.yml @@ -0,0 +1,39 @@ +version: '3' +services: + nginx: + image: nginx:latest + container_name: nginx + restart: always + ports: + - "8000:8000" + volumes: + - ./nginx:/etc/nginx/conf.d + - .:/usr/src/app + depends_on: + - web + web: + build: . + container_name: stage_django + restart: always + command: bash -c "pip install -r requirements.txt && python manage.py collectstatic --noinput && python manage.py migrate && gunicorn zod_bank.wsgi -b 0.0.0.0:8000 -t 300 --log-level=info" + volumes: + - .:/usr/src/app + + broker: + image: rabbitmq:3.7 + container_name: stage_rabbitmq + volumes: + - .:/usr/src/app + ports: + - 5673:5673 + + worker: + build: . + image: celery + container_name: stage_celery + restart: "always" + command: bash -c " celery -A zod_bank.celery worker --concurrency=1 -B -l DEBUG -E" + volumes: + - .:/usr/src/app + depends_on: + - broker diff --git a/zod_bank/settings.py b/zod_bank/settings.py index 7ea1f74..590bc9d 100644 --- a/zod_bank/settings.py +++ b/zod_bank/settings.py @@ -35,19 +35,28 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = os.getenv('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv('DEBUG') +ENV = os.getenv('ENV') # cors allow setting CORS_ORIGIN_ALLOW_ALL = False # Allow specific origins +# if ENV in ['dev', 'qa', 'stage']: CORS_ALLOWED_ORIGINS = [ + # backend base url "https://dev-api.zodqaapp.com", "https://qa-api.zodqaapp.com", "https://stage-api.zodqaapp.com", + + # frontend url + "http://localhost:3000", + "https://zod-dev.zodqaapp.com", + "https://zod-qa.zodqaapp.com", + "https://zod-stage.zodqaapp.com", # Add more trusted origins as needed ] -# if DEBUG: -# CORS_ALLOWED_ORIGINS += ["http://localhost:3000"] +if ENV == "prod": + CORS_ALLOWED_ORIGINS = [] # allow all host ALLOWED_HOSTS = ['*']