Skip to content

Commit

Permalink
update: Removed venv from the container
Browse files Browse the repository at this point in the history
  • Loading branch information
kojicmarko committed Feb 23, 2024
1 parent d94eab6 commit 9201f2e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ COPY poetry.lock pyproject.toml /code/

RUN apk add --no-cache build-base libffi-dev curl netcat-openbsd
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_HOME=/usr/local \
POETRY_VERSION=1.7.1
RUN curl -sSL https://install.python-poetry.org | python3 -

RUN poetry install --no-interaction --no-ansi --only main
RUN curl -sSL https://install.python-poetry.org | python3 - && \
poetry install --no-interaction --no-ansi --only main

# - - - - - - - - - - - - - - - - - - - - #

FROM python:3.10.6-alpine
WORKDIR /code

COPY --from=builder /code /code
COPY --from=builder /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY ./src /code/src
COPY ./alembic.ini /code/alembic.ini
COPY ./alembic /code/alembic
COPY ./docker_start.sh /code/docker_start.sh
COPY entrypoint.sh /code/entrypoint.sh

RUN addgroup --gid 1000 pyweb
RUN adduser pyweb -h /code -u 1000 -G pyweb -DH
RUN chmod +x /code/entrypoint.sh && \
addgroup --gid 1000 pyweb && \
adduser pyweb -h /code -u 1000 -G pyweb -DH
USER 1000

CMD ["/bin/sh", "/code/docker_start.sh"]
ENTRYPOINT ["/code/entrypoint.sh"]
12 changes: 0 additions & 12 deletions docker_start.sh

This file was deleted.

20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

echo "Waiting for PostgreSQL..."
while ! nc -z db 5432; do
sleep 0.1
done
echo "PostgreSQL started"

echo "Running migrations..."
alembic upgrade head
echo "Migrations done"

if [ "$RELOAD" = "true" ]
then
uvicorn src.main:app --host 0.0.0.0 --port 80 --reload
else
uvicorn src.main:app --host 0.0.0.0 --port 80
fi

exec "$@"

0 comments on commit 9201f2e

Please sign in to comment.