Utility-DB-Postgres
A template repo for managing Postgres/postgis databases through Jenkins.
NOTE: The steps below are not for this repo, but for those using it as a template.
Bootstrapping
If needed, steps starting with
[sudo]require elevated permissions.
- Create a new repository by clicking the "Use this template" button on the template repo page.
- Configure the new repo settings. At the bottom, select
Template Items->Git Content. - Create the new repo.
- Pull new repo to local PC.
- [sudo] Give the setup script permission to execute:
chmod +x template/setup.sh - [sudo] Run the start script and fill in the prompts:
./template/setup.sh
Running Locally
This works only if the required files have been made during the bootstrap process.
- You need to have Docker locally installed
- From the repository root directory:
./start.sh - You should see a
datafolder pop up. This is where the local DB data is stored. - Verify you can connect with the default user
postgresand the password you provided.
Deploying
If you configured the Sciocatti Jenkins pipeline during bootstrap, deployment happens automatically on branch main.
The point is to serve as a GitOps "source of truth", so be wary when making changes as it will reflect.
These will be deployed to node ports on the cluster with ports as per the deployment.yaml specs in the cicd folder.
Due note that branches eligible for deployments are configured on the Jenkins server, as deployments happen transparently to developers.
Note that the bootstrapped repo has to be in a organization where the Jenkins user has visibility, and the organization must be configured and linked to the Jenkins server.
Note that you have to configure a Jenkins secret, reachable by the script when deploying. This secret ID must be passed in during the bootstrap process.
MultiArch images
For Mac M1 chips the standard postgis/postgis woooorks, but with warnings and without guarantees.
I prefer using the image from postgis/postgis, but unfortunately their image only supports AMD. This is a issue for Mac M-series chips, and Raspberry Pi 4s. A workaround I am using for both AMD and ARM support:
# Pull image from https://github.com/baosystems/docker-postgis/pkgs/container/postgis
docker pull ghcr.io/baosystems/postgis:11-3.3
# Retag to save to my own registry
docker tag ghcr.io/baosystems/postgis:11-3.3 192.168.195.195:30000/postgis:11-3.3
# Push to repo
docker push 192.168.195.195:30000/postgis:11-3.3
If you don't want to depend on baosystems, or if they don't support your version, then you should also be able to build the image for Arm yourself as per this suggestion
utils-postgres-stage-pwd