-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from ropable/master
Use Alpine base image, update JavaScript library versions
- Loading branch information
Showing
7 changed files
with
156 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
# syntax=docker/dockerfile:1 | ||
# Prepare the base environment. | ||
FROM python:3.12.4-slim AS builder_base_caddy | ||
FROM python:3.12.6-alpine AS builder_base | ||
LABEL [email protected] | ||
LABEL org.opencontainers.image.source=https://github.com/dbca-wa/caddy | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y libmagic-dev gcc binutils gdal-bin proj-bin python3-dev libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& pip install --root-user-action=ignore --upgrade pip | ||
# Install system requirements to build Python packages. | ||
RUN apk add --no-cache \ | ||
gcc \ | ||
libressl-dev \ | ||
musl-dev \ | ||
libffi-dev | ||
# Create a non-root user to run the application. | ||
ARG UID=10001 | ||
ARG GID=10001 | ||
RUN addgroup -g ${GID} appuser \ | ||
&& adduser -H -D -u ${UID} -G appuser appuser | ||
|
||
# Install Python libs using poetry. | ||
FROM builder_base_caddy AS python_libs_caddy | ||
# Install Python libs using Poetry. | ||
FROM builder_base AS python_libs_caddy | ||
# Add system dependencies required to use GDAL | ||
RUN apk add --no-cache \ | ||
gdal \ | ||
geos \ | ||
proj \ | ||
binutils | ||
WORKDIR /app | ||
ARG POETRY_VERSION=1.8.3 | ||
RUN pip install --no-cache-dir --root-user-action=ignore poetry==${POETRY_VERSION} | ||
COPY poetry.lock pyproject.toml ./ | ||
RUN poetry config virtualenvs.create false \ | ||
ARG POETRY_VERSION=1.8.3 | ||
RUN pip install --no-cache-dir --root-user-action=ignore poetry==${POETRY_VERSION} \ | ||
&& poetry config virtualenvs.create false \ | ||
&& poetry install --no-interaction --no-ansi --only main | ||
|
||
# Create a non-root user. | ||
ARG UID=10001 | ||
ARG GID=10001 | ||
RUN groupadd -g ${GID} appuser \ | ||
&& useradd --no-create-home --no-log-init --uid ${UID} --gid ${GID} appuser | ||
# Remove system libraries, no longer required. | ||
RUN apk del \ | ||
gcc \ | ||
libressl-dev \ | ||
musl-dev \ | ||
libffi-dev | ||
|
||
# Install the project. | ||
FROM python_libs_caddy AS project_caddy | ||
COPY geocoder.py gunicorn.py manage.py ./ | ||
COPY caddy ./caddy | ||
COPY shack ./shack | ||
|
||
USER ${UID} | ||
EXPOSE 8080 | ||
CMD ["gunicorn", "caddy.wsgi", "--config", "gunicorn.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# syntax=docker/dockerfile:1 | ||
# Prepare the base environment. | ||
FROM python:3.12.4-slim AS builder_base_caddy | ||
LABEL [email protected] | ||
LABEL org.opencontainers.image.source=https://github.com/dbca-wa/caddy | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y libmagic-dev gcc binutils gdal-bin proj-bin python3-dev libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& pip install --root-user-action=ignore --upgrade pip | ||
|
||
# Install Python libs using poetry. | ||
FROM builder_base_caddy AS python_libs_caddy | ||
WORKDIR /app | ||
ARG POETRY_VERSION=1.8.3 | ||
RUN pip install --no-cache-dir --root-user-action=ignore poetry==${POETRY_VERSION} | ||
COPY poetry.lock pyproject.toml ./ | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install --no-interaction --no-ansi --only main | ||
|
||
# Create a non-root user. | ||
ARG UID=10001 | ||
ARG GID=10001 | ||
RUN groupadd -g ${GID} appuser \ | ||
&& useradd --no-create-home --no-log-init --uid ${UID} --gid ${GID} appuser | ||
|
||
# Install the project. | ||
COPY geocoder.py gunicorn.py manage.py ./ | ||
COPY caddy ./caddy | ||
COPY shack ./shack | ||
|
||
USER ${UID} | ||
EXPOSE 8080 | ||
CMD ["gunicorn", "caddy.wsgi", "--config", "gunicorn.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ patches: | |
- path: service_patch.yaml | ||
images: | ||
- name: ghcr.io/dbca-wa/caddy | ||
newTag: 2.3.9 | ||
newTag: 2.3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "caddy" | ||
version = "2.3.9" | ||
version = "2.3.10" | ||
description = "Lightweight application service to harvest and index the cadastre dataset, and expose an API endpoint to allow full-text searching of addresses." | ||
authors = ["Ashley Felton <[email protected]>"] | ||
license = "Apache License 2.0" | ||
|
@@ -9,7 +9,7 @@ package-mode = false | |
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
django = "4.2.15" | ||
psycopg = {version = "3.2.1", extras = ["binary", "pool"]} | ||
psycopg = { version = "3.2.1", extras = ["binary", "pool"] } | ||
python-dotenv = "1.0.1" | ||
dj-database-url = "2.2.0" | ||
django-extensions = "3.2.3" | ||
|
@@ -29,6 +29,20 @@ ipython = "^8.27.0" | |
ipdb = "^0.13.13" | ||
pre-commit = "^3.8.0" | ||
|
||
# Reference: https://docs.astral.sh/ruff/configuration/ | ||
[tool.ruff] | ||
line-length = 120 | ||
|
||
[tool.ruff.lint] | ||
ignore = [ | ||
"E501", # Line too long | ||
"E722", # Bare except | ||
] | ||
|
||
# Reference: https://www.djlint.com/docs/configuration/ | ||
[tool.djlint] | ||
profile = "django" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.masonry.api" |