Refactored the .envs

This commit is contained in:
Corey Oordt 2019-07-23 08:09:41 -05:00
parent b854da5b3d
commit 5507dfe4f9
9 changed files with 20 additions and 50 deletions

View File

@ -1,14 +1,3 @@
"""
NOTE:
the below code is to be maintained Python 2.x-compatible
as the whole Cookiecutter Django project initialization
can potentially be run in Python 2.x environment
(at least so we presume in `pre_gen_project.py`).
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
"""
from __future__ import print_function
import os
import random
import shutil
@ -56,7 +45,7 @@ def remove_pycharm_files():
def remove_docker_files():
shutil.rmtree("compose")
file_names = ["local.yml", "production.yml", ".dockerignore"]
file_names = ["dev.yml", ".dockerignore"]
for file_name in file_names:
os.remove(file_name)
@ -220,10 +209,10 @@ def append_to_gitignore_file(s):
def set_flags_in_envs(postgres_user, celery_flower_user, debug=False):
local_django_envs_path = os.path.join(".envs", ".local", ".django")
production_django_envs_path = os.path.join(".envs", ".production", ".django")
local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres")
production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres")
local_django_envs_path = os.path.join(".envs", "dev", "django")
production_django_envs_path = os.path.join(".envs", "prod", "django")
local_postgres_envs_path = os.path.join(".envs", "dev", "postgres")
production_postgres_envs_path = os.path.join(".envs", "prod", "postgres")
set_django_secret_key(production_django_envs_path)
set_django_admin_url(production_django_envs_path)

View File

@ -1,15 +1,3 @@
"""
NOTE:
the below code is to be maintained Python 2.x-compatible
as the whole Cookiecutter Django project initialization
can potentially be run in Python 2.x environment.
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
"""
from __future__ import print_function
import sys
TERMINATOR = "\x1b[0m"
WARNING = "\x1b[1;33m [WARNING]: "
INFO = "\x1b[1;33m [INFO]: "

View File

@ -1,7 +0,0 @@
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB={{ cookiecutter.project_slug }}
POSTGRES_USER=!!!SET POSTGRES_USER!!!
POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!!

View File

@ -4,10 +4,10 @@ from typing import Sequence
import pytest
ROOT_DIR_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
PRODUCTION_DOTENVS_DIR_PATH = os.path.join(ROOT_DIR_PATH, ".envs", ".production")
PRODUCTION_DOTENVS_DIR_PATH = os.path.join(ROOT_DIR_PATH, ".envs", "prod")
PRODUCTION_DOTENV_FILE_PATHS = [
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".django"),
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".postgres"),
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, "django"),
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, "postgres"),
]
DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, ".env")

View File

@ -6,4 +6,4 @@ set -o nounset
python /app/manage.py collectstatic --noinput
/usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app
/usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:8000 --chdir=/app

View File

@ -8,7 +8,7 @@ services:
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
dockerfile: ./compose/dev/django/Dockerfile
image: {{ cookiecutter.project_slug }}_local_django
depends_on:
- postgres
@ -18,8 +18,8 @@ services:
volumes:
- .:/app
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
- ./.envs/dev/django
- ./.envs/dev/postgres
ports:
- "8000:8000"
command: /start
@ -27,13 +27,13 @@ services:
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: {{ cookiecutter.project_slug }}_production_postgres
dockerfile: postgres:11-alpine
image: {{ cookiecutter.project_slug }}_postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/backups
env_file:
- ./.envs/.local/.postgres
- .envs/dev/postgres
{%- if cookiecutter.use_mailhog == 'y' %}
mailhog:
@ -49,7 +49,7 @@ services:
celeryworker:
<<: *django
image: {{ cookiecutter.project_slug }}_local_celeryworker
image: {{ cookiecutter.project_slug }}_celeryworker
depends_on:
- redis
- postgres
@ -61,7 +61,7 @@ services:
celerybeat:
<<: *django
image: {{ cookiecutter.project_slug }}_local_celerybeat
image: {{ cookiecutter.project_slug }}_celerybeat
depends_on:
- redis
- postgres
@ -73,7 +73,7 @@ services:
flower:
<<: *django
image: {{ cookiecutter.project_slug }}_local_flower
image: {{ cookiecutter.project_slug }}_flower
ports:
- "5555:5555"
command: /start-flower
@ -83,8 +83,8 @@ services:
node:
build:
context: .
dockerfile: ./compose/local/node/Dockerfile
image: {{ cookiecutter.project_slug }}_local_node
dockerfile: node:10-stretch-slim
image: {{ cookiecutter.project_slug }}_node
depends_on:
- django
volumes: