From dc60f2ca4863b027c51ae6b7ea85c067556e0ed3 Mon Sep 17 00:00:00 2001 From: Ilya Selenzev Date: Fri, 15 Dec 2023 16:55:43 +0300 Subject: [PATCH 1/4] create new compoce-file and transfer root docker file --- Dockerfile => infra/dev/Dockerfile | 11 ++++++----- infra/dev/docker-compose.dev.yaml | 25 ++++++++++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) rename Dockerfile => infra/dev/Dockerfile (57%) diff --git a/Dockerfile b/infra/dev/Dockerfile similarity index 57% rename from Dockerfile rename to infra/dev/Dockerfile index 2a19d28a..bd769d96 100644 --- a/Dockerfile +++ b/infra/dev/Dockerfile @@ -1,14 +1,15 @@ -FROM python:3.11-slim-bullseye AS builder +FROM python:3.11-slim AS builder RUN mkdir /app 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 +RUN python -m pip install --upgrade pip +RUN python -m pip install --no-cache-dir poetry==1.6.1 +RUN poetry config virtualenvs.in-project true +RUN poetry install --without dev --with test -FROM python:3.11-slim-bullseye +FROM python:3.11-slim COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh diff --git a/infra/dev/docker-compose.dev.yaml b/infra/dev/docker-compose.dev.yaml index 483fd6ee..68e4cebe 100644 --- a/infra/dev/docker-compose.dev.yaml +++ b/infra/dev/docker-compose.dev.yaml @@ -3,15 +3,30 @@ name: ahf_dev services: db: - container_name: db image: postgres:13.0-alpine + env_file: + - ./.env + web: + build: ./ restart: always volumes: - - postgres_data:/var/lib/postgresql/data/ + - static_value:/app/static/ + - media_value:/app/media/ + depends_on: + - db env_file: - - ../../.env + - ./.env + nginx: + image: nginx:1.21.3-alpine ports: - - 5432:5432 + - "80:80" + volumes: + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + - static_value:/var/html/static/ + - media_value:/var/html/media/ + depends_on: + - web volumes: - postgres_data: + static_value: + media_value: From f17ba7a744c4f615a1de9d969fde8aec814cf97b Mon Sep 17 00:00:00 2001 From: Ilya Selenzev Date: Fri, 15 Dec 2023 17:13:59 +0300 Subject: [PATCH 2/4] change docker poetry version --- infra/dev/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/dev/Dockerfile b/infra/dev/Dockerfile index bd769d96..14efa7ce 100644 --- a/infra/dev/Dockerfile +++ b/infra/dev/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app COPY poetry.lock pyproject.toml ./ RUN python -m pip install --upgrade pip -RUN python -m pip install --no-cache-dir poetry==1.6.1 +RUN python -m pip install --no-cache-dir poetry==1.7.1 RUN poetry config virtualenvs.in-project true RUN poetry install --without dev --with test From 451e3d3979458ad46df5146e3f68524780f44405 Mon Sep 17 00:00:00 2001 From: Ilya Selenzev Date: Sat, 16 Dec 2023 13:15:28 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B2=20docker=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0?= =?UTF-8?q?=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 1 + infra/dev/Dockerfile | 17 +++++++++-------- infra/dev/docker-compose.dev.yaml | 10 ++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index e69de29b..a65dbc77 100644 --- a/.env.example +++ b/.env.example @@ -0,0 +1 @@ +POSTGRES_PASSWORD='1qw2#ER$' \ No newline at end of file diff --git a/infra/dev/Dockerfile b/infra/dev/Dockerfile index 14efa7ce..441933cf 100644 --- a/infra/dev/Dockerfile +++ b/infra/dev/Dockerfile @@ -1,19 +1,20 @@ -FROM python:3.11-slim AS builder +# Filename: Dockerfile +# Full path: infra/dev/Dockerfile +# Description: Dockerfile for local development environment + +FROM python:3.11-slim -RUN mkdir /app WORKDIR /app -COPY poetry.lock pyproject.toml ./ +COPY ./poetry.lock ./ +COPY ./pyproject.toml ./ RUN python -m pip install --upgrade pip RUN python -m pip install --no-cache-dir poetry==1.7.1 RUN poetry config virtualenvs.in-project true -RUN poetry install --without dev --with test - -FROM python:3.11-slim +RUN poetry install --with dev -COPY entrypoint.sh /entrypoint.sh +COPY ./entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh -COPY --from=builder /app /app COPY adaptive_hockey_federation/ ./ ENTRYPOINT ["/entrypoint.sh"] diff --git a/infra/dev/docker-compose.dev.yaml b/infra/dev/docker-compose.dev.yaml index 68e4cebe..60d414e2 100644 --- a/infra/dev/docker-compose.dev.yaml +++ b/infra/dev/docker-compose.dev.yaml @@ -1,3 +1,7 @@ +# filename: docker-compose.dev.yml +# full path: /home/ahf/ahf_dev/docker-compose.dev.yml +# Description: docker-compose file for local development environment + version: '3.8' name: ahf_dev @@ -7,7 +11,9 @@ services: env_file: - ./.env web: - build: ./ + build: + context: ../../ + dockerfile: ./infra/dev/Dockerfile restart: always volumes: - static_value:/app/static/ @@ -21,7 +27,7 @@ services: ports: - "80:80" volumes: - - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + - ../../nginx/default.conf:/etc/nginx/conf.d/default.conf - static_value:/var/html/static/ - media_value:/var/html/media/ depends_on: From 5468711409cfb78f3cfb687a1cd620b7d5fcb9b3 Mon Sep 17 00:00:00 2001 From: Ilya Selenzev Date: Mon, 18 Dec 2023 15:33:26 +0300 Subject: [PATCH 4/4] create simple docker-compose.dev.yaml for next step of development --- infra/dev/docker-compose.dev.yaml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/infra/dev/docker-compose.dev.yaml b/infra/dev/docker-compose.dev.yaml index 60d414e2..41a30f9d 100644 --- a/infra/dev/docker-compose.dev.yaml +++ b/infra/dev/docker-compose.dev.yaml @@ -10,29 +10,10 @@ services: image: postgres:13.0-alpine env_file: - ./.env - web: - build: - context: ../../ - dockerfile: ./infra/dev/Dockerfile - restart: always volumes: - - static_value:/app/static/ - - media_value:/app/media/ - depends_on: - - db - env_file: - - ./.env - nginx: - image: nginx:1.21.3-alpine + - db_data:/var/lib/postgresql/data/ 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: - - web + - "5432:5432" volumes: - static_value: - media_value: + db_data: