mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
Re-organize compose/ into environment-specific file groups (#1317)
* Re-organize compose/ into environment-specific file groups Closes #1316. * Commit missing files That was weird: git failed to commit one specific folder previously
This commit is contained in:
parent
7aa99c6ae3
commit
188ff966f8
|
@ -1,2 +0,0 @@
|
||||||
FROM abiosoft/caddy:0.10.6
|
|
||||||
COPY Caddyfile /etc/Caddyfile
|
|
|
@ -1,29 +0,0 @@
|
||||||
FROM python:3.5
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
|
||||||
|
|
||||||
RUN groupadd -r django \
|
|
||||||
&& useradd -r -g django django
|
|
||||||
|
|
||||||
# Requirements have to be pulled and installed here, otherwise caching won't work
|
|
||||||
COPY ./requirements /requirements
|
|
||||||
RUN pip install --no-cache-dir -r /requirements/production.txt \
|
|
||||||
&& rm -rf /requirements
|
|
||||||
|
|
||||||
COPY ./compose/django/gunicorn.sh ./compose/django/entrypoint.sh /
|
|
||||||
RUN sed -i 's/\r//' /entrypoint.sh \
|
|
||||||
&& sed -i 's/\r//' /gunicorn.sh \
|
|
||||||
&& chmod +x /entrypoint.sh \
|
|
||||||
&& chown django /entrypoint.sh \
|
|
||||||
&& chmod +x /gunicorn.sh \
|
|
||||||
&& chown django /gunicorn.sh
|
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
RUN chown -R django /app
|
|
||||||
|
|
||||||
USER django
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
@ -1,26 +0,0 @@
|
||||||
FROM python:3.5
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
|
||||||
|
|
||||||
# Requirements have to be pulled and installed here, otherwise caching won't work
|
|
||||||
COPY ./requirements /requirements
|
|
||||||
RUN pip install -r /requirements/local.txt
|
|
||||||
|
|
||||||
COPY ./compose/django/entrypoint.sh /entrypoint.sh
|
|
||||||
RUN sed -i 's/\r//' /entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
COPY ./compose/django/start-dev.sh /start-dev.sh
|
|
||||||
RUN sed -i 's/\r//' /start-dev.sh
|
|
||||||
RUN chmod +x /start-dev.sh
|
|
||||||
|
|
||||||
COPY ./compose/django/celery/worker/start-dev.sh /start-celeryworker-dev.sh
|
|
||||||
RUN sed -i 's/\r//' /start-celeryworker-dev.sh
|
|
||||||
RUN chmod +x /start-celeryworker-dev.sh
|
|
||||||
|
|
||||||
COPY ./compose/django/celery/beat/start-dev.sh /start-celerybeat-dev.sh
|
|
||||||
RUN sed -i 's/\r//' /start-celerybeat-dev.sh
|
|
||||||
RUN chmod +x /start-celerybeat-dev.sh
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
python manage.py migrate
|
|
||||||
python manage.py runserver_plus 0.0.0.0:8000
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
FROM python:3.5
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
# Requirements have to be pulled and installed here, otherwise caching won't work
|
||||||
|
COPY ./requirements /requirements
|
||||||
|
RUN pip install -r /requirements/local.txt
|
||||||
|
|
||||||
|
COPY ./compose/production/django/entrypoint.sh /entrypoint.sh
|
||||||
|
RUN sed -i 's/\r//' /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
COPY ./compose/local/django/start.sh /start.sh
|
||||||
|
RUN sed -i 's/\r//' /start.sh
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
COPY ./compose/local/django/celery/worker/start.sh /start-celeryworker.sh
|
||||||
|
RUN sed -i 's/\r//' /start-celeryworker.sh
|
||||||
|
RUN chmod +x /start-celeryworker.sh
|
||||||
|
|
||||||
|
COPY ./compose/local/django/celery/beat/start.sh /start-celerybeat.sh
|
||||||
|
RUN sed -i 's/\r//' /start-celerybeat.sh
|
||||||
|
RUN chmod +x /start-celerybeat.sh
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
@ -1,8 +1,10 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
|
|
||||||
rm -f './celerybeat.pid'
|
rm -f './celerybeat.pid'
|
||||||
celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO
|
celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO
|
|
@ -1,7 +1,9 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
|
|
||||||
celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO
|
celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO
|
10
{{cookiecutter.project_slug}}/compose/local/django/start.sh
Normal file
10
{{cookiecutter.project_slug}}/compose/local/django/start.sh
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
set -o xtrace
|
||||||
|
|
||||||
|
|
||||||
|
python manage.py migrate
|
||||||
|
python manage.py runserver_plus 0.0.0.0:8000
|
|
@ -1,11 +0,0 @@
|
||||||
FROM postgres:{{ cookiecutter.postgresql_version }}
|
|
||||||
|
|
||||||
# add backup scripts
|
|
||||||
ADD backup.sh /usr/local/bin/backup
|
|
||||||
ADD restore.sh /usr/local/bin/restore
|
|
||||||
ADD list-backups.sh /usr/local/bin/list-backups
|
|
||||||
|
|
||||||
# make them executable
|
|
||||||
RUN chmod +x /usr/local/bin/restore
|
|
||||||
RUN chmod +x /usr/local/bin/list-backups
|
|
||||||
RUN chmod +x /usr/local/bin/backup
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
FROM abiosoft/caddy:0.10.6
|
||||||
|
|
||||||
|
COPY ./compose/production/caddy/Caddyfile /etc/Caddyfile
|
|
@ -0,0 +1,39 @@
|
||||||
|
FROM python:3.5
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
RUN groupadd -r django \
|
||||||
|
&& useradd -r -g django django
|
||||||
|
|
||||||
|
# Requirements have to be pulled and installed here, otherwise caching won't work
|
||||||
|
COPY ./requirements /requirements
|
||||||
|
RUN pip install --no-cache-dir -r /requirements/production.txt \
|
||||||
|
&& rm -rf /requirements
|
||||||
|
|
||||||
|
COPY ./compose/production/django/gunicorn.sh /gunicorn.sh
|
||||||
|
RUN sed -i 's/\r//' /gunicorn.sh
|
||||||
|
RUN chmod +x /gunicorn.sh
|
||||||
|
RUN chown django /gunicorn.sh
|
||||||
|
|
||||||
|
COPY ./compose/production/django/entrypoint.sh /entrypoint.sh
|
||||||
|
RUN sed -i 's/\r//' /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
RUN chown django /entrypoint.sh
|
||||||
|
|
||||||
|
COPY ./compose/production/django/celery/worker/start.sh /start-celeryworker.sh
|
||||||
|
RUN sed -i 's/\r//' /start-celeryworker.sh
|
||||||
|
RUN chmod +x /start-celeryworker.sh
|
||||||
|
|
||||||
|
COPY ./compose/production/django/celery/beat/start.sh /start-celerybeat.sh
|
||||||
|
RUN sed -i 's/\r//' /start-celerybeat.sh
|
||||||
|
RUN chmod +x /start-celerybeat.sh
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN chown -R django /app
|
||||||
|
|
||||||
|
USER django
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
|
||||||
|
celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
|
||||||
|
celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO
|
|
@ -1,5 +1,12 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# todo: turn on after #1295
|
||||||
|
# set -o nounset
|
||||||
|
|
||||||
|
|
||||||
cmd="$@"
|
cmd="$@"
|
||||||
|
|
||||||
# This entrypoint is used to play nicely with the current cookiecutter configuration.
|
# This entrypoint is used to play nicely with the current cookiecutter configuration.
|
|
@ -1,3 +1,9 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
|
||||||
python /app/manage.py collectstatic --noinput
|
python /app/manage.py collectstatic --noinput
|
||||||
/usr/local/bin/gunicorn config.wsgi -w 4 -b 0.0.0.0:5000 --chdir=/app
|
/usr/local/bin/gunicorn config.wsgi -w 4 -b 0.0.0.0:5000 --chdir=/app
|
|
@ -0,0 +1,9 @@
|
||||||
|
FROM postgres:{{ cookiecutter.postgresql_version }}
|
||||||
|
|
||||||
|
ADD ./compose/production/postgres/backup.sh /usr/local/bin/backup
|
||||||
|
ADD ./compose/production/postgres/restore.sh /usr/local/bin/restore
|
||||||
|
ADD ./compose/production/postgres/list-backups.sh /usr/local/bin/list-backups
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/restore
|
||||||
|
RUN chmod +x /usr/local/bin/list-backups
|
||||||
|
RUN chmod +x /usr/local/bin/backup
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# stop on errors
|
|
||||||
set -e
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
|
||||||
# we might run into trouble when using the default `postgres` user, e.g. when dropping the postgres
|
# we might run into trouble when using the default `postgres` user, e.g. when dropping the postgres
|
||||||
# database in restore.sh. Check that something else is used here
|
# database in restore.sh. Check that something else is used here
|
|
@ -1,4 +1,10 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
|
||||||
echo "listing available backups"
|
echo "listing available backups"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
ls /backups/
|
ls /backups/
|
|
@ -1,7 +1,9 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
# stop on errors
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# we might run into trouble when using the default `postgres` user, e.g. when dropping the postgres
|
# we might run into trouble when using the default `postgres` user, e.g. when dropping the postgres
|
||||||
# database in restore.sh. Check that something else is used here
|
# database in restore.sh. Check that something else is used here
|
|
@ -1,14 +1,14 @@
|
||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data_dev: {}
|
postgres_data_local: {}
|
||||||
postgres_backup_dev: {}
|
postgres_backup_local: {}
|
||||||
|
|
||||||
services:
|
services:
|
||||||
django: &django
|
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./compose/django/Dockerfile-local
|
dockerfile: ./compose/local/django/Dockerfile
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
||||||
- mailhog{% endif %}
|
- mailhog{% endif %}
|
||||||
|
@ -19,13 +19,15 @@ services:
|
||||||
- USE_DOCKER=yes
|
- USE_DOCKER=yes
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
command: /start-dev.sh
|
command: /start.sh
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
build: ./compose/postgres
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./compose/production/postgres/Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data_dev:/var/lib/postgresql/data
|
- postgres_data_local:/var/lib/postgresql/data
|
||||||
- postgres_backup_dev:/backups
|
- postgres_backup_local:/backups
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER={{cookiecutter.project_slug}}
|
- POSTGRES_USER={{cookiecutter.project_slug}}
|
||||||
{% if cookiecutter.use_mailhog == 'y' %}
|
{% if cookiecutter.use_mailhog == 'y' %}
|
||||||
|
@ -46,7 +48,7 @@ services:
|
||||||
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
||||||
- mailhog{% endif %}
|
- mailhog{% endif %}
|
||||||
ports: []
|
ports: []
|
||||||
command: /start-celeryworker-dev.sh
|
command: /start-celeryworker.sh
|
||||||
|
|
||||||
celerybeat:
|
celerybeat:
|
||||||
# https://github.com/docker/compose/issues/3220
|
# https://github.com/docker/compose/issues/3220
|
||||||
|
@ -56,5 +58,5 @@ services:
|
||||||
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
||||||
- mailhog{% endif %}
|
- mailhog{% endif %}
|
||||||
ports: []
|
ports: []
|
||||||
command: /start-celerybeat-dev.sh
|
command: /start-celerybeat.sh
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -6,54 +6,52 @@ volumes:
|
||||||
caddy: {}
|
caddy: {}
|
||||||
|
|
||||||
services:
|
services:
|
||||||
django:
|
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./compose/django/Dockerfile
|
dockerfile: ./compose/production/django/Dockerfile
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- redis
|
- redis
|
||||||
command: /gunicorn.sh
|
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
command: /gunicorn.sh
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
build: ./compose/postgres
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./compose/production/postgres/Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
- postgres_backup:/backups
|
- postgres_backup:/backups
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
|
||||||
caddy:
|
caddy:
|
||||||
build: ./compose/caddy
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./compose/production/caddy/Dockerfile
|
||||||
depends_on:
|
depends_on:
|
||||||
- django
|
- django
|
||||||
ports:
|
|
||||||
- "0.0.0.0:80:80"
|
|
||||||
- "0.0.0.0:443:443"
|
|
||||||
volumes:
|
volumes:
|
||||||
- caddy:/root/.caddy
|
- caddy:/root/.caddy
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
ports:
|
||||||
|
- "0.0.0.0:80:80"
|
||||||
|
- "0.0.0.0:443:443"
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:3.0
|
image: redis:3.0
|
||||||
{% if cookiecutter.use_celery == 'y' %}
|
{% if cookiecutter.use_celery == 'y' %}
|
||||||
celeryworker:
|
celeryworker:
|
||||||
build:
|
<<: *django
|
||||||
context: .
|
|
||||||
dockerfile: ./compose/django/Dockerfile
|
|
||||||
env_file: .env
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- redis
|
- redis
|
||||||
command: celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO
|
command: /start-celeryworker.sh
|
||||||
|
|
||||||
celerybeat:
|
celerybeat:
|
||||||
build:
|
<<: *django
|
||||||
context: .
|
|
||||||
dockerfile: ./compose/django/Dockerfile
|
|
||||||
env_file: .env
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- redis
|
- redis
|
||||||
command: celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO
|
command: /start-celerybeat.sh
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
{% if cookiecutter.windows == 'y' -%}
|
{% if cookiecutter.windows == 'y' -%}
|
||||||
# Python-PostgreSQL Database Adapter
|
# Python-PostgreSQL Database Adapter
|
||||||
# If using Win for dev, this assumes Unix in prod
|
# Assuming Windows is used locally, and *nix -- in production.
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
psycopg2==2.7.3.1
|
psycopg2==2.7.3.1
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user