Skip to content

Commit

Permalink
Updated docker build (#13)
Browse files Browse the repository at this point in the history
* Fix package install part of docker build
* Add setuptools, since its a dependency
  • Loading branch information
jonathangreen authored Feb 12, 2024
1 parent e51e9e1 commit 8a80157
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM python:3.10-slim

ENV APP_DIR=/virtual_library_card/ \
DJANGO_SETTINGS_MODULE=virtual_library_card.settings.prod
DJANGO_SETTINGS_MODULE=virtual_library_card.settings.prod \
POETRY_VIRTUALENVS_CREATE=false

ENV UWSGI_MASTER=1 \
UWSGI_HTTP_AUTO_CHUNKED=1 \
Expand All @@ -22,29 +23,38 @@ ENV UWSGI_MASTER=1 \
UWSGI_LOGFORMAT="[pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) %(clean_uri) => generated %(rsize) bytes in %(msecs) msecs (%(proto) %(status)) %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core))"

ARG POETRY_VERSION=1.7.1
ARG REPO=ThePalaceProject/virtual-library-card

# Install system
RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
curl mime-support && \
curl -sSL https://install.python-poetry.org | POETRY_HOME="/opt/poetry" python3 - --yes --version "$POETRY_VERSION" && \
ln -s /opt/poetry/bin/poetry /bin/poetry && \
apt-get remove curl -y && \
apt-get autoremove -y && \
rm -Rf /var/lib/apt/lists/* && \
rm -Rf /root/.cache && \
find /opt /usr -type d -name "__pycache__" -exec rm -rf {} +

# Install Python dependencies
COPY pyproject.toml poetry.lock $APP_DIR
WORKDIR $APP_DIR
RUN POETRY_VIRTUALENVS_CREATE=false poetry install --only main --no-interaction && \

# Do basic python dependency install
# We use curl here to grab our poetry.lock and pyproject.toml files from the repo
# so that we can cache the docker layer for the poetry install step.
# If these files change, the later poetry install will handle it.
RUN curl -fsSL https://raw.githubusercontent.com/${REPO}/main/pyproject.toml -o ${APP_DIR}pyproject.toml && \
curl -fsSL https://raw.githubusercontent.com/${REPO}/main/poetry.lock -o ${APP_DIR}poetry.lock && \
poetry install --sync --only main --no-root --no-interaction && \
poetry cache clear -n --all pypi && \
rm -Rf /root/.cache && \
find /opt /usr -type d -name "__pycache__" -exec rm -rf {} +

# Install code
# Do final poetry install, when the layers are cached, this is the only step that will run
COPY . $APP_DIR
RUN POETRY_VIRTUALENVS_CREATE=false poetry install --sync --only main --no-interaction && \
poetry cache clear -n --all pypi && \
rm -Rf /root/.cache && \
find /opt /usr -type d -name "__pycache__" -exec rm -rf {} +

EXPOSE 8000

Expand Down
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ description = "Virtual Library Card Creator"
homepage = "https://thepalaceproject.org"
license = "Apache-2.0"
name = "Virtual Library Card"
packages = [
{include = "virtual_library_card"},
{include = "virtuallibrarycard"},
]
readme = "README.md"
repository = "https://github.com/ThePalaceProject/virtual-library-card"
version = "0" # Version number is managed with tags in git
Expand Down Expand Up @@ -62,6 +66,7 @@ python-stdnum = "1.19"
pytz = "^2023.2"
pyuwsgi = ">=2.0,<2.1"
requests = "^2.31"
setuptools = "^69.1.0"

[tool.poetry.group.ci.dependencies]
dunamai = "^1.16"
Expand Down

0 comments on commit 8a80157

Please sign in to comment.