From ce62d46a0972ac16e147ace1beb5ac51e9b02b8f Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Thu, 9 May 2024 14:51:58 +0900 Subject: [PATCH 01/11] chore(docker): dockernize api --- Dockerfile | 29 +++++++++++++++++++++++++++++ compose.yml | 13 +++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6d7d421 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +ARG ENVIRONMENT="dev" +# ENVIRONMENT: dev or prod, refer to project.optional-dependencies in pyproject.toml + +FROM python:3.11-bookworm as builder + +WORKDIR /app +ARG ENVIRONMENT +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONUSERBASE=/app/__pypackages__ + +# 一旦flit_coreによるビルドを通すために毎回丸ごとコピーする。 +# あとでビルドに必要な最小限のファイルを調べます。 +COPY . . +RUN pip install --user --no-cache-dir -e ".[${ENVIRONMENT}]" + +FROM python:3.11-slim-bookworm as runner + +WORKDIR /app +ENV PYTHONUSERBASE=/app/__pypackages__ + +RUN groupadd -r app && useradd -r -g app app +RUN chown -R app:app /app +USER app + +COPY --from=builder /app/__pypackages__ /app/__pypackages__ +COPY --chown=app:app . ./ + +ENTRYPOINT ["python", "-m", "uvicorn", "birdxplorer.main:app", "--host", "0.0.0.0"] diff --git a/compose.yml b/compose.yml index 5d3bd88..74ffeaf 100644 --- a/compose.yml +++ b/compose.yml @@ -12,6 +12,19 @@ services: - '5432:5432' volumes: - postgres_data:/var/lib/postgresql/data + app: + depends_on: + - db + build: + args: + - ENVIRONMENT=dev + context: . + dockerfile: Dockerfile + env_file: + - .env + ports: + - '8000:8000' + volumes: postgres_data: From b2095ecbe8a7df5b182acc14651639ea5174de78 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Thu, 9 May 2024 15:10:09 +0900 Subject: [PATCH 02/11] fix(docker): copy minimum files --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d7d421..6cd6387 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,8 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PYTHONUSERBASE=/app/__pypackages__ -# 一旦flit_coreによるビルドを通すために毎回丸ごとコピーする。 -# あとでビルドに必要な最小限のファイルを調べます。 -COPY . . +COPY pyproject.toml README.md ./ +COPY birdxplorer/__init__.py ./birdxplorer/__init__.py RUN pip install --user --no-cache-dir -e ".[${ENVIRONMENT}]" FROM python:3.11-slim-bookworm as runner From 52b1af03ae98e1d25bd4ccb728f38b44a941cd5b Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Thu, 9 May 2024 15:10:53 +0900 Subject: [PATCH 03/11] fix(docker): use normal pip dir, extract python version to arg --- Dockerfile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6cd6387..85fcd32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,29 @@ +ARG PYTHON_VERSION_CODE=3.10 ARG ENVIRONMENT="dev" # ENVIRONMENT: dev or prod, refer to project.optional-dependencies in pyproject.toml -FROM python:3.11-bookworm as builder +FROM python:${PYTHON_VERSION_CODE}-bookworm as builder +ARG PYTHON_VERSION_CODE +ARG ENVIRONMENT WORKDIR /app -ARG ENVIRONMENT ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PYTHONUSERBASE=/app/__pypackages__ + PYTHONUNBUFFERED=1 COPY pyproject.toml README.md ./ -COPY birdxplorer/__init__.py ./birdxplorer/__init__.py -RUN pip install --user --no-cache-dir -e ".[${ENVIRONMENT}]" +COPY birdxplorer/__init__.py ./birdxplorer/ +RUN pip install --no-cache-dir -e ".[${ENVIRONMENT}]" -FROM python:3.11-slim-bookworm as runner +FROM python:${PYTHON_VERSION_CODE}-slim-bookworm as runner +ARG PYTHON_VERSION_CODE WORKDIR /app -ENV PYTHONUSERBASE=/app/__pypackages__ RUN groupadd -r app && useradd -r -g app app RUN chown -R app:app /app USER app -COPY --from=builder /app/__pypackages__ /app/__pypackages__ +COPY --from=builder /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages COPY --chown=app:app . ./ ENTRYPOINT ["python", "-m", "uvicorn", "birdxplorer.main:app", "--host", "0.0.0.0"] From f869acdb18c3614870edda3b20da9e6bcf21576a Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Mon, 13 May 2024 13:30:25 +0900 Subject: [PATCH 04/11] fix(directory): handle directory structure change by #56 --- Dockerfile => api/Dockerfile | 4 ++-- api/README.md | 2 ++ api/pyproject.toml | 8 ++++---- compose.yml | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) rename Dockerfile => api/Dockerfile (83%) create mode 100644 api/README.md diff --git a/Dockerfile b/api/Dockerfile similarity index 83% rename from Dockerfile rename to api/Dockerfile index 85fcd32..706cda4 100644 --- a/Dockerfile +++ b/api/Dockerfile @@ -11,7 +11,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 COPY pyproject.toml README.md ./ -COPY birdxplorer/__init__.py ./birdxplorer/ +COPY birdxplorer_api/__init__.py ./birdxplorer_api/ RUN pip install --no-cache-dir -e ".[${ENVIRONMENT}]" FROM python:${PYTHON_VERSION_CODE}-slim-bookworm as runner @@ -26,4 +26,4 @@ USER app COPY --from=builder /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages COPY --chown=app:app . ./ -ENTRYPOINT ["python", "-m", "uvicorn", "birdxplorer.main:app", "--host", "0.0.0.0"] +ENTRYPOINT ["python", "-m", "uvicorn", "birdxplorer_api.main:app", "--host", "0.0.0.0"] diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..281ffc7 --- /dev/null +++ b/api/README.md @@ -0,0 +1,2 @@ + +# BirdXplorer API diff --git a/api/pyproject.toml b/api/pyproject.toml index 7503043..3079e78 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -10,9 +10,9 @@ authors = [ {name = "osoken"}, ] dynamic = [ - "version", + "version", ] -readme = "../README.md" +readme = "README.md" license = {file = "../LICENSE"} requires-python = ">=3.10" @@ -100,11 +100,11 @@ legacy_tox_ini = """ envlist = py310 [testenv] - setenv = + setenv = VIRTUALENV_PIP = 24.0 deps = -e .[dev] - commands = + commands = black birdxplorer_api tests isort birdxplorer_api tests pytest diff --git a/compose.yml b/compose.yml index 74ffeaf..bbdc435 100644 --- a/compose.yml +++ b/compose.yml @@ -18,7 +18,7 @@ services: build: args: - ENVIRONMENT=dev - context: . + context: ./api dockerfile: Dockerfile env_file: - .env From adea7617a415c8412e8749647aa156bdec538d86 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Mon, 13 May 2024 13:46:44 +0900 Subject: [PATCH 05/11] fix: add docker compose watch support --- api/.dockerignore | 1 + compose.yml | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 api/.dockerignore diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 0000000..2b29f27 --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1 @@ +tests diff --git a/compose.yml b/compose.yml index bbdc435..e68f920 100644 --- a/compose.yml +++ b/compose.yml @@ -24,6 +24,11 @@ services: - .env ports: - '8000:8000' + develop: + watch: + - action: rebuild + path: ./api + target: /app/api volumes: From 97d8ddf947975ea8a735ee426d9228ac1f394a43 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Mon, 13 May 2024 14:23:10 +0900 Subject: [PATCH 06/11] feat(migrate): add migration package --- migrate/README.md | 2 + migrate/birdxplorer_migration/__init__.py | 1 + .../birdxplorer_migration/data}/.gitignore | 0 .../migrations/convert_data_from_v1.py | 0 .../scripts}/migrations/migrate_all.py | 0 migrate/pyproject.toml | 103 ++++++++++++++++++ 6 files changed, 106 insertions(+) create mode 100644 migrate/README.md create mode 100644 migrate/birdxplorer_migration/__init__.py rename {data => migrate/birdxplorer_migration/data}/.gitignore (100%) rename {scripts => migrate/birdxplorer_migration/scripts}/migrations/convert_data_from_v1.py (100%) rename {scripts => migrate/birdxplorer_migration/scripts}/migrations/migrate_all.py (100%) create mode 100644 migrate/pyproject.toml diff --git a/migrate/README.md b/migrate/README.md new file mode 100644 index 0000000..a2e3a42 --- /dev/null +++ b/migrate/README.md @@ -0,0 +1,2 @@ + +# BirdXplorer Migrations diff --git a/migrate/birdxplorer_migration/__init__.py b/migrate/birdxplorer_migration/__init__.py new file mode 100644 index 0000000..f102a9c --- /dev/null +++ b/migrate/birdxplorer_migration/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/data/.gitignore b/migrate/birdxplorer_migration/data/.gitignore similarity index 100% rename from data/.gitignore rename to migrate/birdxplorer_migration/data/.gitignore diff --git a/scripts/migrations/convert_data_from_v1.py b/migrate/birdxplorer_migration/scripts/migrations/convert_data_from_v1.py similarity index 100% rename from scripts/migrations/convert_data_from_v1.py rename to migrate/birdxplorer_migration/scripts/migrations/convert_data_from_v1.py diff --git a/scripts/migrations/migrate_all.py b/migrate/birdxplorer_migration/scripts/migrations/migrate_all.py similarity index 100% rename from scripts/migrations/migrate_all.py rename to migrate/birdxplorer_migration/scripts/migrations/migrate_all.py diff --git a/migrate/pyproject.toml b/migrate/pyproject.toml new file mode 100644 index 0000000..1136ad1 --- /dev/null +++ b/migrate/pyproject.toml @@ -0,0 +1,103 @@ +[build-system] +build-backend = "flit_core.buildapi" +requires = ["flit_core >=3.8.0,<4"] + + +[project] +name = "birdxplorer_migration" +description = "The Migration Scripts for BirdXplorer project." +authors = [ + {name = "osoken"}, +] +dynamic = [ + "version", +] +readme = "README.md" +license = {file = "../LICENSE"} +requires-python = ">=3.10" + +classifiers = [ + "Development Status :: 3 - Alpha", + "Natural Language :: Japanese", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.10", +] + +dependencies = [ + "birdxplorer_common @ git+https://github.com/codeforjapan/BirdXplorer.git@feature/issue-53-divide-python-packages#subdirectory=common", + "sqlalchemy", + "python-dotenv", +] + +[project.urls] +Source = "https://github.com/codeforjapan/BirdXplorer" + +[tool.setuptools] +packages=["birdxplorer"] + +[tool.setuptools.package-data] +birdxplorer = ["py.typed"] + +[project.optional-dependencies] +dev=[ + "black", + "flake8", + "pyproject-flake8", + "pytest", + "mypy", + "tox", + "isort", + "pytest-mock", + "pytest-cov", + "freezegun", + "types-python-dateutil", + "psycopg2-binary", + "factory_boy", + "uvicorn", + "polyfactory", + "httpx", +] +prod=[ +] + +[tool.black] +line-length = 120 +target-version = ['py310'] + +[tool.flake8] +max-line-length = 120 +extend-ignore = "E203,E701" + +[tool.mypy] +python_version = "3.10" +warn_return_any = true +warn_unused_configs = true +plugins = ["pydantic.mypy"] + +[tool.pydantic.mypy] +init_typed = true + +[tool.isort] +profile = "black" +known_first_party = "birdxplorer_api,birdxplorer_common,birdxplorer_etl" + +[tool.tox] +legacy_tox_ini = """ + [tox] + skipsdist = true + envlist = py310 + + [testenv] + setenv = + VIRTUALENV_PIP = 24.0 + deps = + -e .[dev] + commands = + black birdxplorer_api tests + isort birdxplorer_api tests + pytest + pflake8 birdxplorer_api/ tests/ + mypy birdxplorer_api --strict + mypy tests --strict +""" From 3c77c58e85d65d11caa3513584acce1070f733b4 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Mon, 13 May 2024 14:23:41 +0900 Subject: [PATCH 07/11] feat(docker): execute db migration on docker compose --- compose.yml | 10 ++++++++++ migrate/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 migrate/Dockerfile diff --git a/compose.yml b/compose.yml index e68f920..f2900e7 100644 --- a/compose.yml +++ b/compose.yml @@ -29,6 +29,16 @@ services: - action: rebuild path: ./api target: /app/api + migrate: + depends_on: + - db + build: + args: + - ENVIRONMENT=dev + context: ./migrate + dockerfile: Dockerfile + env_file: + - .env volumes: diff --git a/migrate/Dockerfile b/migrate/Dockerfile new file mode 100644 index 0000000..646f3a5 --- /dev/null +++ b/migrate/Dockerfile @@ -0,0 +1,34 @@ +ARG PYTHON_VERSION_CODE=3.10 +ARG ENVIRONMENT="dev" +# ENVIRONMENT: dev or prod, refer to project.optional-dependencies in pyproject.toml + +FROM python:${PYTHON_VERSION_CODE}-bookworm as builder +ARG PYTHON_VERSION_CODE +ARG ENVIRONMENT + +WORKDIR /app +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +COPY pyproject.toml README.md ./ +COPY birdxplorer_migration/__init__.py ./birdxplorer_migration/ +RUN pip install --no-cache-dir -e ".[${ENVIRONMENT}]" + +COPY --from=ghcr.io/ufoscout/docker-compose-wait:latest /wait /wait + +FROM python:${PYTHON_VERSION_CODE}-slim-bookworm as runner +ARG PYTHON_VERSION_CODE + +WORKDIR /app + +RUN groupadd -r app && useradd -r -g app app +RUN chown -R app:app /app +USER app + + +COPY --from=builder /wait /wait +COPY --from=builder /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages +COPY --chown=app:app . ./ + +ENV WAIT_COMMAND="python birdxplorer_migration/scripts/migrations/migrate_all.py birdxplorer_migration/data/appv1/" +ENTRYPOINT ["/wait"] From 7039f8defaedec141fcdc70dce484babc89d4ec2 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Mon, 13 May 2024 14:26:44 +0900 Subject: [PATCH 08/11] fix(docker): wait for db before migration --- compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compose.yml b/compose.yml index f2900e7..b422ba2 100644 --- a/compose.yml +++ b/compose.yml @@ -37,6 +37,8 @@ services: - ENVIRONMENT=dev context: ./migrate dockerfile: Dockerfile + environment: + - WAIT_HOSTS=db:5432 env_file: - .env From dd535f640c9878fe14759503f98e82bed08bb9c5 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Mon, 13 May 2024 14:34:47 +0900 Subject: [PATCH 09/11] chore(docker): script directory --- migrate/Dockerfile | 2 +- .../scripts/{migrations => }/convert_data_from_v1.py | 0 .../scripts/{migrations => }/migrate_all.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename migrate/birdxplorer_migration/scripts/{migrations => }/convert_data_from_v1.py (100%) rename migrate/birdxplorer_migration/scripts/{migrations => }/migrate_all.py (100%) diff --git a/migrate/Dockerfile b/migrate/Dockerfile index 646f3a5..0be3434 100644 --- a/migrate/Dockerfile +++ b/migrate/Dockerfile @@ -30,5 +30,5 @@ COPY --from=builder /wait /wait COPY --from=builder /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages COPY --chown=app:app . ./ -ENV WAIT_COMMAND="python birdxplorer_migration/scripts/migrations/migrate_all.py birdxplorer_migration/data/appv1/" +ENV WAIT_COMMAND="python birdxplorer_migration/scripts/migrate_all.py birdxplorer_migration/data/appv1/" ENTRYPOINT ["/wait"] diff --git a/migrate/birdxplorer_migration/scripts/migrations/convert_data_from_v1.py b/migrate/birdxplorer_migration/scripts/convert_data_from_v1.py similarity index 100% rename from migrate/birdxplorer_migration/scripts/migrations/convert_data_from_v1.py rename to migrate/birdxplorer_migration/scripts/convert_data_from_v1.py diff --git a/migrate/birdxplorer_migration/scripts/migrations/migrate_all.py b/migrate/birdxplorer_migration/scripts/migrate_all.py similarity index 100% rename from migrate/birdxplorer_migration/scripts/migrations/migrate_all.py rename to migrate/birdxplorer_migration/scripts/migrate_all.py From f35550a9f450879a0a58087ff6cad72f4690de79 Mon Sep 17 00:00:00 2001 From: sushi-chaaaan Date: Wed, 15 May 2024 14:42:53 +0900 Subject: [PATCH 10/11] refactor(docker): use healthcheck for wait db setup --- compose.yml | 11 +++++++++-- migrate/Dockerfile | 7 +------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compose.yml b/compose.yml index b422ba2..7d36098 100644 --- a/compose.yml +++ b/compose.yml @@ -8,13 +8,19 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: ${BX_STORAGE_SETTINGS__PASSWORD} POSTGRES_DB: postgres + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 ports: - '5432:5432' volumes: - postgres_data:/var/lib/postgresql/data app: depends_on: - - db + db: + condition: service_healthy build: args: - ENVIRONMENT=dev @@ -31,7 +37,8 @@ services: target: /app/api migrate: depends_on: - - db + db: + condition: service_healthy build: args: - ENVIRONMENT=dev diff --git a/migrate/Dockerfile b/migrate/Dockerfile index 0be3434..32e5ab1 100644 --- a/migrate/Dockerfile +++ b/migrate/Dockerfile @@ -14,8 +14,6 @@ COPY pyproject.toml README.md ./ COPY birdxplorer_migration/__init__.py ./birdxplorer_migration/ RUN pip install --no-cache-dir -e ".[${ENVIRONMENT}]" -COPY --from=ghcr.io/ufoscout/docker-compose-wait:latest /wait /wait - FROM python:${PYTHON_VERSION_CODE}-slim-bookworm as runner ARG PYTHON_VERSION_CODE @@ -25,10 +23,7 @@ RUN groupadd -r app && useradd -r -g app app RUN chown -R app:app /app USER app - -COPY --from=builder /wait /wait COPY --from=builder /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages /usr/local/lib/python${PYTHON_VERSION_CODE}/site-packages COPY --chown=app:app . ./ -ENV WAIT_COMMAND="python birdxplorer_migration/scripts/migrate_all.py birdxplorer_migration/data/appv1/" -ENTRYPOINT ["/wait"] +ENTRYPOINT ["python", "birdxplorer_migration/scripts/migrate_all.py", "birdxplorer_migration/data/appv1/"] From d7186f4095ecc7503496eefd259599603dbc4a6c Mon Sep 17 00:00:00 2001 From: osoken Date: Thu, 16 May 2024 23:15:25 +0900 Subject: [PATCH 11/11] fix(Dockerfile): add psycopg2 for prod dependency --- api/Dockerfile | 15 +++++++++++++++ api/pyproject.toml | 1 + migrate/Dockerfile | 16 ++++++++++++++++ migrate/pyproject.toml | 1 + 4 files changed, 33 insertions(+) diff --git a/api/Dockerfile b/api/Dockerfile index 706cda4..b50590a 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -12,13 +12,28 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ COPY pyproject.toml README.md ./ COPY birdxplorer_api/__init__.py ./birdxplorer_api/ + +RUN if [ "${ENVIRONMENT}" = "prod" ]; then \ + apt-get update && apt-get install -y --no-install-recommends \ + postgresql-client-15 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*; \ + fi RUN pip install --no-cache-dir -e ".[${ENVIRONMENT}]" FROM python:${PYTHON_VERSION_CODE}-slim-bookworm as runner ARG PYTHON_VERSION_CODE +ARG ENVIRONMENT WORKDIR /app +RUN if [ "${ENVIRONMENT}" = "prod" ]; then \ + apt-get update && apt-get install -y --no-install-recommends \ + libpq5 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*; \ + fi + RUN groupadd -r app && useradd -r -g app app RUN chown -R app:app /app USER app diff --git a/api/pyproject.toml b/api/pyproject.toml index 3079e78..e1b12be 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -62,6 +62,7 @@ dev=[ "httpx", ] prod=[ + "psycopg2", ] [tool.pytest.ini_options] diff --git a/migrate/Dockerfile b/migrate/Dockerfile index 32e5ab1..be0444e 100644 --- a/migrate/Dockerfile +++ b/migrate/Dockerfile @@ -12,13 +12,29 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ COPY pyproject.toml README.md ./ COPY birdxplorer_migration/__init__.py ./birdxplorer_migration/ + +RUN if [ "${ENVIRONMENT}" = "prod" ]; then \ + apt-get update && apt-get install -y --no-install-recommends \ + postgresql-client-15 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*; \ + fi + RUN pip install --no-cache-dir -e ".[${ENVIRONMENT}]" FROM python:${PYTHON_VERSION_CODE}-slim-bookworm as runner ARG PYTHON_VERSION_CODE +ARG ENVIRONMENT WORKDIR /app +RUN if [ "${ENVIRONMENT}" = "prod" ]; then \ + apt-get update && apt-get install -y --no-install-recommends \ + libpq5 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*; \ + fi + RUN groupadd -r app && useradd -r -g app app RUN chown -R app:app /app USER app diff --git a/migrate/pyproject.toml b/migrate/pyproject.toml index 1136ad1..f11c627 100644 --- a/migrate/pyproject.toml +++ b/migrate/pyproject.toml @@ -59,6 +59,7 @@ dev=[ "httpx", ] prod=[ + "psycopg2" ] [tool.black]