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 os
import random import random
import shutil import shutil
@ -56,7 +45,7 @@ def remove_pycharm_files():
def remove_docker_files(): def remove_docker_files():
shutil.rmtree("compose") shutil.rmtree("compose")
file_names = ["local.yml", "production.yml", ".dockerignore"] file_names = ["dev.yml", ".dockerignore"]
for file_name in file_names: for file_name in file_names:
os.remove(file_name) 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): def set_flags_in_envs(postgres_user, celery_flower_user, debug=False):
local_django_envs_path = os.path.join(".envs", ".local", ".django") local_django_envs_path = os.path.join(".envs", "dev", "django")
production_django_envs_path = os.path.join(".envs", ".production", ".django") production_django_envs_path = os.path.join(".envs", "prod", "django")
local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres") local_postgres_envs_path = os.path.join(".envs", "dev", "postgres")
production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres") production_postgres_envs_path = os.path.join(".envs", "prod", "postgres")
set_django_secret_key(production_django_envs_path) set_django_secret_key(production_django_envs_path)
set_django_admin_url(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" TERMINATOR = "\x1b[0m"
WARNING = "\x1b[1;33m [WARNING]: " WARNING = "\x1b[1;33m [WARNING]: "
INFO = "\x1b[1;33m [INFO]: " 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 import pytest
ROOT_DIR_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 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 = [ PRODUCTION_DOTENV_FILE_PATHS = [
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".django"), os.path.join(PRODUCTION_DOTENVS_DIR_PATH, "django"),
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".postgres"), os.path.join(PRODUCTION_DOTENVS_DIR_PATH, "postgres"),
] ]
DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, ".env") 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 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 %} django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
build: build:
context: . context: .
dockerfile: ./compose/local/django/Dockerfile dockerfile: ./compose/dev/django/Dockerfile
image: {{ cookiecutter.project_slug }}_local_django image: {{ cookiecutter.project_slug }}_local_django
depends_on: depends_on:
- postgres - postgres
@ -18,8 +18,8 @@ services:
volumes: volumes:
- .:/app - .:/app
env_file: env_file:
- ./.envs/.local/.django - ./.envs/dev/django
- ./.envs/.local/.postgres - ./.envs/dev/postgres
ports: ports:
- "8000:8000" - "8000:8000"
command: /start command: /start
@ -27,13 +27,13 @@ services:
postgres: postgres:
build: build:
context: . context: .
dockerfile: ./compose/production/postgres/Dockerfile dockerfile: postgres:11-alpine
image: {{ cookiecutter.project_slug }}_production_postgres image: {{ cookiecutter.project_slug }}_postgres
volumes: volumes:
- local_postgres_data:/var/lib/postgresql/data - local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/backups - local_postgres_data_backups:/backups
env_file: env_file:
- ./.envs/.local/.postgres - .envs/dev/postgres
{%- if cookiecutter.use_mailhog == 'y' %} {%- if cookiecutter.use_mailhog == 'y' %}
mailhog: mailhog:
@ -49,7 +49,7 @@ services:
celeryworker: celeryworker:
<<: *django <<: *django
image: {{ cookiecutter.project_slug }}_local_celeryworker image: {{ cookiecutter.project_slug }}_celeryworker
depends_on: depends_on:
- redis - redis
- postgres - postgres
@ -61,7 +61,7 @@ services:
celerybeat: celerybeat:
<<: *django <<: *django
image: {{ cookiecutter.project_slug }}_local_celerybeat image: {{ cookiecutter.project_slug }}_celerybeat
depends_on: depends_on:
- redis - redis
- postgres - postgres
@ -73,7 +73,7 @@ services:
flower: flower:
<<: *django <<: *django
image: {{ cookiecutter.project_slug }}_local_flower image: {{ cookiecutter.project_slug }}_flower
ports: ports:
- "5555:5555" - "5555:5555"
command: /start-flower command: /start-flower
@ -83,8 +83,8 @@ services:
node: node:
build: build:
context: . context: .
dockerfile: ./compose/local/node/Dockerfile dockerfile: node:10-stretch-slim
image: {{ cookiecutter.project_slug }}_local_node image: {{ cookiecutter.project_slug }}_node
depends_on: depends_on:
- django - django
volumes: volumes: