-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:codeforjapan/BirdXplorer into feat/…
…add-topic-seed # Conflicts: # common/birdxplorer_common/models.py
- Loading branch information
Showing
15 changed files
with
296 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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 api/pyproject.toml api/README.md ./ | ||
COPY api/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 python -m pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -e ".[${ENVIRONMENT}]" | ||
|
||
COPY ../common ./common | ||
RUN if [ "${ENVIRONMENT}" = "dev" ]; then \ | ||
pip install -e ./common; \ | ||
fi | ||
|
||
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 | ||
|
||
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 api ./ | ||
COPY ../common ./common | ||
|
||
ENTRYPOINT ["python", "-m", "uvicorn", "birdxplorer_api.main:app", "--host", "0.0.0.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
ARG PYTHON_VERSION_CODE=3.10 | ||
ARG ENVIRONMENT="prod" | ||
# 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_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 python -m pip install --no-cache-dir --upgrade pip && \ | ||
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 | ||
|
||
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", "gunicorn", "birdxplorer_api.main:app", "-k", "uvicorn.workers.UvicornWorker", "-w", "1", "--bind", "0.0.0.0:10000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.