diff --git a/.github/workflows/deploy_gcp_prod.yaml b/.github/workflows/deploy_gcp_prod.yaml index 2a9daf9..996a8ba 100644 --- a/.github/workflows/deploy_gcp_prod.yaml +++ b/.github/workflows/deploy_gcp_prod.yaml @@ -30,12 +30,6 @@ jobs: steps: - name: hypnos::deploy_prod::docker::Checkout repository uses: actions/checkout@v4 - - - name: hypnos::deploy_prod::docker::Setup docker (missing on MacOS) - if: runner.os == 'macos' - run: | - brew install docker colima docker-buildx - colima start - name: hypnos::deploy_prod::docker::Log in to the Container registry uses: docker/login-action@v3 @@ -132,42 +126,42 @@ jobs: # # --set-secrets= - # deploy-to-gcp-vm: - # needs: build-and-push-image - # name: hypnos::deploy_prod::push_to_gcp::vm - # runs-on: ubuntu-latest + deploy-to-gcp-vm: + needs: build-and-push-image + name: hypnos::deploy_prod::push_to_gcp::vm + runs-on: ubuntu-latest - # steps: - # - name: hypnos::deploy_prod::gcp::Checkout repository - # uses: actions/checkout@v3 + steps: + - name: hypnos::deploy_prod::gcp::Checkout repository + uses: actions/checkout@v3 - # - name: hypnos::deploy_prod::gcp::Set Docker image tag - # id: set_tag - # run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" + - name: hypnos::deploy_prod::gcp::Set Docker image tag + id: set_tag + run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" - # - name: hypnos::deploy_prod::gcp::Set up Google Cloud SDK - # uses: google-github-actions/setup-gcloud@v0.3.0 - # with: - # service_account_email: ${{ secrets.GCP_SA_EMAIL }} - # service_account_key: ${{ secrets.GCP_SA_KEY }} - # export_default_credentials: true - # project_id: ${{ secrets.GCP_PROJECT_ID }} + - name: hypnos::deploy_prod::gcp::Set up Google Cloud SDK + uses: google-github-actions/setup-gcloud@v0.3.0 + with: + service_account_email: ${{ secrets.GCP_SA_EMAIL }} + service_account_key: ${{ secrets.GCP_SA_KEY }} + export_default_credentials: true + project_id: ${{ secrets.GCP_PROJECT_ID }} - # - name: hypnos::deploy_prod::gcp::Log in to the Container registry - # uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - # with: - # registry: ${{ env.REGISTRY }} - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # - name: install ssh keys - # # check this thread to understand why its needed: - # # - # run: | - # install -m 600 -D /dev/null ~/.ssh/id_rsa - # echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa - # ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts - # - name: connect and pull - # run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && docker compose pull && docker compose up -d && exit" - # - name: cleanup - # run: rm -rf ~/.ssh + - name: hypnos::deploy_prod::gcp::Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: install ssh keys + # check this thread to understand why its needed: + # + run: | + install -m 600 -D /dev/null ~/.ssh/id_rsa + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts + - name: connect and pull + run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && docker compose pull && docker compose up -d && exit" + - name: cleanup + run: rm -rf ~/.ssh diff --git a/Dockerfile b/Dockerfile index 688e4be..5e17809 100644 --- a/Dockerfile +++ b/Dockerfile @@ -151,9 +151,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs -EXPOSE 3000 +EXPOSE 3001 -ENV PORT=3000 +ENV PORT=3001 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output diff --git a/package.json b/package.json index 5d88573..047d84f 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,9 @@ "build": "npm run schema:generate:all && next build", "build:vm": "npm run schema:generate:all:standalone && next build", "start": "next start", - "start:pm2": "pm2 start npm --name 'hypnos' -- run start", + "start:pm2": "pm2-runtime start npm --name 'hypnos' -- run start", "start:vm": "HOSTNAME='0.0.0.0' node server.js", - "start:vm:pm2": "pm2 start npm --name 'hypnos' -- run start:vm", + "start:vm:pm2": "pm2-runtime start npm --name 'hypnos' -- run start:vm", "lint": "next lint", "format": "next lint && prettier --check --ignore-path .gitignore --ignore-path .prettierignore .", "format:fix": "next lint --fix && prettier --write --ignore-path .gitignore --ignore-path .prettierignore .",