From 70ae93c1406d236e25274548e89a53f0db66ae72 Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Tue, 19 Nov 2024 16:42:30 +0200 Subject: [PATCH 1/6] fix: build context --- compose.yml | 3 +++ pgpool2/Dockerfile | 2 +- postgres/Dockerfile | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compose.yml b/compose.yml index 05dad22..834c2d6 100644 --- a/compose.yml +++ b/compose.yml @@ -11,6 +11,7 @@ x-base: services: primary: <<: *base + image: ghcr.io/withlogicco/postgres/primary build: context: postgres target: primary @@ -19,6 +20,7 @@ services: secondary: <<: *base + image: ghcr.io/withlogicco/postgres/secondary build: context: postgres target: secondary @@ -27,6 +29,7 @@ services: - secondary_data:/var/lib/postgresql/data pgpool2: + image: ghcr.io/withlogicco/postgres/pgpool2 build: context: pgpool2 secrets: diff --git a/pgpool2/Dockerfile b/pgpool2/Dockerfile index f47c5ad..0cef110 100644 --- a/pgpool2/Dockerfile +++ b/pgpool2/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 as pgpool +FROM ubuntu:22.04 AS pgpool # https://www.pgpool.net/mediawiki/index.php/Apt_Repository diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 01c6a91..659d9c6 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,14 +1,14 @@ -FROM postgres:16.2 as base +FROM postgres:16.2 AS base -FROM base as primary +FROM base AS primary -COPY ./postgres/primary/docker-entrypoint-initdb.d/ docker-entrypoint-initdb.d/ +COPY ./primary/docker-entrypoint-initdb.d/ docker-entrypoint-initdb.d/ -FROM base as secondary +FROM base AS secondary -COPY ./postgres/secondary/bin/ /usr/local/bin/ +COPY ./secondary/bin/ /usr/local/bin/ ENTRYPOINT [ "docker-entrypoint-override.sh" ] CMD ["postgres"] From 024a0c4fb408c4ba702b8ecefcd4be2e9d7fd6fb Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Tue, 19 Nov 2024 16:49:47 +0200 Subject: [PATCH 2/6] ci: push stack --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..174d6b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +on: push + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - run: docker compose alpha publish ghcr.io/withlogicco/postgres + + config: + needs: publish + runs-on: ubuntu-latest + env: + COMPOSE_EXPERIMENTAL_OCI_REMOTE: "1" + steps: + - uses: actions/checkout@v4 + - run: docker info + - run: docker compose version + - run: docker compose config --no-normalize + - run: docker compose alpha viz --image --indentation-size=4 --networks --ports --spaces From a3e6999dbb3524e9cf69dd260bdc3da01fea5f1c Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Tue, 19 Nov 2024 16:53:57 +0200 Subject: [PATCH 3/6] ci: build before publish --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 174d6b3..db41ea6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,8 @@ on: push jobs: publish: runs-on: ubuntu-latest + env: + COMPOSE_EXPERIMENTAL_OCI_REMOTE: "1" steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 @@ -11,6 +13,7 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - run: docker compose build --push - run: docker compose alpha publish ghcr.io/withlogicco/postgres config: From 80560715bc2df70d328461de6b333fd19031f02c Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Tue, 19 Nov 2024 16:58:32 +0200 Subject: [PATCH 4/6] ci: grant access --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db41ea6..cd79a45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,12 @@ on: push +permissions: + id-token: write + contents: write + issues: write + pull-requests: write + packages: write + jobs: publish: runs-on: ubuntu-latest From 828ef8bed64139e69d185dd1f9ff7535c890cc9b Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Tue, 19 Nov 2024 17:47:23 +0200 Subject: [PATCH 5/6] ci: download latest compose --- .github/workflows/ci.yml | 16 ++++++++++------ compose.yml | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd79a45..257bf17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,12 @@ permissions: pull-requests: write packages: write +env: + COMPOSE_EXPERIMENTAL_OCI_REMOTE: "1" + jobs: publish: runs-on: ubuntu-latest - env: - COMPOSE_EXPERIMENTAL_OCI_REMOTE: "1" steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 @@ -20,14 +21,17 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - run: docker compose build --push - - run: docker compose alpha publish ghcr.io/withlogicco/postgres + - run: | + wget https://github.com/docker/compose/releases/download/v2.30.3/docker-compose-linux-x86_64 + mv docker-compose-linux-x86_64 compose-v2.30 + chmod +x compose-v2.30 + mv compose-v2.30 /usr/local/bin + - run: compose-v2.30 build --push + - run: compose-v2.30 alpha publish ghcr.io/withlogicco/postgres:${{ github.sha }} config: needs: publish runs-on: ubuntu-latest - env: - COMPOSE_EXPERIMENTAL_OCI_REMOTE: "1" steps: - uses: actions/checkout@v4 - run: docker info diff --git a/compose.yml b/compose.yml index 834c2d6..034121f 100644 --- a/compose.yml +++ b/compose.yml @@ -11,7 +11,7 @@ x-base: services: primary: <<: *base - image: ghcr.io/withlogicco/postgres/primary + image: ghcr.io/withlogicco/postgres/primary:${DOCKER_IMAGE_TAG:-latest} build: context: postgres target: primary @@ -20,7 +20,7 @@ services: secondary: <<: *base - image: ghcr.io/withlogicco/postgres/secondary + image: ghcr.io/withlogicco/postgres/secondary:${DOCKER_IMAGE_TAG:-latest} build: context: postgres target: secondary @@ -29,7 +29,7 @@ services: - secondary_data:/var/lib/postgresql/data pgpool2: - image: ghcr.io/withlogicco/postgres/pgpool2 + image: ghcr.io/withlogicco/postgres/pgpool2:${DOCKER_IMAGE_TAG:-latest} build: context: pgpool2 secrets: From 560aad0e608d5a698b9aa821d9082642f8d3c2fb Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Tue, 19 Nov 2024 17:52:24 +0200 Subject: [PATCH 6/6] ci: set `DOCKER_IMAGE_TAG` --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 257bf17..3ddb916 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ permissions: env: COMPOSE_EXPERIMENTAL_OCI_REMOTE: "1" + DOCKER_IMAGE_TAG: ${{ github.sha }} jobs: publish: