diff --git a/.github/workflows/deploy-api.yml b/.github/workflows/deploy-api.yml index 280e8c8c..10f834c3 100644 --- a/.github/workflows/deploy-api.yml +++ b/.github/workflows/deploy-api.yml @@ -11,7 +11,7 @@ on: jobs: build: runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }} + environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }} name: Build and push API docker image for release steps: @@ -38,53 +38,24 @@ jobs: docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT - # setup-database: - # needs: build - # name: Setup Database - # runs-on: ubuntu-latest - # environment: alpha - - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Install Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: 20 - - # - name: Install pnpm - # uses: pnpm/action-setup@v4 - # with: - # version: 9.2.0 - # run_install: false - - # - name: Deploy migrations - # env: - # DATABASE_URL: ${{ secrets.DATABASE_URL }} - # run: pnpm db:deploy-migrations - - # deploy: - # needs: [build, setup-database] - # runs-on: ubuntu-latest - # environment: alpha - # name: Deploy API docker image for release - - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v4 - # with: - # aws-access-key-id: ${{ secrets.ACCESS_KEY }} - # aws-secret-access-key: ${{ secrets.SECRET_KEY }} - # aws-region: ap-south-1 + deploy: + runs-on: ubuntu-latest + environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }} + name: Restart API container app + needs: build + steps: + - name: Azure Login action + uses: azure/login@v2 + with: + creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }} + enable-AzPSSession: true - # - name: Force re-deploy task in service - # id: force-redeploy - # env: - # ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} - # ECS_SERVICE: ${{ vars.ECS_API_SERVICE }} - # run: | - # aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment + - name: Azure CLI script + uses: azure/cli@v2 + env: + API_CONTAINER: ${{ vars.API_CONTAINER }} + API_CONTAINER_RG: ${{ vars.API_CONTAINER_RG }} + with: + azcliversion: latest + inlineScript: | + az containerapp restart --name $API_CONTAINER --resource-group $API_CONTAINER_RG diff --git a/.github/workflows/deploy-platform.yml b/.github/workflows/deploy-platform.yml index 53d98b55..209ea6ce 100644 --- a/.github/workflows/deploy-platform.yml +++ b/.github/workflows/deploy-platform.yml @@ -16,7 +16,7 @@ on: jobs: build: runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }} + environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }} name: Build and push Platform docker image for release steps: @@ -44,26 +44,23 @@ jobs: echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT # deploy: - # needs: build # runs-on: ubuntu-latest - # environment: alpha - # name: Deploy Platform docker image for release - + # environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }} + # name: Restart Platform container app + # needs: build # steps: - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v4 + # - name: Azure Login action + # uses: azure/login@v2 # with: - # aws-access-key-id: ${{ secrets.ACCESS_KEY }} - # aws-secret-access-key: ${{ secrets.SECRET_KEY }} - # aws-region: ap-south-1 + # creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }} + # enable-AzPSSession: true - # - name: Force re-deploy task in service - # id: force-redeploy + # - name: Azure CLI script + # uses: azure/cli@v2 # env: - # ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} - # ECS_SERVICE: ${{ vars.ECS_PLATFORM_SERVICE }} - # run: | - # aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment + # PLATFORM_CONTAINER: ${{ vars.PLATFORM_CONTAINER }} + # PLATFORM_CONTAINER_RG: ${{ vars.PLATFORM_CONTAINER_RG }} + # with: + # azcliversion: latest + # inlineScript: | + # az containerapp restart --name $PLATFORM_CONTAINER --resource-group $PLATFORM_CONTAINER_RG diff --git a/.github/workflows/deploy-web.yml b/.github/workflows/deploy-web.yml index 9cb2d184..27497a34 100644 --- a/.github/workflows/deploy-web.yml +++ b/.github/workflows/deploy-web.yml @@ -11,7 +11,7 @@ on: jobs: build: runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'beta' || 'stage' }} + environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }} name: Build and push Web docker image for release steps: @@ -38,27 +38,24 @@ jobs: docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT - # deploy: - # needs: build - # runs-on: ubuntu-latest - # environment: alpha - # name: Deploy Web docker image for release - - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v4 - # with: - # aws-access-key-id: ${{ secrets.ACCESS_KEY }} - # aws-secret-access-key: ${{ secrets.SECRET_KEY }} - # aws-region: ap-south-1 + deploy: + runs-on: ubuntu-latest + environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }} + name: Restart Web container app + needs: build + steps: + - name: Azure Login action + uses: azure/login@v2 + with: + creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }} + enable-AzPSSession: true - # - name: Force re-deploy task in service - # id: force-redeploy - # env: - # ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} - # ECS_SERVICE: ${{ vars.ECS_WEB_SERVICE }} - # run: | - # aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment + - name: Azure CLI script + uses: azure/cli@v2 + env: + WEB_CONTAINER: ${{ vars.WEB_CONTAINER }} + WEB_CONTAINER_RG: ${{ vars.WEB_CONTAINER_RG }} + with: + azcliversion: latest + inlineScript: | + az containerapp restart --name $WEB_CONTAINER --resource-group $WEB_CONTAINER_RG diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 88ce4c87..836fa57c 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -31,6 +31,8 @@ USER node FROM node:20-alpine AS prod +RUN apk add --no-cache openssl + # Don't run production as root USER node @@ -42,6 +44,6 @@ COPY --chown=root:root --chmod=755 --from=build /app/node_modules /app/node_modu COPY --chown=root:root --chmod=755 --from=build /app/apps/api/node_modules /app/apps/api/node_modules COPY --chown=root:root --chmod=755 --from=build /app/apps/api/dist /app/apps/api/dist -EXPOSE ${API_PORT} +EXPOSE 4200 ENTRYPOINT ["node", "/app/apps/api/dist/main.js"] \ No newline at end of file diff --git a/apps/api/src/prisma/schema.prisma b/apps/api/src/prisma/schema.prisma index d64780ef..2fb61b27 100644 --- a/apps/api/src/prisma/schema.prisma +++ b/apps/api/src/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { provider = "prisma-client-js" + binaryTargets = ["native", "linux-musl"] } datasource db {