Make running with Docker more convenient
This commit is contained in:
parent
1de84e17c9
commit
5cba45e0a7
@ -2,11 +2,11 @@
|
||||
FROM python:3
|
||||
|
||||
RUN useradd -d /code xf
|
||||
RUN mkdir /code
|
||||
RUN chown xf:xf /code
|
||||
RUN mkdir -p /code
|
||||
RUN chown -R xf:xf /code
|
||||
|
||||
RUN mkdir /conf
|
||||
RUN chown xf:xf /conf
|
||||
RUN mkdir -p /conf/static
|
||||
RUN chown -R xf:xf /conf
|
||||
|
||||
RUN mkdir /venv
|
||||
RUN chown xf:xf /venv
|
||||
@ -15,9 +15,9 @@ USER xf
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
WORKDIR /code
|
||||
COPY requirements.prod.txt /code/
|
||||
COPY requirements.txt /code/
|
||||
RUN python -m venv /venv
|
||||
RUN . /venv/bin/activate && pip install -r requirements.prod.txt
|
||||
RUN . /venv/bin/activate && pip install -r requirements.txt
|
||||
# CMD . /venv/bin/activate && uwsgi --ini /conf/uwsgi.ini
|
||||
CMD . /venv/bin/activate && uvicorn --reload --reload-include *.html --workers 2 --uds /var/run/socks/app.sock app.asgi:application
|
||||
# CMD . /venv/bin/activate && gunicorn -b 0.0.0.0:8000 --reload app.asgi:application -k uvicorn.workers.UvicornWorker
|
16
Makefile
16
Makefile
@ -1,23 +1,23 @@
|
||||
run:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env up -d
|
||||
docker-compose --env-file=stack.env up -d
|
||||
|
||||
build:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env build
|
||||
docker-compose --env-file=stack.env build
|
||||
|
||||
stop:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env down
|
||||
docker-compose --env-file=stack.env down
|
||||
|
||||
log:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env logs -f
|
||||
docker-compose --env-file=stack.env logs -f
|
||||
|
||||
migrate:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py migrate"
|
||||
docker-compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py migrate"
|
||||
|
||||
makemigrations:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py makemigrations"
|
||||
docker-compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py makemigrations"
|
||||
|
||||
auth:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py createsuperuser"
|
||||
docker-compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py createsuperuser"
|
||||
|
||||
token:
|
||||
docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py addstatictoken m"
|
||||
docker-compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py addstatictoken m"
|
||||
|
@ -87,7 +87,7 @@ WSGI_APPLICATION = "app.wsgi.application"
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": BASE_DIR / "db.sqlite3",
|
||||
"NAME": "/conf/db.sqlite3",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,16 @@ version: "2.2"
|
||||
services:
|
||||
app:
|
||||
image: xf/envelope:prod
|
||||
build: ${PORTAINER_GIT_DIR}/docker/prod
|
||||
container_name: envelope
|
||||
build: .
|
||||
volumes:
|
||||
- ${PORTAINER_GIT_DIR}:/code
|
||||
# - ${PORTAINER_GIT_DIR}/docker/prod/uwsgi.ini:/conf/uwsgi.ini
|
||||
- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py
|
||||
- ${APP_DATABASE_FILE}:/code/db.sqlite3
|
||||
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
|
||||
- app_static:${STATIC_ROOT}
|
||||
#ports:
|
||||
# - "8000:8000" # uwsgi socket
|
||||
env_file:
|
||||
- ../stack.env
|
||||
- stack.env
|
||||
volumes_from:
|
||||
- tmp
|
||||
depends_on:
|
||||
@ -25,28 +25,31 @@ services:
|
||||
|
||||
migration:
|
||||
image: xf/envelope:prod
|
||||
build: ./docker/prod
|
||||
container_name: migration_envelope
|
||||
build: .
|
||||
command: sh -c '. /venv/bin/activate && python manage.py migrate --noinput'
|
||||
volumes:
|
||||
- ${PORTAINER_GIT_DIR}:/code
|
||||
- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py
|
||||
- ${APP_DATABASE_FILE}:/code/db.sqlite3
|
||||
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
|
||||
- app_static:${STATIC_ROOT}
|
||||
env_file:
|
||||
- ../stack.env
|
||||
- stack.env
|
||||
|
||||
collectstatic:
|
||||
image: xf/envelope:prod
|
||||
build: ./docker/prod
|
||||
container_name: collectstatic_envelope
|
||||
build: .
|
||||
command: sh -c '. /venv/bin/activate && python manage.py collectstatic --noinput'
|
||||
volumes:
|
||||
- ${PORTAINER_GIT_DIR}:/code
|
||||
- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py
|
||||
- ${APP_DATABASE_FILE}:/code/db.sqlite3
|
||||
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
|
||||
- app_static:${STATIC_ROOT}
|
||||
env_file:
|
||||
- ../stack.env
|
||||
- stack.env
|
||||
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
container_name: nginx_envelope
|
||||
ports:
|
||||
- ${APP_PORT}:9999
|
||||
ulimits:
|
||||
@ -57,6 +60,7 @@ services:
|
||||
volumes:
|
||||
- ${PORTAINER_GIT_DIR}:/code
|
||||
- ${PORTAINER_GIT_DIR}/docker/nginx/conf.d:/etc/nginx/conf.d
|
||||
- app_static:${STATIC_ROOT}
|
||||
volumes_from:
|
||||
- tmp
|
||||
depends_on:
|
||||
@ -72,6 +76,7 @@ services:
|
||||
|
||||
tmp:
|
||||
image: busybox
|
||||
container_name: tmp_envelope
|
||||
command: chmod -R 777 /var/run/socks
|
||||
volumes:
|
||||
- /var/run/socks
|
||||
@ -100,5 +105,5 @@ networks:
|
||||
external:
|
||||
name: xf
|
||||
|
||||
# volumes:
|
||||
# redis_data: {}
|
||||
volumes:
|
||||
app_static: {}
|
Loading…
Reference in New Issue
Block a user