Skip to content

Commit

Permalink
Merge pull request #1 from sparebank1utvikling/dev
Browse files Browse the repository at this point in the history
Add Azure deploy github action
  • Loading branch information
havardthom authored Sep 12, 2024
2 parents c680a61 + ca65ea0 commit 7d19f90
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Trigger auto deployment

# When this action will be executed
on:
# Uncomment the code below for automatically trigger the workflow when detected changes in the main branch
push:
branches: [main]

# Allow manual trigger
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout to the branch
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Set up Postgresql with prisma
run: |
DATABASE_URL=${{secrets.DATABASE_URL}} npx prisma generate
DATABASE_URL=${{secrets.DATABASE_URL}} npx prisma migrate deploy
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Build and push container image to registry
uses: azure/container-apps-deploy-action@v1
with:
appSourcePath: ${{ github.workspace }}
registryUrl: sbukrokeloneacr.azurecr.io
registryUsername: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
registryPassword: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
imageToBuild: sbukrokeloneacr.azurecr.io/krokelo:${{ github.sha }}
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ FROM base as deps

WORKDIR /myapp

ADD package.json package-lock.json ./
RUN npm install --production=false
ADD package.json package-lock.json .npmrc ./
RUN npm install --include=dev

# Setup production node_modules
FROM base as production-deps

WORKDIR /myapp

COPY --from=deps /myapp/node_modules /myapp/node_modules
ADD package.json package-lock.json ./
RUN npm prune --production
ADD package.json package-lock.json .npmrc ./
RUN npm prune --omit=dev

# Build the app
FROM base as build
Expand All @@ -37,10 +37,6 @@ RUN npx prisma generate
ADD . .
RUN npm run build

# Run migrations
ARG DATABASE_URL
RUN npm run deploy:db

# Finally, build the production image with minimal footprint
FROM base

Expand Down

0 comments on commit 7d19f90

Please sign in to comment.