Добавил докер

This commit is contained in:
urec56 2024-06-02 19:40:32 +05:00
parent 6301e94a81
commit 1887afe06d
4 changed files with 91 additions and 0 deletions

6
.dockerignore Normal file
View file

@ -0,0 +1,6 @@
.venv
venv
.idea
.gitignore
.git
__pycache__

30
docker/Dockerfile_back Normal file
View file

@ -0,0 +1,30 @@
FROM quay.io/urec56/python312
RUN addgroup --system app && adduser --system --group app
ENV APP_HOME=/home/app
WORKDIR $APP_HOME
RUN apt-get update \
&& apt-get -y install curl gcc libpq-dev \
&& apt-get clean
RUN pip install --upgrade pip setuptools
COPY requirements.txt .
RUN pip config set global.trusted-host "pypi.python.org pypi.org files.pythonhosted.org" && \
pip install \
--proxy= \
-r requirements.txt
COPY . .
RUN chown -R app:app $APP_HOME
USER app
CMD ["gunicorn", "app.main:app", "--workers", "1", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind=0.0.0.0:8000"]

30
docker/Dockerfile_celery Normal file
View file

@ -0,0 +1,30 @@
FROM quay.io/urec56/python312
RUN addgroup --system app && adduser --system --group app
ENV APP_HOME=/home/app
WORKDIR $APP_HOME
RUN apt-get update \
&& apt-get -y install curl gcc libpq-dev \
&& apt-get clean
RUN pip install --upgrade pip setuptools
COPY requirements.txt .
RUN pip config set global.trusted-host "pypi.python.org pypi.org files.pythonhosted.org" && \
pip install \
--proxy= \
-r requirements.txt
COPY . .
RUN chown -R app:app $APP_HOME
USER app
CMD ["celery", "-A", "app.tasks.celery:celery", "worker", "--loglevel=INFO"]

25
docker/docker-compose.yml Normal file
View file

@ -0,0 +1,25 @@
version: '3.8'
services:
chat_back:
image: chat_back
container_name: chat_back
ports:
- "9000:8000"
build:
context: ..
dockerfile: docker/Dockerfile_back
env_file:
- ../.env
restart: always
depends_on:
- celery
celery:
image: celery
container_name: celery
build:
context: ..
dockerfile: docker/Dockerfile_celery
env_file:
- ../.env
restart: always