Skip to content

Commit

Permalink
Update development and test setup (#321)
Browse files Browse the repository at this point in the history
* Ensure Python >= 3.9
* Update PostgreSQL and Python versions for tests
* Remove abandoned (for now) powerdns integration
  • Loading branch information
kofrezo committed Jul 19, 2023
1 parent 2b900ac commit 837b180
Show file tree
Hide file tree
Showing 30 changed files with 143 additions and 874 deletions.
3 changes: 0 additions & 3 deletions .docker/db/pdns-db.sql

This file was deleted.

12 changes: 0 additions & 12 deletions .docker/pdns-auth/Dockerfile

This file was deleted.

19 changes: 0 additions & 19 deletions .docker/pdns-auth/entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .docker/pdns-auth/pdns.conf

This file was deleted.

8 changes: 4 additions & 4 deletions .docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Pipenv seems to not work with bullseye (yet)
FROM python:3.7-buster
FROM python:3.9-bullseye

ENV PYTHONUNBUFFERED=1

COPY entrypoint.sh /

WORKDIR /code

RUN echo "deb http://apt.postgresql.org/pub/repos/apt buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt update && \
apt install -y pipenv postgresql-client-14
apt install -y postgresql-client-15 && \
pip3 install --upgrade pip pipenv

ENTRYPOINT ["/entrypoint.sh"]
15 changes: 7 additions & 8 deletions .docker/web/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source .env

# Install or update dependencies on every start in case something changed
pipenv install --dev
python3 -m pipenv install --dev

# Wait for database to be available before running migrations
until pg_isready -h "$POSTGRES_HOST" -U "$POSTGRES_USER" &> /dev/null; do
Expand All @@ -12,23 +12,22 @@ until pg_isready -h "$POSTGRES_HOST" -U "$POSTGRES_USER" &> /dev/null; do
done

# Apply pending migrations on every start
pipenv run python -m serveradmin migrate --no-input
pipenv run python -m serveradmin migrate --database=powerdns --no-input
python3 -m pipenv run python -m serveradmin migrate --no-input

# Requires Django >= 3.x
# pipenv run python -m serveradmin createsuper --no-input
pipenv run python -m serveradmin createdefaultuser
python3 -m pipenv run python -m serveradmin createdefaultuser

# Create default application
pipenv run python -m serveradmin createapp --non-interactive
python3 -m pipenv run python -m serveradmin createapp --non-interactive

echo -e "
********************************************************************************
\e[32m[TIPS]\e[39m
- Run 'docker-compose exec web /bin/bash' to access web service
- Run 'pipenv run python -m serveradmin -h' in web service to access django commands
- Run 'pipenv run python -m adminapi example.com' in web service to make adminapi queries
- Run 'python3 -m pipenv run python -m serveradmin -h' in web service to access django commands
- Run 'python3 -m pipenv run python -m adminapi example.com' in web service to make adminapi queries
\e[33mAccess serveradmin from your browser via:\e[39m
- URL: http://127.0.0.1:8000
Expand All @@ -39,4 +38,4 @@ echo -e "
"

# Start development server reachable for host machine
pipenv run python -m serveradmin runserver 0.0.0.0:8000
python3 -m pipenv run python -m serveradmin runserver 0.0.0.0:8000
9 changes: 0 additions & 9 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
POSTGRES_VERSION=14

# db service database settings
POSTGRES_DB=serveradmin
POSTGRES_USER=serveradmin
POSTGRES_PASSWORD=serveradmin
POSTGRES_HOST=db
POSTGRES_PORT=5432

# PowerDNS db service database settings
POSTGRES_POWERDNS_DB=powerdns
POSTGRES_POWERDNS_USER=powerdns
POSTGRES_POWERDNS_PASSWORD=powerdns
POSTGRES_POWERDNS_HOST=db
POSTGRES_POWERDNS_PORT=5432

# Credentials for default super user (requires Django >= 3.x)
DJANGO_SUPERUSER_USERNAME=serveradmin
DJANGO_SUPERUSER_EMAIL=serveradmin@example.com
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ jobs:
strategy:
matrix:
python:
- "3.7"
- "3.8"
- "3.9"
- "3.10"

services:
db:
image: 'postgres:14'
image: 'postgres:15'
env:
POSTGRES_USER: serveradmin
POSTGRES_PASSWORD: serveradmin
Expand All @@ -33,19 +31,6 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
pdns-db:
image: 'postgres:14'
env:
POSTGRES_USER: powerdns
POSTGRES_PASSWORD: powerdns
POSTGRES_DB: powerdns
ports:
- 5432/tcp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Setup python
Expand Down Expand Up @@ -73,18 +58,6 @@ jobs:
'client_encoding': 'UTF8',
},
},
'powerdns': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': '127.0.0.1',
'PORT': '${{ job.services.pdns-db.ports[5432] }}',
'NAME': 'powerdns',
'USER': 'powerdns',
'PASSWORD': 'powerdns',
'OPTIONS': {
'connect_timeout': 1,
'client_encoding': 'UTF8',
},
},
}
SECRET_KEY = 'TEST'
TIME_ZONE = 'Europe/Berlin'
Expand Down
6 changes: 5 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ django_compressor = "<3.0.0"
paramiko = "~=2.10"
pexpect = "<5.0.0"
rich = "*"
typing-extensions = "*"

[dev-packages]
# Used to build the sphinx docs
Expand All @@ -45,4 +46,7 @@ faker = "<14.0.0"
tblib = "*"

[requires]
python_version = "3.7"
python_version = "3.9"

[production]
sentry-sdk = {version = "*", extras = ["django"]}

0 comments on commit 837b180

Please sign in to comment.