From 385e6bd9b849c725bd8be3d8b2b8ad289c25cc5d Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Tue, 15 Jul 2025 16:30:02 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5?= =?UTF-8?q?=D0=B9=D0=BD=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Dockerfile | 30 +++++++++++-- docker-compose-full.yml | 85 +++++++++++++++++++++++++++++++++++ docker-compose-without-db.yml | 40 +++++++++++++++++ 3 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 docker-compose-full.yml create mode 100644 docker-compose-without-db.yml diff --git a/app/Dockerfile b/app/Dockerfile index c01f3e7..a4f120c 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,4 +1,28 @@ -FROM ubuntu:latest -LABEL authors="z.lyrshikov" +# pull official base image +FROM python:3.10 -ENTRYPOINT ["top", "-b"] \ No newline at end of file +# 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 diff --git a/docker-compose-full.yml b/docker-compose-full.yml new file mode 100644 index 0000000..9a59885 --- /dev/null +++ b/docker-compose-full.yml @@ -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: \ No newline at end of file diff --git a/docker-compose-without-db.yml b/docker-compose-without-db.yml new file mode 100644 index 0000000..b916dd3 --- /dev/null +++ b/docker-compose-without-db.yml @@ -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: \ No newline at end of file