From b9cce371de3509946bee894405fc41c3e0389bc4 Mon Sep 17 00:00:00 2001 From: GabrielCarvalho Date: Sat, 14 Sep 2024 19:06:12 -0300 Subject: [PATCH] build(Dockerfiles): Adding dockerfiles to the project --- Dockerfile | 12 ++---------- Dockerfile.dev | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index 6b0cce4..1dee99a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,6 @@ ENV POETRY_NO_INTERACTION=1 \ WORKDIR app/ COPY pyproject.toml poetry.lock ./ - -#RUN touch README.md - RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root FROM python:3.11-slim-buster as runtime @@ -28,10 +25,5 @@ COPY alembic.ini ./ COPY migrations ./migrations COPY entrypoint.sh ./ -#RUN alembic init migrations \ -# && alembic revision --autogenerate \ -# && alembic upgrade head - -EXPOSE 8000 -CMD ["uvicorn", "--host", "0.0.0.0", "app.main:app"] -#ENTRYPOINT ["python", "-m", "app.app"] +EXPOSE 5000 +CMD ["uvicorn", "--host", "0.0.0.0", "--port", "5000", "app.main:app"] diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..e24118f --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,39 @@ +FROM python:3.11-buster as builder + +RUN pip install poetry==1.4.2 + +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache + +WORKDIR app/ + +COPY pyproject.toml poetry.lock ./ + +#RUN touch README.md + +RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root +RUN poetry add pytest + +FROM python:3.11-slim-buster as runtime + +ENV VIRTUAL_ENV=/app/.venv \ + PATH="/app/.venv/bin:$PATH" + +COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} + +COPY .env ./ +COPY app ./app +COPY alembic.ini ./ +COPY migrations ./migrations +COPY entrypoint.sh ./ +COPY tests ./tests +RUN chmod +x ./entrypoint.sh + +#RUN alembic init migrations \ +# && alembic revision --autogenerate \ +# && alembic upgrade head + +EXPOSE 8000 +# CMD ["uvicorn", "--host", "0.0.0.0", "app.main:app"]