Skip to content

Commit

Permalink
port fix + ci/cd for docker hub
Browse files Browse the repository at this point in the history
  • Loading branch information
code-crusher committed Oct 15, 2024
1 parent 071f4a3 commit f2999a7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
./env
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit f2999a7

Please sign in to comment.