-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from koldakov/fix/poetry-docker-deployment
Fix/poetry docker deployment
- Loading branch information
Showing
119 changed files
with
5,081 additions
and
3,031 deletions.
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.0.0] - 2024-06-01 | ||
|
||
### Added | ||
|
||
- API: Character selection by id | ||
- API: Paginated characters selection by gender, status, species, order by, order by direction | ||
- API: Character search by name | ||
- API: Episode selection by id | ||
- API: Paginated episodes selection | ||
- API: Season selection by id | ||
- API: Paginated seasons selection | ||
- API: Callbacks for characters, episodes, seasons | ||
- API: Server Sent Events (SSE) for characters | ||
- API: User registration | ||
- API: User authorization | ||
- API: User activation | ||
- API: User confirmation resend message | ||
- API: User information update | ||
- GraphQL: Character selection by id | ||
- GraphQL: Paginated (Edged) characters selection by gender, status, species, order by, order by direction | ||
- GraphQL: Episode selection by id | ||
- GraphQL: Paginated (Edged) episodes selection | ||
- GraphQL: Season selection by id | ||
- GraphQL: Paginated (Edged) seasons selection | ||
|
||
[1.0.0]: https://github.com/koldakov/futuramaapi/releases/tag/1.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 |
---|---|---|
@@ -1,46 +1,56 @@ | ||
FROM python:3.12.0-slim-bullseye | ||
FROM python:3.12.0-slim-bullseye as python-base | ||
|
||
# Environ | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV VIRTUAL_ENV=/opt/venv | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PATH="${PATH}:/root/.local/bin" \ | ||
POETRY_HOME=/opt/poetry \ | ||
POETRY_VENV=/opt/poetry-venv \ | ||
POETRY_CACHE_DIR=/opt/.cache | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
# Arguments | ||
ARG APP_USER=qworpa | ||
ARG APP_USER=userapp | ||
ARG WORK_DIR=/app | ||
|
||
# Install OS dependencies | ||
COPY install-dependencies.sh /tmp | ||
RUN . /tmp/install-dependencies.sh | ||
# Install dependencies | ||
RUN apt-get update | ||
RUN apt-get -y install make | ||
|
||
# Install python environ | ||
RUN python3 -m venv $VIRTUAL_ENV | ||
COPY requirements.txt /tmp | ||
RUN pip install --upgrade pip | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
# Create stage for Poetry installation | ||
FROM python-base as poetry-base | ||
|
||
# Add user | ||
RUN groupadd \ | ||
--system ${APP_USER} \ | ||
&& useradd --no-log-init --system --gid ${APP_USER} ${APP_USER} | ||
# Creating a virtual environment just for poetry and install it with pip | ||
RUN python3 -m venv $POETRY_VENV \ | ||
&& $POETRY_VENV/bin/pip install poetry | ||
|
||
# Create a new stage from the base python image | ||
FROM python-base as example-app | ||
|
||
# Copy project files to the work dir | ||
COPY ./ ${WORK_DIR} | ||
# Copy Poetry to app image | ||
COPY --from=poetry-base ${POETRY_VENV} ${POETRY_VENV} | ||
|
||
# Set owner to the project | ||
RUN chown -R ${APP_USER}:${APP_USER} ${WORK_DIR} | ||
# Add Poetry to PATH | ||
ENV PATH="${PATH}:${POETRY_VENV}/bin" | ||
|
||
# Set work dir | ||
WORKDIR ${WORK_DIR} | ||
|
||
# Copy Dependencies | ||
COPY . ${WORK_DIR} | ||
|
||
# Install Dependencies | ||
RUN poetry install --no-interaction --no-cache --without dev --without test | ||
|
||
EXPOSE 8000 | ||
|
||
# Add user | ||
RUN groupadd \ | ||
--system ${APP_USER} \ | ||
&& useradd --no-log-init --system --gid ${APP_USER} ${APP_USER} | ||
|
||
# Set project user | ||
USER ${APP_USER}:${APP_USER} | ||
|
||
# Compile messages | ||
RUN cd ${WORK_DIR}; make messages-compile | ||
|
||
# Main launch command | ||
CMD ["./docker-entrypoint.sh"] |
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 |
---|---|---|
@@ -1,28 +1,19 @@ | ||
SHELL = /bin/bash | ||
PYTHON = python3.12 | ||
|
||
help: # Display this message | ||
@sed -ne '/@sed/!s/# //p' $(MAKEFILE_LIST) | ||
|
||
messages-init: # locale=LANG, init LANG language | ||
@test $${locale?Please specify locale. Example \"locale=en_CA\"} | ||
@pybabel init -l $(locale) -i locale/messages.pot -d locale | ||
install-dev: # Install DEV/TEST Environ and dependencies | ||
@echo "Upgrading pip" | ||
@$(PYTHON) -m pip install --upgrade pip | ||
@echo "Installing poetry" | ||
@$(PYTHON) -m pip install poetry | ||
@echo "Installing dependencies" | ||
@poetry install | ||
|
||
messages-extract: # Extract messages to locale/messages.pot | ||
@pybabel extract \ | ||
--version=0.0.1 \ | ||
[email protected] \ | ||
--project=FuturamaAPI \ | ||
--copyright-holder=FuturamaAPI \ | ||
--mapping babel.cfg \ | ||
--output-file=locale/messages.pot \ | ||
. | ||
test: # Run tests | ||
@poetry run $(PYTHON) -m pytest | ||
|
||
messages: # Update all locales | ||
@$(MAKE) messages-extract | ||
@pybabel update --input-file=locale/messages.pot --output-dir=locale | ||
|
||
messages-compile: # Generate .mo files for all locales | ||
@pybabel compile --directory=locale | ||
|
||
tests: # Run tests | ||
@python -m pytest | ||
migrate: # Migrate | ||
@poetry run $(PYTHON) -m alembic upgrade head |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.