Skip to content

Commit

Permalink
refactor(docker): use healthcheck for wait db setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed May 15, 2024
1 parent dd535f6 commit f35550a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 9 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +37,8 @@ services:
target: /app/api
migrate:
depends_on:
- db
db:
condition: service_healthy
build:
args:
- ENVIRONMENT=dev
Expand Down
7 changes: 1 addition & 6 deletions migrate/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/"]

0 comments on commit f35550a

Please sign in to comment.