Skip to content

Commit

Permalink
build: migrate to ubi9 image and drop postgis
Browse files Browse the repository at this point in the history
In an effort to reduce dependency on dockerhub, switching to use ubi9
rhel image. Additionally dropping postgis as it simplifies transitioning
to ubi9 because gdal is no longer a required dependency.

Refs: HP-2685
  • Loading branch information
voneiden committed Oct 17, 2024
1 parent 13d0ce3 commit 8bd91f8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 44 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

services:
postgres:
image: postgis/postgis:13-3.2
image: postgres:13
ports:
- 5432:5432
options: >-
Expand Down Expand Up @@ -50,9 +50,6 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install system packages
run: sudo apt-get install -y gdal-bin
- name: Install Python dependencies
run: |
pip install -r requirements.txt -r requirements-dev.txt codecov
Expand Down
27 changes: 9 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
# Used by Azure Devops to pull from internal registry
ARG BUILDER_REGISTRY=registry.access.redhat.com
# ==============================
FROM python:3.11-slim-bookworm as appbase
FROM ${BUILDER_REGISTRY}/ubi9/python-311:latest AS appbase
# ==============================

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

COPY tools /tools
ENV PATH="/tools:${PATH}"

USER 0
RUN groupadd -g 1000 appuser \
&& useradd -u 1000 -g appuser -ms /bin/bash appuser \
&& chown -R appuser:appuser /app

COPY --chown=appuser:appuser requirements*.txt /app/

RUN apt-install.sh \
git \
curl \
build-essential \
libpq-dev \
gdal-bin \
netcat-openbsd \
python3-gdal \
postgresql-client \
RUN dnf update -y \
&& dnf install -y nmap-ncat \
&& pip install --upgrade pip setuptools wheel \
&& pip install --no-cache-dir --no-deps -r /app/requirements.txt \
&& pip install --no-cache-dir -r /app/requirements-prod.txt \
&& apt-cleanup.sh build-essential
&& pip install --no-cache-dir -r /app/requirements-prod.txt

COPY --chown=appuser:appuser docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
Expand All @@ -37,9 +29,8 @@ ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
FROM appbase as development
# ==============================

RUN apt-install.sh build-essential \
&& pip install --no-cache-dir -r /app/requirements-dev.txt \
&& apt-cleanup.sh build-essential
RUN pip install --no-cache-dir -r /app/requirements-dev.txt


ENV DEV_SERVER=1

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ Create user and database
sudo -u postgres createuser -P -R -S open_city_profile # use password `open_city_profile`
sudo -u postgres createdb -O open_city_profile open_city_profile

Create extensions in the database

sudo -u postgres psql open_city_profile -c "CREATE EXTENSION postgis;"

Allow user to create test database

sudo -u postgres psql -c "ALTER USER open_city_profile CREATEDB;"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
postgres:
image: postgis/postgis:13-3.2-alpine
image: postgres:13-alpine
restart: on-failure
environment:
POSTGRES_USER: open_city_profile
Expand Down
3 changes: 2 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
set -e

if [ -z "$SKIP_DATABASE_CHECK" -o "$SKIP_DATABASE_CHECK" = "0" ]; then
until nc -z -v -w30 "$DATABASE_HOST" 5432
# RHEL ncat
until ncat --verbose --wait 30 --send-only "$DATABASE_HOST" 5432
do
echo "Waiting for postgres database connection..."
sleep 1
Expand Down
3 changes: 0 additions & 3 deletions open_city_profile/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS")

DATABASES = {"default": env.db()}
# Ensure postgis engine
DATABASES["default"]["ENGINE"] = "django.contrib.gis.db.backends.postgis"

if env("DATABASE_PASSWORD"):
DATABASES["default"]["PASSWORD"] = env("DATABASE_PASSWORD")
Expand Down Expand Up @@ -190,7 +188,6 @@
"django.contrib.sites",
"django.contrib.messages",
"open_city_profile.apps.OpenCityProfileStaticFilesConfig",
"django.contrib.gis",
"django_filters",
"parler",
"corsheaders",
Expand Down
9 changes: 0 additions & 9 deletions tools/apt-cleanup.sh

This file was deleted.

4 changes: 0 additions & 4 deletions tools/apt-install.sh

This file was deleted.

0 comments on commit 8bd91f8

Please sign in to comment.