Skip to content

Commit

Permalink
chore: Update pipelines; fixed api docker
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Jan 2, 2025
1 parent c79d886 commit 3f36a17
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 94 deletions.
71 changes: 21 additions & 50 deletions .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
35 changes: 16 additions & 19 deletions .github/workflows/deploy-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
45 changes: 21 additions & 24 deletions .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
4 changes: 3 additions & 1 deletion apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"]
1 change: 1 addition & 0 deletions apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl"]
}

datasource db {
Expand Down

0 comments on commit 3f36a17

Please sign in to comment.