diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ac645cf..422f7871 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: services: postgres: - image: postgis/postgis:13-3.2 + image: postgres:13 ports: - 5432:5432 options: >- @@ -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 diff --git a/Dockerfile b/Dockerfile index 922aacd4..67390e9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ +# 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 @@ -7,28 +9,18 @@ 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"] @@ -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 diff --git a/README.md b/README.md index 9cb5d4d2..d1fb2b48 100644 --- a/README.md +++ b/README.md @@ -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;" diff --git a/docker-compose.yml b/docker-compose.yml index 380df336..829fd5f1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ceb040e1..b1e8770a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -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 diff --git a/open_city_profile/settings.py b/open_city_profile/settings.py index 71968610..5c2e8655 100644 --- a/open_city_profile/settings.py +++ b/open_city_profile/settings.py @@ -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") @@ -190,7 +188,6 @@ "django.contrib.sites", "django.contrib.messages", "open_city_profile.apps.OpenCityProfileStaticFilesConfig", - "django.contrib.gis", "django_filters", "parler", "corsheaders", diff --git a/tools/apt-cleanup.sh b/tools/apt-cleanup.sh deleted file mode 100755 index 9b48d4e8..00000000 --- a/tools/apt-cleanup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! -z "$@" ]]; then - apt-get remove -y "$@" -fi - -apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -apt-get clean -rm -rf /var/lib/apt/lists/* diff --git a/tools/apt-install.sh b/tools/apt-install.sh deleted file mode 100755 index 6b67c3fd..00000000 --- a/tools/apt-install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -apt-get update -apt-get install -y --no-install-recommends "$@"