From 1e50297e73fa04b8872d90c803fdf03e55afdde2 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 16 Jan 2025 16:56:45 +0530 Subject: [PATCH 01/11] Update docker-entrypoint.sh --- 17/alpine3.21/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/17/alpine3.21/docker-entrypoint.sh b/17/alpine3.21/docker-entrypoint.sh index 6f59993e08..1948964d12 100755 --- a/17/alpine3.21/docker-entrypoint.sh +++ b/17/alpine3.21/docker-entrypoint.sh @@ -267,7 +267,7 @@ docker_temp_server_start() { # internal start of server in order to allow setup using psql client # does not listen on external TCP/IP and waits until start finishes - set -- "$@" -c listen_addresses='' -p "${PGPORT:-5432}" + set -- "$@" -c listen_addresses='' -p "${PGPORT:-5433}" PGUSER="${PGUSER:-$POSTGRES_USER}" \ pg_ctl -D "$PGDATA" \ From 8fcdc803f4379ef1dbdb8d4d78dc2c9c8c1ed892 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Fri, 17 Jan 2025 09:48:54 +0530 Subject: [PATCH 02/11] Update Dockerfile --- 17/alpine3.21/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/17/alpine3.21/Dockerfile b/17/alpine3.21/Dockerfile index b8b439b28c..8d053b2c29 100644 --- a/17/alpine3.21/Dockerfile +++ b/17/alpine3.21/Dockerfile @@ -133,7 +133,7 @@ RUN set -eux; \ # --enable-debug \ --disable-rpath \ --with-uuid=e2fs \ - --with-pgport=5432 \ + --with-pgport=5433 \ --with-system-tzdata=/usr/share/zoneinfo \ --prefix=/usr/local \ --with-includes=/usr/local/include \ From 9f70a939337f68db1fb47f4c7803fbed01cf7607 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Mon, 20 Jan 2025 15:21:04 +0530 Subject: [PATCH 03/11] Create deploy.yml --- .github/workflows/deploy.yml | 100 +++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..487beb6fe0 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,100 @@ +name: CI/CD Build and Deploy PostgreSQL Docker Image + +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy (Development/Production)' + required: true + default: 'development' + +jobs: + build-push-deploy-postgres: + name: Build, Push, and Deploy PostgreSQL Docker Image + runs-on: ubuntu-latest + + steps: + # Checkout Postgres Docker repository + - name: Checkout Postgres Repository + uses: actions/checkout@v3 + with: + repository: trplgit/postgres + token: ${{ secrets.GITHUB_TOKEN }} + path: postgres + + # Set up Docker buildx + - name: Set up Docker + uses: docker/setup-buildx-action@v2 + + # Log in to Azure Container Registry + - name: Log in to Azure Container Registry + uses: azure/docker-login@v1 + with: + login-server: ${{ vars.ACR_NAME }}.azurecr.io + username: ${{ vars.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} + + # Build and Push PostgreSQL Docker Image + - name: Build and Push PostgreSQL Docker Image + run: | + docker build -f ./postgres/17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./postgres/17/alpine3.21 + docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 + + # Install OpenVPN + - name: Install OpenVPN + run: sudo apt-get install -y openvpn + + # Prepare VPN files + - name: Prepare VPN Files + run: | + echo "${{ secrets.VPN_PKCS12_FILE }}" | base64 -d > TRPL-FW-TCP-1194-ci-cd-automation.p12 + echo "${{ secrets.VPN_TLS_KEY_FILE }}" | base64 -d > TRPL-FW-TCP-1194-ci-cd-automation-tls.key + + # Connect to VPN + - name: Connect to VPN + run: | + echo "${{ secrets.VPN_CONFIG_FILE }}" > vpn-config.ovpn + echo -e "${{ vars.VPN_USERNAME }}\n${{ secrets.VPN_PASSWORD }}" > vpn-credentials.txt + sudo openvpn --config vpn-config.ovpn --auth-user-pass vpn-credentials.txt --daemon + + # Wait for VPN connection + - name: Wait for VPN Connection + run: sleep 15 + + # Verify VPN connection + - name: Verify VPN Connection + run: | + ifconfig | grep tun || (echo "VPN connection failed" && exit 1) + + # Add user to Docker group + - name: Add user to Docker group + run: | + sudo usermod -aG docker $USER + newgrp docker || true + + # Create Docker network if not exists + - name: Create Docker Network if not exists + run: | + echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker network create odoo-postgres-network || echo "Network already exists" + + # Deploy PostgreSQL Docker container to VM + - name: Deploy PostgreSQL Docker Container to VM + uses: appleboy/ssh-action@v0.1.6 + with: + host: ${{ vars.LINUX_VM_HOST_DEVELOPMENT }} + username: ${{ vars.LINUX_VM_USERNAME_DEVELOPMENT }} + password: ${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }} + port: 22 + script: | + echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker login ${{ vars.ACR_NAME }}.azurecr.io -u ${{ vars.ACR_USERNAME }} -p ${{ secrets.ACR_PASSWORD }} + echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker pull ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 + echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker stop postgres-container || true + echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker rm postgres-container || true + + # Run PostgreSQL container + echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker run -d --restart always --name postgres-container --network=odoo-postgres-network -e POSTGRES_PASSWORD=mysecretpassword -p 5433:5433 ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 + + # Cleanup VPN credentials + - name: Cleanup VPN Credentials + run: | + rm -f vpn-config.ovpn vpn-credentials.txt From f01d64f197de78f6ae3b4ef212b460e2cb05fbb5 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Mon, 20 Jan 2025 15:47:06 +0530 Subject: [PATCH 04/11] Update deploy.yml --- .github/workflows/deploy.yml | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 487beb6fe0..3f1577846a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: CI/CD Build and Deploy PostgreSQL Docker Image +name: CI/CD for PostgreSQL Docker on: workflow_dispatch: @@ -7,24 +7,30 @@ on: description: 'Environment to deploy (Development/Production)' required: true default: 'development' + postgres_version: + description: 'Postgres Version' + required: true + default: '17' jobs: - build-push-deploy-postgres: - name: Build, Push, and Deploy PostgreSQL Docker Image + build-and-push: + name: Build and Push Docker Images for PostgreSQL runs-on: ubuntu-latest steps: - # Checkout Postgres Docker repository + # Checkout Postgres Docker repository into a specific directory - name: Checkout Postgres Repository uses: actions/checkout@v3 with: repository: trplgit/postgres token: ${{ secrets.GITHUB_TOKEN }} - path: postgres + path: postgres # Checkout into the 'postgres' directory # Set up Docker buildx - name: Set up Docker uses: docker/setup-buildx-action@v2 + with: + version: latest # Log in to Azure Container Registry - name: Log in to Azure Container Registry @@ -34,12 +40,18 @@ jobs: username: ${{ vars.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} - # Build and Push PostgreSQL Docker Image - - name: Build and Push PostgreSQL Docker Image + # Build and Push Postgres Docker Image for PostgreSQL 17 + - name: Build and Push Postgres Docker Image run: | docker build -f ./postgres/17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./postgres/17/alpine3.21 docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 + deploy: + name: Deploy PostgreSQL to Linux VM + runs-on: ubuntu-latest + needs: build-and-push + + steps: # Install OpenVPN - name: Install OpenVPN run: sudo apt-get install -y openvpn @@ -66,7 +78,7 @@ jobs: run: | ifconfig | grep tun || (echo "VPN connection failed" && exit 1) - # Add user to Docker group + # Add user to Docker group to allow Docker commands without sudo - name: Add user to Docker group run: | sudo usermod -aG docker $USER @@ -77,8 +89,8 @@ jobs: run: | echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker network create odoo-postgres-network || echo "Network already exists" - # Deploy PostgreSQL Docker container to VM - - name: Deploy PostgreSQL Docker Container to VM + # Deploy Postgres Docker container to VM + - name: Deploy Postgres Docker Container to VM uses: appleboy/ssh-action@v0.1.6 with: host: ${{ vars.LINUX_VM_HOST_DEVELOPMENT }} @@ -91,7 +103,7 @@ jobs: echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker stop postgres-container || true echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker rm postgres-container || true - # Run PostgreSQL container + # Run Postgres container (PostgreSQL 17) echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker run -d --restart always --name postgres-container --network=odoo-postgres-network -e POSTGRES_PASSWORD=mysecretpassword -p 5433:5433 ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 # Cleanup VPN credentials From cbee0e4eac70994d480ef6564359167edbbf3aa5 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:42:23 +0530 Subject: [PATCH 05/11] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccc7fd8955..e41e407aed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,9 @@ name: GitHub CI -on: +#on: pull_request: push: - schedule: + # schedule: - cron: 0 0 * * 0 workflow_dispatch: From 8aa1716c5d03ed6c87e7fe736cc565089c52b450 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:43:57 +0530 Subject: [PATCH 06/11] Update ci.yml --- .github/workflows/ci.yml | 49 ---------------------------------------- 1 file changed, 49 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e41e407aed..8b13789179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,50 +1 @@ -name: GitHub CI -#on: - pull_request: - push: - # schedule: - - cron: 0 0 * * 0 - workflow_dispatch: - -defaults: - run: - shell: 'bash -Eeuo pipefail -x {0}' - -jobs: - - generate-jobs: - name: Generate Jobs - runs-on: ubuntu-latest - outputs: - strategy: ${{ steps.generate-jobs.outputs.strategy }} - steps: - - uses: actions/checkout@v4 - - uses: docker-library/bashbrew@HEAD - - id: generate-jobs - name: Generate Jobs - run: | - strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")" - strategy="$(.github/workflows/munge.sh -c <<<"$strategy")" - echo "strategy=$strategy" >> "$GITHUB_OUTPUT" - jq . <<<"$strategy" # sanity check / debugging aid - - test: - needs: generate-jobs - strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Prepare Environment - run: ${{ matrix.runs.prepare }} - - name: Pull Dependencies - run: ${{ matrix.runs.pull }} - - name: Build ${{ matrix.name }} - run: ${{ matrix.runs.build }} - - name: History ${{ matrix.name }} - run: ${{ matrix.runs.history }} - - name: Test ${{ matrix.name }} - run: ${{ matrix.runs.test }} - - name: '"docker images"' - run: ${{ matrix.runs.images }} From ef7c8c8058df96eb15ab915f8ab07157cb2f9496 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:45:00 +0530 Subject: [PATCH 07/11] Update ci.yml --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b13789179..6e63b34a1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1 +1,51 @@ +name: GitHub CI + +#on: + pull_request: + push: + # schedule: + - cron: 0 0 * * 0 + workflow_dispatch: + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' + +jobs: + + generate-jobs: + name: Generate Jobs + runs-on: ubuntu-latest + outputs: + strategy: ${{ steps.generate-jobs.outputs.strategy }} + steps: + - uses: actions/checkout@v4 + - uses: docker-library/bashbrew@HEAD + - id: generate-jobs + name: Generate Jobs + run: | + strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")" + strategy="$(.github/workflows/munge.sh -c <<<"$strategy")" + echo "strategy=$strategy" >> "$GITHUB_OUTPUT" + jq . <<<"$strategy" # sanity check / debugging aid + + test: + needs: generate-jobs + strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Prepare Environment + run: ${{ matrix.runs.prepare }} + - name: Pull Dependencies + run: ${{ matrix.runs.pull }} + - name: Build ${{ matrix.name }} + run: ${{ matrix.runs.build }} + - name: History ${{ matrix.name }} + run: ${{ matrix.runs.history }} + - name: Test ${{ matrix.name }} + run: ${{ matrix.runs.test }} + - name: '"docker images"' + run: ${{ matrix.runs.images }} From 4ee59a8ba1ca2401b2098342aceca00ac2e9d9fc Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:47:17 +0530 Subject: [PATCH 08/11] Update deploy.yml --- .github/workflows/deploy.yml | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3f1577846a..3c0ddd13d9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: CI/CD for PostgreSQL Docker +name: CI/CD for PostgreSQL Docker - Build, Push, and Deploy on: workflow_dispatch: @@ -8,31 +8,28 @@ on: required: true default: 'development' postgres_version: - description: 'Postgres Version' + description: 'PostgreSQL Version' required: true - default: '17' + default: '17.0' jobs: build-and-push: - name: Build and Push Docker Images for PostgreSQL + name: Build and Push PostgreSQL Docker Image runs-on: ubuntu-latest steps: - # Checkout Postgres Docker repository into a specific directory - name: Checkout Postgres Repository uses: actions/checkout@v3 with: repository: trplgit/postgres token: ${{ secrets.GITHUB_TOKEN }} - path: postgres # Checkout into the 'postgres' directory + path: postgres - # Set up Docker buildx - name: Set up Docker uses: docker/setup-buildx-action@v2 with: version: latest - # Log in to Azure Container Registry - name: Log in to Azure Container Registry uses: azure/docker-login@v1 with: @@ -40,57 +37,48 @@ jobs: username: ${{ vars.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} - # Build and Push Postgres Docker Image for PostgreSQL 17 - name: Build and Push Postgres Docker Image run: | docker build -f ./postgres/17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./postgres/17/alpine3.21 docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 deploy: - name: Deploy PostgreSQL to Linux VM + name: Deploy PostgreSQL Docker Container to Linux VM runs-on: ubuntu-latest needs: build-and-push steps: - # Install OpenVPN - name: Install OpenVPN run: sudo apt-get install -y openvpn - # Prepare VPN files - name: Prepare VPN Files run: | echo "${{ secrets.VPN_PKCS12_FILE }}" | base64 -d > TRPL-FW-TCP-1194-ci-cd-automation.p12 echo "${{ secrets.VPN_TLS_KEY_FILE }}" | base64 -d > TRPL-FW-TCP-1194-ci-cd-automation-tls.key - # Connect to VPN - name: Connect to VPN run: | echo "${{ secrets.VPN_CONFIG_FILE }}" > vpn-config.ovpn echo -e "${{ vars.VPN_USERNAME }}\n${{ secrets.VPN_PASSWORD }}" > vpn-credentials.txt sudo openvpn --config vpn-config.ovpn --auth-user-pass vpn-credentials.txt --daemon - # Wait for VPN connection - name: Wait for VPN Connection run: sleep 15 - # Verify VPN connection - name: Verify VPN Connection run: | ifconfig | grep tun || (echo "VPN connection failed" && exit 1) - # Add user to Docker group to allow Docker commands without sudo - name: Add user to Docker group run: | sudo usermod -aG docker $USER newgrp docker || true - # Create Docker network if not exists - name: Create Docker Network if not exists run: | echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker network create odoo-postgres-network || echo "Network already exists" - # Deploy Postgres Docker container to VM - - name: Deploy Postgres Docker Container to VM + - name: Deploy PostgreSQL Docker Container to VM uses: appleboy/ssh-action@v0.1.6 with: host: ${{ vars.LINUX_VM_HOST_DEVELOPMENT }} @@ -106,7 +94,6 @@ jobs: # Run Postgres container (PostgreSQL 17) echo "${{ secrets.LINUX_VM_PASSWORD_DEVELOPMENT }}" | sudo -S docker run -d --restart always --name postgres-container --network=odoo-postgres-network -e POSTGRES_PASSWORD=mysecretpassword -p 5433:5433 ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 - # Cleanup VPN credentials - name: Cleanup VPN Credentials run: | rm -f vpn-config.ovpn vpn-credentials.txt From fd27fdc8a7464f0b710729f8dda2612b997ec6b1 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:50:04 +0530 Subject: [PATCH 09/11] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3c0ddd13d9..c6475d4005 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -39,7 +39,7 @@ jobs: - name: Build and Push Postgres Docker Image run: | - docker build -f ./postgres/17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./postgres/17/alpine3.21 + docker build -f ./17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./17/alpine3.21 docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 deploy: From 5b45fc012654ffcd0a3e604163fa8010404c4f4d Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:51:57 +0530 Subject: [PATCH 10/11] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c6475d4005..e994aed07c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 with: repository: trplgit/postgres - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GH_TOKEN }} path: postgres - name: Set up Docker From f15fb83fd8a5c3a0bbc9cfad6fc91f0c73359db8 Mon Sep 17 00:00:00 2001 From: ravindraba-regtech Date: Thu, 27 Feb 2025 10:57:31 +0530 Subject: [PATCH 11/11] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e994aed07c..55cabf6011 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -39,7 +39,7 @@ jobs: - name: Build and Push Postgres Docker Image run: | - docker build -f ./17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./17/alpine3.21 + docker build -f ./postgres/17/alpine3.21/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 ./postgres/17/alpine3.21 docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/trpl-postgres-docker:v17 deploy: