commit
9b2045c235
@ -1,5 +1,8 @@ |
||||
# Environment variable overrides for local development |
||||
FLASK_APP=autoapp.py |
||||
FLASK_DEBUG=1 |
||||
FLASK_ENV=development |
||||
DATABASE_URL="sqlite:////tmp/dev.db" |
||||
SECRET_KEY="not-so-secret" |
||||
DATABASE_URL=sqlite:////tmp/dev.db |
||||
GUNICORN_WORKERS=1 |
||||
LOG_LEVEL=debug |
||||
SECRET_KEY=not-so-secret |
||||
|
@ -0,0 +1,57 @@ |
||||
# ==================================== BASE ==================================== |
||||
ARG INSTALL_PYTHON_VERSION=${INSTALL_PYTHON_VERSION:-3.7} |
||||
FROM python:${INSTALL_PYTHON_VERSION}-slim-stretch AS base |
||||
|
||||
RUN apt-get update |
||||
RUN apt-get install -y \ |
||||
curl |
||||
|
||||
ARG INSTALL_NODE_VERSION=${INSTALL_NODE_VERSION:-12} |
||||
RUN curl -sL https://deb.nodesource.com/setup_${INSTALL_NODE_VERSION}.x | bash - |
||||
RUN apt-get install -y \ |
||||
nodejs \ |
||||
&& apt-get -y autoclean |
||||
|
||||
WORKDIR /app |
||||
{%- if cookiecutter.use_pipenv == "yes" %} |
||||
COPY ["Pipfile", "shell_scripts/auto_pipenv.sh", "./"] |
||||
RUN pip install pipenv |
||||
{%- else %} |
||||
COPY requirements requirements |
||||
{%- endif %} |
||||
|
||||
COPY [ "assets", "package.json", "webpack.config.js", "./" ] |
||||
RUN npm install |
||||
|
||||
# ================================= DEVELOPMENT ================================ |
||||
FROM base AS development |
||||
{%- if cookiecutter.use_pipenv == "yes" %} |
||||
RUN pipenv install --dev |
||||
{%- else %} |
||||
RUN pip install -r requirements/dev.txt |
||||
{%- endif %} |
||||
EXPOSE 2992 |
||||
EXPOSE 5000 |
||||
CMD [ {% if cookiecutter.use_pipenv == 'yes' %}"pipenv", "run", {% endif %}"npm", "start" ] |
||||
|
||||
# ================================= PRODUCTION ================================= |
||||
FROM base AS production |
||||
{%- if cookiecutter.use_pipenv == "yes" %} |
||||
RUN pipenv install |
||||
{%- else %} |
||||
RUN pip install -r requirements/prod.txt |
||||
{%- endif %} |
||||
COPY supervisord.conf /etc/supervisor/supervisord.conf |
||||
COPY supervisord_programs /etc/supervisor/conf.d |
||||
EXPOSE 5000 |
||||
ENTRYPOINT ["/bin/bash", "shell_scripts/supervisord_entrypoint.sh"] |
||||
CMD ["-c", "/etc/supervisor/supervisord.conf"] |
||||
|
||||
# =================================== MANAGE =================================== |
||||
FROM base AS manage |
||||
{%- if cookiecutter.use_pipenv == "yes" %} |
||||
COPY --from=development /root/.local/share/virtualenvs/ /root/.local/share/virtualenvs/ |
||||
{%- else %} |
||||
RUN pip install -r requirements/dev.txt |
||||
{%- endif %} |
||||
ENTRYPOINT [ {% if cookiecutter.use_pipenv == 'yes' %}"pipenv", "run", {% endif %}"flask" ] |
@ -0,0 +1,54 @@ |
||||
version: '3.6' |
||||
|
||||
x-build-args: &build_args |
||||
INSTALL_PYTHON_VERSION: {{cookiecutter.python_version}} |
||||
INSTALL_NODE_VERSION: {{cookiecutter.node_version}} |
||||
|
||||
x-default-volumes: &default_volumes |
||||
volumes: |
||||
- ./:/app |
||||
- node-modules:/app/node_modules |
||||
- ./dev.db:/tmp/dev.db |
||||
|
||||
services: |
||||
flask-dev: |
||||
build: |
||||
context: . |
||||
target: development |
||||
args: |
||||
<<: *build_args |
||||
image: "{{cookiecutter.app_name}}-development" |
||||
ports: |
||||
- "5000:5000" |
||||
- "2992:2992" |
||||
<<: *default_volumes |
||||
|
||||
flask-prod: |
||||
build: |
||||
context: . |
||||
target: production |
||||
args: |
||||
<<: *build_args |
||||
image: "{{cookiecutter.app_name}}-production" |
||||
ports: |
||||
- "5000:5000" |
||||
environment: |
||||
FLASK_ENV: production |
||||
FLASK_DEBUG: 0 |
||||
LOG_LEVEL: info |
||||
GUNICORN_WORKERS: 4 |
||||
<<: *default_volumes |
||||
|
||||
manage: |
||||
build: |
||||
context: . |
||||
target: manage |
||||
image: "{{cookiecutter.app_name}}-manage" |
||||
stdin_open: true |
||||
tty: true |
||||
<<: *default_volumes |
||||
|
||||
volumes: |
||||
node-modules: |
||||
static-build: |
||||
dev-db: |
@ -0,0 +1,7 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
function auto_pipenv_shell { |
||||
if [ -f "Pipfile" ] ; then |
||||
source "$(pipenv --venv)/bin/activate" |
||||
fi |
||||
} |
@ -0,0 +1,15 @@ |
||||
#!/usr/bin/env sh |
||||
set -e |
||||
|
||||
npm run build |
||||
|
||||
{%- if cookiecutter.use_pipenv == "yes" %} |
||||
source ./shell_scripts/auto_pipenv.sh |
||||
auto_pipenv_shell |
||||
{%- endif %} |
||||
|
||||
if [ $# -eq 0 ] || [ "${1#-}" != "$1" ]; then |
||||
set -- supervisord "$@" |
||||
fi |
||||
|
||||
exec "$@" |
@ -0,0 +1,21 @@ |
||||
[unix_http_server] |
||||
file=/tmp/supervisor.sock ; path to your socket file |
||||
|
||||
[supervisord] |
||||
logfile=/tmp/supervisord.log ; supervisord log file |
||||
logfile_maxbytes=50MB ; maximum size of logfile before rotation |
||||
logfile_backups=10 ; number of backed up logfiles |
||||
loglevel=%(ENV_LOG_LEVEL)s ; info, debug, warn, trace |
||||
pidfile=/tmp/supervisord.pid ; pidfile location |
||||
nodaemon=true ; run supervisord as a daemon |
||||
minfds=1024 ; number of startup file descriptors |
||||
minprocs=200 ; number of process descriptors |
||||
|
||||
[rpcinterface:supervisor] |
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface |
||||
|
||||
[supervisorctl] |
||||
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket |
||||
|
||||
[include] |
||||
files = /etc/supervisor/conf.d/*.conf |
@ -0,0 +1,18 @@ |
||||
[program:gunicorn] |
||||
directory=/app |
||||
command=gunicorn |
||||
{{cookiecutter.app_name}}.app:create_app() |
||||
-b :5000 |
||||
-w %(ENV_GUNICORN_WORKERS)s |
||||
-k gevent |
||||
--max-requests=5000 |
||||
--max-requests-jitter=500 |
||||
--log-level=%(ENV_LOG_LEVEL)s |
||||
stdout_logfile=/dev/stdout |
||||
stdout_logfile_maxbytes=0 |
||||
autostart=true |
||||
autorestart=true |
||||
stdout_logfile=/dev/stdout |
||||
stdout_logfile_maxbytes=0 |
||||
stderr_logfile=/dev/stderr |
||||
stderr_logfile_maxbytes=0 |
Loading…
Reference in new issue