From f2999a79414cfd4474b941007b3399b67e433cfa Mon Sep 17 00:00:00 2001 From: xblack Date: Tue, 15 Oct 2024 16:50:04 +0530 Subject: [PATCH] port fix + ci/cd for docker hub --- .dockerignore | 2 ++ .github/workflows/main.yml | 41 ++++++++++++++++++++++++++++++++++++++ src/index.ts | 4 ++-- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/main.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..62fecc8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +./env \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1baa3af --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,41 @@ +name: Deploy +on: + push: + branches: + - main + +jobs: + buildAndDeploy: + name: Build and Deploy + runs-on: self-hosted + steps: + - name: Checkout & Build + uses: actions/checkout@v4 + + - name: Build + uses: actions/setup-node@v2 + with: + node-version: 18.x + cache: 'npm' + cache-dependency-path: package-lock.json + - run: npm ci && npm run build + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker Image + uses: docker/build-push-action@v5 + with: + context: ./ + file: ./Dockerfile + push: true + tags: 'gravitycloud/gravity-ci-cd-agent:latest' diff --git a/src/index.ts b/src/index.ts index 90eb734..e3bf496 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,7 +16,7 @@ const pool = new Pool({ database: process.env.POSTGRES_DB, user: process.env.POSTGRES_USER, password: process.env.POSTGRES_PASSWORD, - port: 6543, + port: 5432, }); // Replace getDbConnection function @@ -310,7 +310,7 @@ const syncGitRepo = async () => { // build the docker image in sync with pushing the log output into array const dockerBuildCommand = `${dockerBuildCli} ${process.env.ENV === "production" ? "bud --isolation chroot" : "build"} --platform=linux/amd64 -t ${owner}/${serviceName}:latest -f ${gitRepoPath}/Dockerfile ${gitRepoPath}`; - // await customExec(deploymentRunId, "DOCKER_IMAGE_BUILD", dockerBuildCommand); + await customExec(deploymentRunId, "DOCKER_IMAGE_BUILD", dockerBuildCommand); console.log("dockerBuildCommand COMPLETED");