Skip to content

Commit

Permalink
Clean up DockerFile (#37)
Browse files Browse the repository at this point in the history
* Add .env to .gitignore file

* Update precommit with hook that auto adds ticket from branch name

* Update pre commit config so things are install into the correct stages

* Update docker to use pipx rather than a curl command

* Update the docker file to utilize pipx and an up to date version of poetry

* Fix comments in Dockerfile

---------

Co-authored-by: JP Hanna <[email protected]>
  • Loading branch information
jplhanna and JP Hanna authored Dec 31, 2023
1 parent 20f7be2 commit 7dc9d33
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ logs/
coverage.xml
local.env
docker-compose.override.yml
.env
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
default_install_hook_types:
- pre-commit
- commit-msg
default_stages:
- pre-commit
repos:
- repo: local
hooks:
Expand Down Expand Up @@ -60,3 +65,10 @@ repos:
types: [ python ]
exclude: alembic|test_.*|conftest.py
args: [ -c, pyproject.toml ]

- repo: https://github.com/milin/giticket
rev: v1.4
hooks:
- id: giticket
stages:
- commit-msg
29 changes: 20 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
FROM python:3.11.4 as base
FROM python:3.11.4-slim as base
MAINTAINER JP Hanna "[email protected]"
WORKDIR /app/
COPY . /app/

FROM base as install-poetry
ENV POETRY_VIRTUALENVS_CREATE=false \
POETRY_VERSION=1.5.1
RUN curl -sSL https://install.python-poetry.org | python3 -

# Set env variables
ENV PIPX_BIN_DIR="/opt/pipx" \
POETRY_NO_INTERACTION=true \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_CACHE_DIR="/opt/poetry" \
POETRY_VERSION=1.7.0 \
PATH="/root/.local/share/pipx/venvs/poetry/bin:$PATH"
ENV PATH="$POETRY_VIRTUALENVS_PATH/bin:$PIPX_BIN_DIR:$PATH"

# Install poetry
RUN pip install --upgrade pip \
&& pip install pipx \
&& pipx install poetry==$POETRY_VERSION
RUN apt-get update && apt-get install -y --no-install-recommends gcc
ENV PATH "/root/.local/bin:$PATH"

# Install python dependencies in /.venv
RUN poetry install --no-root --no-ansi --no-interaction --only=main
# Install python dependencies
RUN poetry install --no-root --no-ansi --no-interaction --only=main --no-directory

# Install application into container
ENV PYTHONPATH "{$PYTHONPATH}:/app/"
ENV PYTHONPATH "$PYTHONPATH:/app/"

FROM install-poetry as install-dev
RUN poetry install --no-root --no-ansi --no-interaction --only=dev
RUN poetry install --no-root --no-ansi --no-interaction --only=dev --no-directory

0 comments on commit 7dc9d33

Please sign in to comment.