Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: migrate to ubi9 image and drop postgis #524

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 10 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
# 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 root
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 \
&& dnf clean all \
&& 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
voneiden marked this conversation as resolved.
Show resolved Hide resolved

COPY --chown=appuser:appuser docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
Expand All @@ -37,9 +30,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
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

if [ -z "$SKIP_DATABASE_CHECK" -o "$SKIP_DATABASE_CHECK" = "0" ]; then
until nc -z -v -w30 "$DATABASE_HOST" 5432
until nc --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.