From eadfa51b5f7cd1d3be59f9897007eb2722f7c327 Mon Sep 17 00:00:00 2001 From: Artemy Date: Wed, 13 Sep 2023 10:11:26 +0300 Subject: [PATCH] ci: caprover docker deploy --- .github/workflows/deploy.yml | 38 ++++++++++++++++++++++++++++++++++++ Dockerfile | 4 ++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..fe289ee --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,38 @@ +name: Build and Deploy Docker Image +on: [push] +jobs: + build_and_deploy: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_TOKEN }} + + - name: Preset Image Name + run: echo "IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(echo ${{ github.sha }} | cut -c1-7) | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Build and push Docker Image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ env.IMAGE_URL }} + + - name: Deploy Image to CapRrover + uses: caprover/deploy-from-github@v1.1.2 + with: + server: "${{ secrets.CAPROVER_SERVER }}" + app: "${{ secrets.APP_NAME }}" + token: "${{ secrets.APP_TOKEN }}" + image: ${{ env.IMAGE_URL }} diff --git a/Dockerfile b/Dockerfile index a12a489..a26f270 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ RUN npm run build FROM node:18-alpine as run WORKDIR /app -COPY --from=build /app/package*.json /app/index.js /app/note_validator.js /app/core.js /usr/src/app/ -COPY --from=build /app/dist/ /usr/src/app/dist/ +COPY --from=build /app/package*.json /app/index.js /app/note_validator.js /app/core.js ./ +COPY --from=build /app/dist/ ./dist/ RUN npm install --omit=dev CMD npm run start EXPOSE 80