From 69a884f56290d3f4884c30dfe16b073f25ffe0b6 Mon Sep 17 00:00:00 2001 From: Jay Bhavsar Date: Thu, 18 Apr 2024 17:56:19 +0530 Subject: [PATCH] dockerized --- .github/workflows/docker-build.yml | 43 ++++++++++++++++++++++++++++++ web-app/Dockerfile | 8 ++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/docker-build.yml create mode 100644 web-app/Dockerfile diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..b39a3ac --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,43 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + - dev + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set Tag + run: | + if [[ $GITHUB_REF == 'refs/heads/main' ]]; then + echo "TAG=latest" >> $GITHUB_ENV + elif [[ $GITHUB_REF == 'refs/heads/dev' ]]; then + echo "TAG=dev" >> $GITHUB_ENV + fi + + - name: Build and Push Docker Image + uses: docker/build-push-action@v2 + with: + context: ./web-app + file: ./web-app/Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/web3-testimonials:${{ env.TAG }} + + - name: Logout from DockerHub + run: docker logout \ No newline at end of file diff --git a/web-app/Dockerfile b/web-app/Dockerfile new file mode 100644 index 0000000..c1b4274 --- /dev/null +++ b/web-app/Dockerfile @@ -0,0 +1,8 @@ +FROM node:20 +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build +EXPOSE 3000 +CMD ["npm", "run", "start"]