Skip to content

Commit

Permalink
Feature/infrastructure docker (#56)
Browse files Browse the repository at this point in the history
* Структура папки infra

* dev compose work postgresql work

* prod

* Added prod and stage without specifying the image path. Workflow integration needed

---------

Co-authored-by: Евгений Каликов <eskalikov@yandex.com>
  • Loading branch information
esk-git and Евгений Каликов authored Dec 14, 2023
1 parent ab9c391 commit d89f8e5
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 0 deletions.
17 changes: 17 additions & 0 deletions infra/dev/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.8'
name: ahf_dev

services:
db:
container_name: db
image: postgres:13.0-alpine
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ../../.env
ports:
- 5432:5432

volumes:
postgres_data:
18 changes: 18 additions & 0 deletions infra/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11-slim-bullseye AS builder

WORKDIR /app
COPY poetry.lock pyproject.toml ./

RUN python -m pip install --no-cache-dir poetry==1.6.1 \
&& poetry config virtualenvs.in-project true \
&& poetry install --without dev --with test

FROM python:3.11-slim-bullseye

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY --from=builder /app /app
COPY adaptive_hockey_federation/ ./
ENTRYPOINT ["/entrypoint.sh"]

CMD ["/app/.venv/bin/gunicorn", "adaptive_hockey_federation.wsgi:application", "--bind", "0:8000" ]
39 changes: 39 additions & 0 deletions infra/prod/docker-compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.8'
name: ahf_prod

services:
db:
container_name: db
image: postgres:13.0-alpine
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env

site:
image: imageName
restart: always
volumes:
- static_value:/app/static/
- media_value:/app/media/
env_file:
- ./.env
depends_on:
- db

nginx:
image: nginx:1.21.3-alpine
ports:
- "80:80"
volumes:
- ../../nginx/default.conf:/etc/nginx/conf.d/default.conf
- static_value:/var/html/static/
- media_value:/var/html/media/
depends_on:
- site

volumes:
static_value:
media_value:
postgres_data:
18 changes: 18 additions & 0 deletions infra/stage/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11-slim-bullseye AS builder

WORKDIR /app
COPY poetry.lock pyproject.toml ./

RUN python -m pip install --no-cache-dir poetry==1.6.1 \
&& poetry config virtualenvs.in-project true \
&& poetry install --without dev --with test

FROM python:3.11-slim-bullseye

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY --from=builder /app /app
COPY adaptive_hockey_federation/ ./
ENTRYPOINT ["/entrypoint.sh"]

CMD ["/app/.venv/bin/gunicorn", "adaptive_hockey_federation.wsgi:application", "--bind", "0:8000" ]
39 changes: 39 additions & 0 deletions infra/stage/docker-compose.stage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.8'
name: ahf_stage

services:
db:
container_name: db
image: postgres:13.0-alpine
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env

site:
image: imageName
restart: always
volumes:
- static_value:/app/static/
- media_value:/app/media/
env_file:
- ./.env
depends_on:
- db

nginx:
image: nginx:1.21.3-alpine
ports:
- "80:80"
volumes:
- ../../nginx/default.conf:/etc/nginx/conf.d/default.conf
- static_value:/var/html/static/
- media_value:/var/html/media/
depends_on:
- site

volumes:
static_value:
media_value:
postgres_data:

0 comments on commit d89f8e5

Please sign in to comment.