Конфигурация контейнеров

This commit is contained in:
zakhy 2025-07-15 16:30:02 +07:00
parent 92a14583e6
commit 385e6bd9b8
3 changed files with 152 additions and 3 deletions

View File

@ -1,4 +1,28 @@
FROM ubuntu:latest
LABEL authors="z.lyrshikov"
# pull official base image
FROM python:3.10
ENTRYPOINT ["top", "-b"]
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc
# create the appropriate directories
ENV APP_HOME=/home/app
WORKDIR $APP_HOME
# install python dependencies
COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels -r requirements.txt
RUN pip install --no-cache /wheels/* && rm -rf /wheels
# copy project
COPY . $APP_HOME
# create the app user
RUN addgroup --system app && adduser --system --group app && \
chown -R app:app $APP_HOME
USER app

85
docker-compose-full.yml Normal file
View File

@ -0,0 +1,85 @@
version: "3.9"
services:
web:
build: ./app
image: mfssogr:latest
command: >
sh -c "
python manage.py migrate --noinput &&
gunicorn -c mfssogr/gunicorn.conf.py
"
ports:
- '127.0.0.1:8000:8000'
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./app/static:/home/app/web/static/
- ./app/log:/home/app/web/log/
restart: always
celery:
image: mfssogr:latest
command: celery -A mfssogr worker --loglevel=INFO
env_file:
- .env
volumes:
- ./app/logs:/home/app/web/logs
- ./app/media:/home/app/web/media
depends_on:
redis:
condition: service_started
web:
condition: service_started
restart: always
celery-beat:
image: mfssogr:latest
command: celery -A mfssogr beat -l info
env_file:
- .env
depends_on:
redis:
condition: service_started
web:
condition: service_started
restart: always
ogr_postgres:
image: postgis/postgis:13-3.5
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- .env
ports:
- '5432:5432'
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ]
interval: 10s
timeout: 60s
retries: 3
start_period: 10s
restart: always
ogr_redis:
image: redis
volumes:
- redis_data:/data
ports:
- "6379:6379"
healthcheck:
test: [ "CMD-SHELL", "redis-cli ping | grep PONG" ]
interval: 1s
timeout: 3s
retries: 5
restart: always
volumes:
postgres_data:
redis_data:

View File

@ -0,0 +1,40 @@
version: "3.9"
services:
web:
build: ./app
image: mfssogr:latest
command: >
sh -c "
python manage.py migrate --noinput &&
gunicorn -c mfssogr/gunicorn.conf.py
"
ports:
- '127.0.0.1:8000:8000'
env_file:
- .env
volumes:
- ./app/static:/home/app/web/static/
- ./app/log:/home/app/web/log/
restart: always
celery:
image: mfssogr:latest
command: celery -A mfssogr worker --loglevel=INFO
env_file:
- .env
volumes:
- ./app/logs:/home/app/web/logs
- ./app/media:/home/app/web/media
restart: always
celery-beat:
image: mfssogr:latest
command: celery -A mfssogr beat -l info
env_file:
- .env
restart: always
volumes:
postgres_data:
redis_data: