From 8e9acfacc31ea23b56e52897bf664edf65aa25ed Mon Sep 17 00:00:00 2001 From: Elliot Matson <1711604+elliotmatson@users.noreply.github.com> Date: Fri, 29 Jul 2022 14:09:45 -0500 Subject: [PATCH 01/36] Add pgadmin, clean up docker-compose Restructured cocker-compose to be cleaner --- docker-compose.yml | 64 +++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 154b9ce..def1779 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,29 @@ --- -version: '3' +version: '3.8' +x-common: + database: &db-environment + POSTGRES_DB: database + POSTGRES_USER: postgres + POSTGRES_PASSWORD: DaVinci + TZ: America/Chicago + POSTGRES_LOCATION: &db-location "???:/var/lib/postgresql/data" + backup: &backup-environment + SCHEDULE: "@daily" + BACKUP_KEEP_DAYS: 7 + BACKUP_KEEP_WEEKS: 4 + BACKUP_KEEP_MONTHS: 6 + BACKUP_LOCATION: &bk-location "???:/backups" + admin: &admin-environment + PGADMIN_DEFAULT_EMAIL: admin@admin.com + PGADMIN_DEFAULT_PASSWORD: root + #PGADMIN_CONFIG_DEFAULT_SERVER: postgres +# +# ------------------------------------------------------------------------------------------ +# DANGER ZONE BELOW +# +# The remainder of this file likely does not need to be changed. Please only make modifications +# below if you understand what you are doing. +# services: postgres: image: postgres:13 @@ -7,33 +31,27 @@ services: ports: - "5432:5432" environment: - - POSTGRES_DB=database - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=DaVinci - - TZ=America/Chicago + <<: [*db-environment] volumes: - - "resolve-db:/var/lib/postgresql/data" + - *db-location pgbackups: image: prodrigestivill/postgres-backup-local:13 restart: always volumes: - - "(location you want backups stored):/backups" + - *bk-location links: - postgres - depends_on: - - postgres environment: - - POSTGRES_HOST=postgres - - POSTGRES_DB=database - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=DaVinci - - POSTGRES_EXTRA_OPTS=--blobs --format=custom --quote-all-identifiers - - BACKUP_SUFFIX=.backup - - SCHEDULE=@daily - - BACKUP_KEEP_DAYS=7 - - BACKUP_KEEP_WEEKS=4 - - BACKUP_KEEP_MONTHS=6 - - HEALTHCHECK_PORT=8080 - - TZ=America/Chicago -volumes: - resolve-db: + <<: [*db-environment, *backup-environment] + POSTGRES_HOST: postgres + POSTGRES_EXTRA_OPTS: --blobs --format=custom --quote-all-identifiers + BACKUP_SUFFIX: .backup + HEALTHCHECK_PORT: 8080 + pgadmin: + container_name: pgadmin4_container + image: dpage/pgadmin4 + restart: always + environment: + <<: [*admin-environment] + ports: + - "6969:80" From d241924323815264b88b6cfb6e5ed7fbd002d720 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 16:23:29 -0500 Subject: [PATCH 02/36] Update readme to match compose updates --- README.md | 135 +++++++++++++++++++++------------------------ docker-compose.yml | 4 +- 2 files changed, 64 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 6491010..a2b544e 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,16 @@ Simple Resolve project server with automatic backups - [Introduction](#introduction) - [Features](#features) - [Configuration](#configuration) - - [PostgreSQL Server](#postgresql-server) - - [Backup Server](#backup-server) + - [Database](#database) + - [Backups](#backups) + - [PGAdmin](#pgadmin) + - [Volume Locations](#volume-locations) - [Installation](#installation) - [QNAP Installation](#qnap-installation) - [Synology](#synology) - [Linux](#linux) - [Different PostgreSQL versions](#different-postgresql-versions) - - [Setting up a PostgreSQL 11 Project Server](#setting-up-a-postgresql-11-project-server) - - [Using PostgreSQL 11 on Windows](#using-postgresql-11-on-windows) - - [Using PostgreSQL 11 on Mac](#using-postgresql-11-on-mac) + - [Setting up a PostgreSQL 9.5 or 11 Project Server](#setting-up-a-postgresql-95-or-11-project-server) - [Thanks](#thanks) ## Introduction @@ -27,83 +27,72 @@ There are a lot of ways to host a Resolve project server, but each of them has t - **Lightweight** - Docker based, so doesn't require a full macOS or Windows machine or VM. - **Platform Independent** - can be installed on Windows, Mac, Linux, QNAP, Synology, RPi, really anything that can run Docker. - **Compatible with Resolve's existing backup/restore functions** - All backup files use the standard Resolve *.backup file syntax, and can be restored from the Resolve UI +- **Built-in PGAdmin Server** - PGAdmin is a tool for administering a PostgreSQL Server, and is helpful for diagnosing problems and migrating/updating entire servers ## Configuration -There are a few things we'll need to edit in the docker-compose.yml file to configure our installation: -### PostgreSQL Server +There are a few things we'll need to edit at the top of the docker-compose.yml file to configure our installation: +```yaml +--- +version: '3.8' +x-common: + database: &db-environment + POSTGRES_DB: database + POSTGRES_USER: postgres + POSTGRES_PASSWORD: DaVinci + TZ: America/Chicago + POSTGRES_LOCATION: &db-location "???:/var/lib/postgresql/data" + backup: &backup-environment + SCHEDULE: "@daily" + BACKUP_KEEP_DAYS: 7 + BACKUP_KEEP_WEEKS: 4 + BACKUP_KEEP_MONTHS: 6 + BACKUP_LOCATION: &bk-location "???:/backups" + admin: &admin-environment + PGADMIN_DEFAULT_EMAIL: admin@admin.com + PGADMIN_DEFAULT_PASSWORD: root + PGADMIN_PORT: &pgadmin-port "3001:80" +... +``` + +### Database To configure the server itself, we'll want to configure the environment variables below: -```yaml -... -services: - postgres: - ... - environment: - - POSTGRES_DB=database - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=DaVinci - - TZ=America/Chicago - ... -... -``` | Environment Variable |Meaning| |---|---| -| POSTGRES_DB | This is the name of your database. Name it whatever you like. | -| POSTGRES_USER | This is the username you will use to connect to your database. The Resolve default is "postgres" | -| POSTGRES_PASSWORD | This is the password you will use to connect to your database. The Resolve default is "DaVinci" | -| TZ | This is your timezone, here is [a list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)| +| POSTGRES_DB | Nme of your database. Name it whatever you like. | +| POSTGRES_USER | Username you will use to connect to your database. The Resolve default is "postgres" | +| POSTGRES_PASSWORD | Password you will use to connect to your database. The Resolve default is "DaVinci" | +| TZ | Your timezone, here is [a list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)| +| POSTGRES_LOCATION | Location your database will be stored. See [Volume Locations](###Volume-Locations) | -### Backup Server +### Backups To configure the backups, we'll want to configure the variables below: -```yaml -... -services: - ... - pgbackups: - ... - volumes: - - "(Whatever location you want backups stored):/backups" - ... - environment: - - POSTGRES_HOST=postgres - - POSTGRES_DB=database - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=DaVinci - - POSTGRES_EXTRA_OPTS=--blobs --format=custom --quote-all-identifiers - - BACKUP_SUFFIX=.backup - - SCHEDULE=@daily - - BACKUP_KEEP_DAYS=7 - - BACKUP_KEEP_WEEKS=4 - - BACKUP_KEEP_MONTHS=6 - - HEALTHCHECK_PORT=8080 - - TZ=America/Chicago - ... -... -``` -First, we will want to decide on a backup location and edit the ```volumes:``` section. You will need the full path to the folder you want backups stored in. On a QNAP NAS for example, if I wanted to use a folder called "Backups" inside a shared folder named "Videos", the path would be ```/shares/Videos/Backups/```, and my ```volumes:``` section would look like this: -```yaml -volumes: - - "/shares/Videos/Backups:/backups" -``` - On Ubuntu, if I wanted to use a folder named "Backups" in the home directory of the user named "johndoe", the path would be ```/home/johndoe/Backups/```, and my ```volumes:``` section would look like this: -```yaml -volumes: - - "/home/johndoe/Backups:/backups" -``` - - - - -There are also some variables in the environment section. Many of these don't need to be edited, but here are the ones you might want to change: | Environment Variable |Meaning| |---|---| -| POSTGRES_DB | This is the name of the database from the previous step. Can also be a comma/space separated list of database names if you create more in the future | -| POSTGRES_USER | This is the database username from the previous step | -| POSTGRES_PASSWORD | This is the database password from the previous step | -| SCHEDULE | This is a [cron string](https://www.freeformatter.com/cron-expression-generator-quartz.html) for how often backups are created. can be "@daily", "@every 1h", etc | -| BACKUP_KEEP_DAYS | Number of daily backups to keep before removal. -| BACKUP_KEEP_WEEKS | Number of weekly backups to keep before removal. -| BACKUP_KEEP_MONTHS | Number of daily backups to keep before removal. -| TZ | This is your timezone, here is [a list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)| +| SCHEDULE | This is a [cron string](https://www.freeformatter.com/cron-expression-generator-quartz.html) for how often backups are created. can be "@daily", "@every 1h", etc | +| BACKUP_KEEP_DAYS | Number of daily backups to keep before removal. | +| BACKUP_KEEP_WEEKS | Number of weekly backups to keep before removal. | +| BACKUP_KEEP_MONTHS | Number of daily backups to keep before removal. | +| BACKUP_LOCATION | Location your backups will be stored. See [Volume Locations](###Volume-Locations) | + +### PGAdmin +To configure PGAdmin, we'll want to configure the variables below: +| Environment Variable |Meaning| +|---|---| +| PGADMIN_DEFAULT_EMAIL | Email used for PGAdmin login. Default is "admin@admin.com" | +| PGADMIN_DEFAULT_PASSWORD | Password used for PGAdmin login. Default is "root" | +| PGADMIN_PORT | String configuring port to expose PGAdmin on. Syntax is "YOUR_PORT:80" | + +### Volume Locations +The location of your database and backups depend on what platform you are installing on. You will need the full path to the folder you want them stored in. On a QNAP NAS for example, if I wanted to use a folder called "Backups" inside a shared folder named "Videos" for my backups location, the path would be ```/shares/Videos/Backups/```, and my ```BACKUP_LOCATION``` value would look like this: +```yaml +BACKUP_LOCATION: &bk-location "/shares/Videos/Backups/:/backups" +``` + On Ubuntu, if I wanted to use a folder named "database" in the home directory of the user named "johndoe" for my database location, the path would be ```/home/johndoe/database/```, and my ```POSTGRES_LOCATION``` value would look like this: +```yaml +POSTGRES_LOCATION: &db-location "johndoe/database/:/var/lib/postgresql/data" +``` + +I recommend putting your database on an SSD, your access speed will be noticeably slower on a spinning drive. Once you have configured these settings, save your modified docker-compose.yml file and move on to installation! diff --git a/docker-compose.yml b/docker-compose.yml index def1779..24d9a24 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ x-common: admin: &admin-environment PGADMIN_DEFAULT_EMAIL: admin@admin.com PGADMIN_DEFAULT_PASSWORD: root - #PGADMIN_CONFIG_DEFAULT_SERVER: postgres + PGADMIN_PORT: &pgadmin-port "3001:80" # # ------------------------------------------------------------------------------------------ # DANGER ZONE BELOW @@ -54,4 +54,4 @@ services: environment: <<: [*admin-environment] ports: - - "6969:80" + - *pgadmin-port From 19f9f58630b5e969432ccb75b9986f0eb9712eee Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 16:25:58 -0500 Subject: [PATCH 03/36] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2b544e..c0ce524 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ To configure the server itself, we'll want to configure the environment variable | POSTGRES_USER | Username you will use to connect to your database. The Resolve default is "postgres" | | POSTGRES_PASSWORD | Password you will use to connect to your database. The Resolve default is "DaVinci" | | TZ | Your timezone, here is [a list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)| -| POSTGRES_LOCATION | Location your database will be stored. See [Volume Locations](###Volume-Locations) | +| POSTGRES_LOCATION | Location your database will be stored. See [Volume Locations](#volume-locations) | ### Backups To configure the backups, we'll want to configure the variables below: @@ -72,7 +72,7 @@ To configure the backups, we'll want to configure the variables below: | BACKUP_KEEP_DAYS | Number of daily backups to keep before removal. | | BACKUP_KEEP_WEEKS | Number of weekly backups to keep before removal. | | BACKUP_KEEP_MONTHS | Number of daily backups to keep before removal. | -| BACKUP_LOCATION | Location your backups will be stored. See [Volume Locations](###Volume-Locations) | +| BACKUP_LOCATION | Location your backups will be stored. See [Volume Locations](#volume-locations) | ### PGAdmin To configure PGAdmin, we'll want to configure the variables below: From d395bb4f390f752c5a2c969f8a320b20d477ebd9 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 16:43:49 -0500 Subject: [PATCH 04/36] Add healthchecks to postgres and pgadmin --- docker-compose.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 24d9a24..364f25c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,11 @@ services: <<: [*db-environment] volumes: - *db-location + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 pgbackups: image: prodrigestivill/postgres-backup-local:13 restart: always @@ -55,3 +60,5 @@ services: <<: [*admin-environment] ports: - *pgadmin-port + healthcheck: + test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost/ || exit 1"] From e0388c058586c79f4f5c851e364e420ff7a9bd91 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 16:51:54 -0500 Subject: [PATCH 05/36] Update dependabot --- .github/dependabot.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 393290f..4ab9a3d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,14 +5,9 @@ version: 2 updates: - - package-ecosystem: "docker" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "github-actions" + directory: "/" assignees: - Elliot Matson schedule: interval: "daily" - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" From 9e4e2955610aac90941b9dda12f67bda14afe0d7 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:14:20 -0500 Subject: [PATCH 06/36] Adding Actions workflow to test stack --- .github/workflows/lint.yml | 2 -- .github/workflows/stack-healthcheck.yml | 19 +++++++++++++++++++ docker-compose.yml | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/stack-healthcheck.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0bc142a..e6dd1de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,9 +10,7 @@ jobs: run-lint: name: Lint runs-on: ubuntu-latest - steps: - - name: Check out the codebase. uses: actions/checkout@v3 with: diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml new file mode 100644 index 0000000..f275987 --- /dev/null +++ b/.github/workflows/stack-healthcheck.yml @@ -0,0 +1,19 @@ +--- +name: Stack Healthcheck +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + name: Test Stack + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Deploy the stack + run: docker-compose up -d + + - name: Test PGAdmin + run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 364f25c..da78114 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,13 +6,13 @@ x-common: POSTGRES_USER: postgres POSTGRES_PASSWORD: DaVinci TZ: America/Chicago - POSTGRES_LOCATION: &db-location "???:/var/lib/postgresql/data" + POSTGRES_LOCATION: &db-location "~/db:/var/lib/postgresql/data" backup: &backup-environment SCHEDULE: "@daily" BACKUP_KEEP_DAYS: 7 BACKUP_KEEP_WEEKS: 4 BACKUP_KEEP_MONTHS: 6 - BACKUP_LOCATION: &bk-location "???:/backups" + BACKUP_LOCATION: &bk-location "~/backups:/backups" admin: &admin-environment PGADMIN_DEFAULT_EMAIL: admin@admin.com PGADMIN_DEFAULT_PASSWORD: root From ad44d84acf9699e403c1e8e0db1a965fff808567 Mon Sep 17 00:00:00 2001 From: Elliot Matson <1711604+elliotmatson@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:20:24 -0500 Subject: [PATCH 07/36] Update stack-healthcheck.yml --- .github/workflows/stack-healthcheck.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index f275987..cc7ea38 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -2,9 +2,8 @@ name: Stack Healthcheck on: push: - branches: [main] pull_request: - branches: [main] + workflow_dispatch: jobs: test: @@ -16,4 +15,4 @@ jobs: run: docker-compose up -d - name: Test PGAdmin - run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ \ No newline at end of file + run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ From 12f52289bc12676530ad860b22c242d989db85af Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:26:30 -0500 Subject: [PATCH 08/36] name containers --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index da78114..1a91daa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,7 @@ x-common: # services: postgres: + container_name: resolve_pgsql image: postgres:13 restart: always ports: @@ -40,6 +41,7 @@ services: timeout: 5s retries: 5 pgbackups: + container_name: resolve_pgbackup image: prodrigestivill/postgres-backup-local:13 restart: always volumes: @@ -53,7 +55,7 @@ services: BACKUP_SUFFIX: .backup HEALTHCHECK_PORT: 8080 pgadmin: - container_name: pgadmin4_container + container_name: resolve_pgadmin4 image: dpage/pgadmin4 restart: always environment: From bdb951535dbf4ee835e7c3cb08d44f74f13a0ced Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:27:22 -0500 Subject: [PATCH 09/36] name containers --- .github/workflows/stack-healthcheck.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index f275987..a55e56a 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -16,4 +16,4 @@ jobs: run: docker-compose up -d - name: Test PGAdmin - run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ \ No newline at end of file + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1a91daa..574898a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,7 @@ services: BACKUP_SUFFIX: .backup HEALTHCHECK_PORT: 8080 pgadmin: - container_name: resolve_pgadmin4 + container_name: resolve_pgadmin image: dpage/pgadmin4 restart: always environment: From 8d5c7c2b7a2859846a9ae1d538b41f292c785432 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:31:06 -0500 Subject: [PATCH 10/36] update status action --- .github/workflows/stack-healthcheck.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index ec7c831..1d8a4d1 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -15,4 +15,7 @@ jobs: run: docker-compose up -d - name: Test PGAdmin - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ \ No newline at end of file + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ + + - name: Test PGAdmin + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/ \ No newline at end of file From 575073fb82f18d96717268717394ab166e43a003 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:32:27 -0500 Subject: [PATCH 11/36] update action --- .github/workflows/stack-healthcheck.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 1d8a4d1..9365db5 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -14,8 +14,5 @@ jobs: - name: Deploy the stack run: docker-compose up -d - - name: Test PGAdmin - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3001/ - - name: Test PGAdmin run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/ \ No newline at end of file From 7d2b05506548d646203bf03e0705ec154779e7ac Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:41:36 -0500 Subject: [PATCH 12/36] update action --- .github/workflows/stack-healthcheck.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 9365db5..9b41ba9 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -15,4 +15,10 @@ jobs: run: docker-compose up -d - name: Test PGAdmin - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/ \ No newline at end of file + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/ + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} + with: + limit-access-to-actor: true \ No newline at end of file From ef263f475ff028f7a4488f88bb547df722cdaaf2 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:47:11 -0500 Subject: [PATCH 13/36] update action --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 9b41ba9..17ab389 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -14,7 +14,7 @@ jobs: - name: Deploy the stack run: docker-compose up -d - - name: Test PGAdmin + - name: Test PGAdmin container run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/ - name: Setup tmate session From a4115667aad496c3a68f1e3bbfb1812000fe8ea1 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:50:55 -0500 Subject: [PATCH 14/36] update action --- .github/workflows/stack-healthcheck.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 17ab389..4060985 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -19,6 +19,4 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - if: ${{ failure() }} - with: - limit-access-to-actor: true \ No newline at end of file + if: ${{ failure() }} \ No newline at end of file From c45aca589b0141c69d08e83b8adfced161d59ee4 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 17:55:41 -0500 Subject: [PATCH 15/36] update action --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 4060985..345a9ed 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -15,7 +15,7 @@ jobs: run: docker-compose up -d - name: Test PGAdmin container - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/ + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/login - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From d9a9d75f501fdc8486a8d478269effe2c5b28f18 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 18:07:37 -0500 Subject: [PATCH 16/36] test curl --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 345a9ed..83b027d 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -15,7 +15,7 @@ jobs: run: docker-compose up -d - name: Test PGAdmin container - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://localhost/login + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://google.com - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 0e1142c6e8722de6f307997bb50bdebdf428a69c Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 18:14:58 -0500 Subject: [PATCH 17/36] test curl --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 83b027d..c9da92f 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -15,7 +15,7 @@ jobs: run: docker-compose up -d - name: Test PGAdmin container - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-connrefused http://google.com + run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-delay 1 --retry-connrefused http://localhost/ - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 83f2f61f06aacfa90fda5a1d673f7d55d50fa5ca Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 18:16:29 -0500 Subject: [PATCH 18/36] test curl --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index c9da92f..2c18442 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -15,7 +15,7 @@ jobs: run: docker-compose up -d - name: Test PGAdmin container - run: docker run --network container:resolve_pgadmin appropriate/curl -s --retry 10 --retry-delay 1 --retry-connrefused http://localhost/ + run: docker run --network container:resolve_pgadmin appropriate/curl --retry 10 --retry-delay 1 --retry-connrefused http://localhost/ - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 2f0e7c48679e909e246660dc310728ca342d8c5a Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 18:39:56 -0500 Subject: [PATCH 19/36] test action --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 2c18442..e0f3d38 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -14,7 +14,7 @@ jobs: - name: Deploy the stack run: docker-compose up -d - - name: Test PGAdmin container + - name: Test PGAdmin run: docker run --network container:resolve_pgadmin appropriate/curl --retry 10 --retry-delay 1 --retry-connrefused http://localhost/ - name: Setup tmate session From 77b058f671c0cfdbd61cf84630519fb16f49a037 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 19:07:03 -0500 Subject: [PATCH 20/36] test actions --- .github/workflows/stack-healthcheck.yml | 5 +---- docker-compose.yml | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index e0f3d38..3fd822c 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -12,10 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Deploy the stack - run: docker-compose up -d - - - name: Test PGAdmin - run: docker run --network container:resolve_pgadmin appropriate/curl --retry 10 --retry-delay 1 --retry-connrefused http://localhost/ + run: timeout 5 docker-compose up -d - name: Setup tmate session uses: mxschmitt/action-tmate@v3 diff --git a/docker-compose.yml b/docker-compose.yml index 574898a..525e3ce 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,7 +46,7 @@ services: restart: always volumes: - *bk-location - links: + depends_on: - postgres environment: <<: [*db-environment, *backup-environment] @@ -54,6 +54,8 @@ services: POSTGRES_EXTRA_OPTS: --blobs --format=custom --quote-all-identifiers BACKUP_SUFFIX: .backup HEALTHCHECK_PORT: 8080 + healthcheck: + interval: 30s pgadmin: container_name: resolve_pgadmin image: dpage/pgadmin4 @@ -62,5 +64,7 @@ services: <<: [*admin-environment] ports: - *pgadmin-port + depends_on: + - postgres healthcheck: test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost/ || exit 1"] From 0293cf6377faec56e0b1901d702e4d3445f813a5 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 19:08:44 -0500 Subject: [PATCH 21/36] update action --- .github/workflows/stack-healthcheck.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 3fd822c..56c6bf0 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -12,8 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Deploy the stack - run: timeout 5 docker-compose up -d + run: timeout 120 docker-compose up -d - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ failure() }} \ No newline at end of file + uses: mxschmitt/action-tmate@v3 \ No newline at end of file From ec6c6b1e4fed7c92c69a8c5e74dcf07c6c239d7f Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 19:10:12 -0500 Subject: [PATCH 22/36] fix action --- .github/workflows/stack-healthcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index 56c6bf0..ef5c5d4 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Deploy the stack - run: timeout 120 docker-compose up -d + run: timeout 120 docker-compose up --wait - name: Setup tmate session uses: mxschmitt/action-tmate@v3 \ No newline at end of file From ba0c476813c55cb52ff2ad920080eb56a237c8a5 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 19:11:20 -0500 Subject: [PATCH 23/36] fix action again --- .github/workflows/stack-healthcheck.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index ef5c5d4..b066b6b 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Deploy the stack - run: timeout 120 docker-compose up --wait + - name: Deploy the stack, timeout if not healthy after 2m + run: timeout 120 docker compose up --wait - name: Setup tmate session uses: mxschmitt/action-tmate@v3 \ No newline at end of file From 01e8633f12fcfcfe51636067fff8ce7e56856a16 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 19:22:52 -0500 Subject: [PATCH 24/36] add checks to action --- .github/workflows/stack-healthcheck.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index b066b6b..dfd393f 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -13,6 +13,9 @@ jobs: - uses: actions/checkout@v3 - name: Deploy the stack, timeout if not healthy after 2m run: timeout 120 docker compose up --wait - - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 \ No newline at end of file + - name: Check creating database + run: docker compose logs | grep "CREATE DATABASE" + - name: Check database creation + run: docker compose logs | grep "Success. You can now start the database server" + - name: Check postgres init + run: docker compose logs | grep "PostgreSQL init process complete; ready for start up." \ No newline at end of file From 6f6e9012e49bace3df5b104f2dbafa6ae836fb2e Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 22:13:47 -0500 Subject: [PATCH 25/36] Add pgadmin config generator container --- pgadmin-config-creator/Dockerfile | 6 ++++++ pgadmin-config-creator/app.py | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 pgadmin-config-creator/Dockerfile create mode 100644 pgadmin-config-creator/app.py diff --git a/pgadmin-config-creator/Dockerfile b/pgadmin-config-creator/Dockerfile new file mode 100644 index 0000000..779a0e2 --- /dev/null +++ b/pgadmin-config-creator/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.8-alpine +RUN mkdir /app +RUN mkdir /config +ADD . /app +WORKDIR /app +CMD ["python", "app.py"] \ No newline at end of file diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py new file mode 100644 index 0000000..f3cc057 --- /dev/null +++ b/pgadmin-config-creator/app.py @@ -0,0 +1,10 @@ +import json +import os + +with open('/config/servers.json', 'w') as f: + print("created " + f.name) + template_string = '{"Servers": {"1": {"Name": "DavinciResolve", "Group": "Servers", "Port": 5432, "Username": "postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' + data = json.loads(template_string) + data["Servers"]["1"]["Username"]=os.getenv("POSTGRES_USER") + print(data) + json.dump(data, f, indent=2) \ No newline at end of file From fcc97a6c1ae921cf9e6b84acb8048b29e10e9a69 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 22:48:39 -0500 Subject: [PATCH 26/36] new structure --- .github/workflows/docker.yml | 51 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 14 ++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..f2690a6 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,51 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Create and publish a Docker image + +on: + push: + branches: ['release', 'dev'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: pgadmin-config-creator + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: ./pgadmin-config-creator + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 525e3ce..88db8cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -64,7 +64,21 @@ services: <<: [*admin-environment] ports: - *pgadmin-port + volumes: + - pgadmin-config/servers.json:/pgadmin4/servers.json:ro depends_on: - postgres + - pgadmin-config healthcheck: test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost/ || exit 1"] + pgadmin-config: + container_name: resolve_pgadmin-config-creator + image: ghcr.io/elliotmatson/pgadmin-config-creator:latest + restart: always + environment: + <<: [*db-environment] + volumes: + - pgadmin-config:/config + +volumes: + pgadmin-config: From ef490eae1bf369b2955c6b85a7efc50b79138fad Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 22:51:38 -0500 Subject: [PATCH 27/36] test actions --- .github/workflows/docker.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f2690a6..bf9ea43 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,6 +27,12 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 From 985bed2612adb1f8569d9be831186159c0244a28 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 22:53:34 -0500 Subject: [PATCH 28/36] test again --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bf9ea43..fed4d8c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,7 +15,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: pgadmin-config-creator + IMAGE_NAME: elliotmatson/pgadmin-config-creator jobs: build-and-push-image: From 346976c19da682e5539b1d5ac77568e6abc67e83 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 22:58:43 -0500 Subject: [PATCH 29/36] test again --- .github/workflows/docker.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fed4d8c..011b881 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -46,6 +46,11 @@ jobs: uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc From fd1d660dda67b4010f8148e960e5f3e03e167a92 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 23:02:17 -0500 Subject: [PATCH 30/36] fix docker compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 88db8cb..f3aedfb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -65,7 +65,7 @@ services: ports: - *pgadmin-port volumes: - - pgadmin-config/servers.json:/pgadmin4/servers.json:ro + - pgadmin-config:/pgadmin4 depends_on: - postgres - pgadmin-config From e61a1e5345ad087eccb5fe2428ebf06b1cfd671e Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 23:13:15 -0500 Subject: [PATCH 31/36] remove restart from config container --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f3aedfb..e22b9f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,7 +74,7 @@ services: pgadmin-config: container_name: resolve_pgadmin-config-creator image: ghcr.io/elliotmatson/pgadmin-config-creator:latest - restart: always + restart: on-failure environment: <<: [*db-environment] volumes: From 52802f754bd1f2f7bcc6e5b34950aa0ba06de442 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 23:31:17 -0500 Subject: [PATCH 32/36] fix healthcheck --- .github/workflows/stack-healthcheck.yml | 2 +- pgadmin-config-creator/Dockerfile | 3 ++- pgadmin-config-creator/app.py | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stack-healthcheck.yml b/.github/workflows/stack-healthcheck.yml index dfd393f..28091ca 100644 --- a/.github/workflows/stack-healthcheck.yml +++ b/.github/workflows/stack-healthcheck.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Deploy the stack, timeout if not healthy after 2m - run: timeout 120 docker compose up --wait + run: timeout 120 docker compose up --quiet-pull --wait - name: Check creating database run: docker compose logs | grep "CREATE DATABASE" - name: Check database creation diff --git a/pgadmin-config-creator/Dockerfile b/pgadmin-config-creator/Dockerfile index 779a0e2..f328f4d 100644 --- a/pgadmin-config-creator/Dockerfile +++ b/pgadmin-config-creator/Dockerfile @@ -3,4 +3,5 @@ RUN mkdir /app RUN mkdir /config ADD . /app WORKDIR /app -CMD ["python", "app.py"] \ No newline at end of file +CMD ["python", "app.py"] +HEALTHCHECK CMD test -f /config/servers.json || exit 1 \ No newline at end of file diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py index f3cc057..4fcf492 100644 --- a/pgadmin-config-creator/app.py +++ b/pgadmin-config-creator/app.py @@ -1,10 +1,15 @@ import json import os +import time with open('/config/servers.json', 'w') as f: print("created " + f.name) template_string = '{"Servers": {"1": {"Name": "DavinciResolve", "Group": "Servers", "Port": 5432, "Username": "postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' data = json.loads(template_string) data["Servers"]["1"]["Username"]=os.getenv("POSTGRES_USER") + print("printing json to file...") print(data) - json.dump(data, f, indent=2) \ No newline at end of file + json.dump(data, f, indent=2) +# sleep until GHA Healthchecks are complete +time.sleep(125) + From a9bd2416631fee3c717eaca7d490692ba52d4db9 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 23:47:06 -0500 Subject: [PATCH 33/36] Fix linting --- .github/dependabot.yml | 1 + .github/workflows/docker.yml | 4 +++- pgadmin-config-creator/Dockerfile | 5 ++--- pgadmin-config-creator/app.py | 10 ++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4ab9a3d..0dc5e09 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,4 @@ +--- # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 011b881..f05b797 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,3 +1,4 @@ +--- # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support @@ -5,7 +6,8 @@ # GitHub recommends pinning actions to a commit SHA. # To get a newer version, you will need to update the SHA. -# You can also reference a tag or branch, but the action may change without warning. +# You can also reference a tag or branch, +# but the action may change without warning. name: Create and publish a Docker image diff --git a/pgadmin-config-creator/Dockerfile b/pgadmin-config-creator/Dockerfile index f328f4d..0293dce 100644 --- a/pgadmin-config-creator/Dockerfile +++ b/pgadmin-config-creator/Dockerfile @@ -1,7 +1,6 @@ FROM python:3.8-alpine -RUN mkdir /app -RUN mkdir /config -ADD . /app +RUN mkdir -p /{app,config} +COPY . /app WORKDIR /app CMD ["python", "app.py"] HEALTHCHECK CMD test -f /config/servers.json || exit 1 \ No newline at end of file diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py index 4fcf492..32b7d0f 100644 --- a/pgadmin-config-creator/app.py +++ b/pgadmin-config-creator/app.py @@ -4,12 +4,14 @@ import time with open('/config/servers.json', 'w') as f: print("created " + f.name) - template_string = '{"Servers": {"1": {"Name": "DavinciResolve", "Group": "Servers", "Port": 5432, "Username": "postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' + template_string = ('{"Servers": {"1": {"Name": "DavinciResolve", ' + '"Group": "Servers", "Port": 5432, "Username": '' + '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' + ) data = json.loads(template_string) - data["Servers"]["1"]["Username"]=os.getenv("POSTGRES_USER") + data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER") print("printing json to file...") print(data) json.dump(data, f, indent=2) # sleep until GHA Healthchecks are complete -time.sleep(125) - +time.sleep(125) \ No newline at end of file From 7d44729c6ed111a8431a801eb4ff3955cbb170b3 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 23:51:28 -0500 Subject: [PATCH 34/36] fix linting (again) --- pgadmin-config-creator/Dockerfile | 3 ++- pgadmin-config-creator/app.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pgadmin-config-creator/Dockerfile b/pgadmin-config-creator/Dockerfile index 0293dce..22739a4 100644 --- a/pgadmin-config-creator/Dockerfile +++ b/pgadmin-config-creator/Dockerfile @@ -1,5 +1,6 @@ FROM python:3.8-alpine -RUN mkdir -p /{app,config} +RUN mkdir /app +RUN mkdir /config COPY . /app WORKDIR /app CMD ["python", "app.py"] diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py index 32b7d0f..458d06b 100644 --- a/pgadmin-config-creator/app.py +++ b/pgadmin-config-creator/app.py @@ -5,7 +5,7 @@ import time with open('/config/servers.json', 'w') as f: print("created " + f.name) template_string = ('{"Servers": {"1": {"Name": "DavinciResolve", ' - '"Group": "Servers", "Port": 5432, "Username": '' + '"Group": "Servers", "Port": 5432, "Username": ' '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' ) data = json.loads(template_string) From c75fc233feb511f3ce1d421eb378009b440d1dee Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Fri, 29 Jul 2022 23:56:28 -0500 Subject: [PATCH 35/36] 3rd time's the charm --- pgadmin-config-creator/app.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py index 458d06b..606e7c3 100644 --- a/pgadmin-config-creator/app.py +++ b/pgadmin-config-creator/app.py @@ -2,12 +2,13 @@ import json import os import time -with open('/config/servers.json', 'w') as f: +with open("/config/servers.json", "w") as f: print("created " + f.name) - template_string = ('{"Servers": {"1": {"Name": "DavinciResolve", ' - '"Group": "Servers", "Port": 5432, "Username": ' - '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' - ) + template_string = ( + '{"Servers": {"1": {"Name": "DavinciResolve", ' + '"Group": "Servers", "Port": 5432, "Username": ' + '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' + ) data = json.loads(template_string) data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER") print("printing json to file...") From 26600ee69ad287f863e59d1a0091395ce16d48e0 Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Sat, 30 Jul 2022 00:00:03 -0500 Subject: [PATCH 36/36] update compose --- docker-compose.yml | 3 ++- pgadmin-config-creator/app.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e22b9f8..3064056 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,8 @@ x-common: # ------------------------------------------------------------------------------------------ # DANGER ZONE BELOW # -# The remainder of this file likely does not need to be changed. Please only make modifications +# The remainder of this file likely does not need to be changed. +# Please only make modifications # below if you understand what you are doing. # services: diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py index 606e7c3..9cd2048 100644 --- a/pgadmin-config-creator/app.py +++ b/pgadmin-config-creator/app.py @@ -15,4 +15,4 @@ with open("/config/servers.json", "w") as f: print(data) json.dump(data, f, indent=2) # sleep until GHA Healthchecks are complete -time.sleep(125) \ No newline at end of file +time.sleep(125)