Skip to content

Commit ff2a419

Browse files
Add scripts to build and push Docker image to Azure Container Registry
- Created PowerShell script `build-push-acr.ps1` for building and pushing Docker images to ACR. - Created Bash script `build-push-acr.sh` for the same purpose, ensuring compatibility with Unix-like environments. - Both scripts handle environment variables, ACR login, Docker image building, and pushing to ACR with error handling.
1 parent 3c7a606 commit ff2a419

File tree

5 files changed

+1629
-0
lines changed

5 files changed

+1629
-0
lines changed

Dockerfile.backend

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Dockerfile for building backend container from root directory
2+
# This is used by the ACR preprovision hooks for azd deployment
3+
4+
FROM node:20-alpine AS frontend
5+
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
6+
7+
WORKDIR /home/node/app
8+
COPY ./src/frontend/package*.json ./
9+
USER node
10+
RUN npm ci
11+
COPY --chown=node:node ./src/frontend/ ./frontend
12+
WORKDIR /home/node/app/frontend
13+
RUN npm install --save-dev @types/node @types/jest
14+
RUN NODE_OPTIONS=--max_old_space_size=8192 npm run build
15+
16+
FROM python:3.11-alpine
17+
RUN apk add --no-cache --virtual .build-deps \
18+
build-base \
19+
libffi-dev \
20+
openssl-dev \
21+
curl \
22+
&& apk add --no-cache \
23+
libpq
24+
25+
COPY ./src/requirements.txt /usr/src/app/
26+
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt \
27+
&& rm -rf /root/.cache
28+
29+
COPY ./src/ /usr/src/app/
30+
COPY --from=frontend /home/node/app/static /usr/src/app/static/
31+
WORKDIR /usr/src/app
32+
EXPOSE 80
33+
34+
CMD ["gunicorn", "-b", "0.0.0.0:80", "app:app"]

azure_custom.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
3+
name: document-generation
4+
metadata:
5+
template: document-generation@1.0
6+
7+
requiredVersions:
8+
azd: '>= 1.18.0'
9+
10+
# No services defined - Container App is fully managed by Bicep
11+
# This prevents azd from trying to use its broken Container Apps integration
12+
13+
hooks:
14+
preprovision:
15+
windows:
16+
shell: pwsh
17+
run: |
18+
./scripts/auth_init.ps1
19+
Write-Host "Building and pushing Docker image to ACR..." -ForegroundColor Yellow
20+
./scripts/build-push-acr.ps1
21+
interactive: true
22+
continueOnError: false
23+
posix:
24+
shell: sh
25+
run: |
26+
./scripts/auth_init.sh
27+
echo "Building and pushing Docker image to ACR..."
28+
bash ./scripts/build-push-acr.sh
29+
interactive: true
30+
continueOnError: false
31+
postprovision:
32+
windows:
33+
run: |
34+
./scripts/auth_update.ps1
35+
Write-Host "Web app URL: "
36+
Write-Host "$env:WEB_APP_URL" -ForegroundColor Cyan
37+
Write-Host "`nIf you want to use the Sample Data, run the following command in the Bash terminal to process it:"
38+
Write-Host "bash ./infra/scripts/process_sample_data.sh" -ForegroundColor Cyan
39+
shell: pwsh
40+
continueOnError: false
41+
interactive: true
42+
posix:
43+
run: |
44+
./scripts/auth_update.sh
45+
echo "Web app URL: "
46+
echo $WEB_APP_URL
47+
echo ""
48+
echo "If you want to use the Sample Data, run the following command in the bash terminal to process it:"
49+
echo "bash ./infra/scripts/process_sample_data.sh"
50+
shell: sh
51+
continueOnError: false
52+
interactive: true

0 commit comments

Comments
 (0)