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