Skip to content

Commit 06c8478

Browse files
Merge pull request #1 from Priyanka-Microsoft/feature/8534-build-docker-image
CI-CD pipeline
2 parents ab9ba6c + 52c45ba commit 06c8478

File tree

8 files changed

+3843
-720
lines changed

8 files changed

+3843
-720
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build ClientAdvisor Docker Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- ClientAdvisor/**
8+
pull_request:
9+
branches: [main]
10+
types:
11+
- opened
12+
- ready_for_review
13+
- reopened
14+
- synchronize
15+
paths:
16+
- ClientAdvisor/**
17+
merge_group:
18+
19+
jobs:
20+
docker-build:
21+
strategy:
22+
matrix:
23+
include:
24+
- app_name: clientadvisor-webapp
25+
dockerfile: ClientAdvisor/App/WebApp.Dockerfile
26+
password_secret: DOCKER_PASSWORD
27+
- app_name: clientadvisor-azurefunction
28+
dockerfile: ClientAdvisor/AzureFunction/Dockerfile
29+
password_secret: DOCKER_PASSWORD
30+
31+
uses: ./.github/workflows/build-docker.yml
32+
with:
33+
registry: pslpricicdcontainerreg.azurecr.io
34+
username: pslpricicdcontainerreg
35+
app_name: ${{ matrix.app_name }}
36+
dockerfile: ${{ matrix.dockerfile }}
37+
push: true # Adjust this logic as necessary
38+
secrets: inherit

.github/workflows/build-docker.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Reusable Docker build and push workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
registry:
7+
required: true
8+
type: string
9+
username:
10+
required: true
11+
type: string
12+
password_secret:
13+
required: true
14+
type: string
15+
app_name:
16+
required: true
17+
type: string
18+
dockerfile:
19+
required: true
20+
type: string
21+
push:
22+
required: true
23+
type: boolean
24+
secrets:
25+
DOCKER_PASSWORD:
26+
required: true
27+
28+
jobs:
29+
docker-build:
30+
runs-on: ubuntu-latest
31+
steps:
32+
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Docker Login
37+
if: ${{ inputs.push }}
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ inputs.registry }}
41+
username: ${{ inputs.username }}
42+
password: ${{ secrets[inputs.password_secret] }}
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Get current date
48+
id: date
49+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
50+
51+
- name: Build Docker Image and optionally push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
file: ${{ inputs.dockerfile }}
56+
push: ${{ inputs.push }}
57+
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:latest
58+
tags: |
59+
${{ inputs.registry }}/${{ inputs.app_name}}:latest
60+
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build ResearchAssistant Docker Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- ResearchAssistant/**
8+
pull_request:
9+
branches: [main]
10+
types:
11+
- opened
12+
- ready_for_review
13+
- reopened
14+
- synchronize
15+
paths:
16+
- ResearchAssistant/**
17+
merge_group:
18+
19+
jobs:
20+
docker-build:
21+
strategy:
22+
matrix:
23+
include:
24+
- app_name: researchassistant-webapp
25+
dockerfile: ResearchAssistant/App/WebApp.Dockerfile
26+
password_secret: DOCKER_PASSWORD_RESEARCHASSISTANT
27+
28+
uses: ./.github/workflows/build-docker.yml
29+
with:
30+
registry: pslpriracontainerreg.azurecr.io
31+
username: pslpriracontainerreg
32+
app_name: ${{ matrix.app_name }}
33+
dockerfile: ${{ matrix.dockerfile }}
34+
push: true # Adjust this logic as necessary
35+
secrets: inherit
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
# Frontend stage
12
FROM node:20-alpine AS frontend
23
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
34

45
WORKDIR /home/node/app
5-
COPY ./frontend/package*.json ./
6+
COPY ./ClientAdvisor/App/frontend/package*.json ./
67
USER node
7-
RUN npm ci
8-
COPY --chown=node:node ./frontend/ ./frontend
9-
COPY --chown=node:node ./static/ ./static
8+
RUN npm ci
9+
COPY --chown=node:node ./ClientAdvisor/App/frontend/ ./frontend
10+
COPY --chown=node:node ./ClientAdvisor/App/static/ ./static
1011
WORKDIR /home/node/app/frontend
11-
RUN npm run build
12-
12+
RUN npm install --save-dev @types/jest && npm run build
13+
14+
# Backend stage
1315
FROM python:3.11-alpine
1416
RUN apk add --no-cache --virtual .build-deps \
1517
build-base \
@@ -18,15 +20,14 @@ RUN apk add --no-cache --virtual .build-deps \
1820
curl \
1921
&& apk add --no-cache \
2022
libpq
21-
# python3 python3-dev g++ unixodbc-dev unixodbc libpq-dev
22-
23-
COPY requirements.txt /usr/src/app/
23+
24+
COPY ./ClientAdvisor/App/requirements.txt /usr/src/app/
2425
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt \
2526
&& rm -rf /root/.cache
26-
27-
COPY . /usr/src/app/
27+
28+
COPY ./ClientAdvisor/App/ /usr/src/app/
2829
COPY --from=frontend /home/node/app/static /usr/src/app/static/
2930
WORKDIR /usr/src/app
3031
EXPOSE 80
3132

32-
CMD ["gunicorn" , "-b", "0.0.0.0:80", "app:app"]
33+
CMD ["gunicorn", "-b", "0.0.0.0:80", "app:app"]

0 commit comments

Comments
 (0)