Files
Utility-DB-Postgres/README.md
2023-01-09 11:32:06 +02:00

63 lines
2.8 KiB
Markdown

# 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.
1. Create a new repository by clicking the "Use this template" button on the template repo page.
1. Configure the new repo settings. At the bottom, select `Template Items` -> `Git Content`.
1. Create the new repo.
1. Pull new repo to local PC.
1. [sudo] Give the setup script permission to execute:
```bash
chmod +x template/setup.sh
```
1. [sudo] Run the start script and fill in the prompts:
```bash
./template/setup.sh
```
## Running Locally
> This works only if the required files have been made during the bootstrap process.
1. You need to have Docker locally installed
1. From the repository root directory:
```bash
./start.sh
```
1. You should see a `data` folder pop up. This is where the local DB data is stored.
1. Verify you can connect with the default user `postgres` and 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:
```bash
# 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](https://github.com/postgis/docker-postgis/issues/216#issuecomment-809347656)
utils-postgres-stage-pwd