Skip to content

Commit

Permalink
experiment with removing poetry bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanjbrown committed Apr 19, 2024
1 parent 568246a commit 00c714c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
29 changes: 8 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,21 @@ WORKDIR /src
COPY package.json .
RUN npm install


# poetry
FROM python:3.12-slim AS poetry-packages

RUN apt-get update && apt-get install --yes build-essential > /dev/null

RUN pip install poetry poetry-plugin-bundle

WORKDIR /src

COPY pyproject.toml .
COPY poetry.lock .

# do this so that poetry bundle can run without the project - can't pass --no-root to bundle
RUN touch README.md

RUN poetry bundle venv ./venv


# app
FROM python:3.12-slim

RUN apt-get update && apt-get install --yes libpq-dev > /dev/null
RUN apt-get update && apt-get install --yes libpq-dev build-essential > /dev/null

WORKDIR /usr/src/app

COPY --from=npm-packages /src/node_modules ./node_modules
COPY --from=poetry-packages /src/venv ./venv

COPY pyproject.toml .
COPY poetry.lock .
COPY README.md .

RUN pip install poetry
RUN poetry install

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ docker_shell: ## Run the docker container

.PHONY: docker_test
docker_test: ## Run the tests in the docker container
docker run -e DATABASE_URL=psql://consultations_test:@host.docker.internal:5432/consultations_test $(IMAGE) ./venv/bin/pytest
docker run -e DATABASE_URL=psql://consultations_test:@host.docker.internal:5432/consultations_test $(IMAGE) poetry run pytest tests/

.PHONY: docker_login
docker_login:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ Then
```
npm run dev
```

6 changes: 3 additions & 3 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

venv/bin/django-admin migrate
venv/bin/django-admin compress --force --engine jinja2
exec venv/bin/gunicorn -c ./consultation_analyser/gunicorn.py consultation_analyser.wsgi
poetry run django-admin migrate
poetry run django-admin compress --force --engine jinja2
exec poetry run gunicorn -c ./consultation_analyser/gunicorn.py consultation_analyser.wsgi

0 comments on commit 00c714c

Please sign in to comment.