Skip to content

Commit 057bdd8

Browse files
committed
Changed Utilplex to be hosted in storage account
1 parent 5659f12 commit 057bdd8

File tree

3 files changed

+168
-64
lines changed

3 files changed

+168
-64
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(cat:*)"
5+
],
6+
"deny": [],
7+
"ask": []
8+
}
9+
}

.github/workflows/build-deploy.yml

Lines changed: 89 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,126 @@
1-
# This is a workflow to build a Docker image and deploy it to Docker Hub
1+
# Build and Deploy to Azure Storage Static Website
22

3-
name: Docker CI/CD
3+
name: Build and Deploy to Azure Storage
44

55
# Controls when the workflow will run
66
on:
7-
# Triggers the workflow on push or pull request events but only for the "main" branch
7+
# Triggers the workflow on push events but only for the "main" branch
88
push:
99
branches: ["main"]
10-
pull_request:
11-
branches: ["main"]
12-
10+
1311
# Allows you to run this workflow manually from the Actions tab
1412
workflow_dispatch:
1513

1614
env:
1715
PROJECT_NAME: utilplex
18-
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
19-
DOCKER_HUB_REPOSITORY: ${{ vars.DOCKER_HUB_REPOSITORY || 'utilplex' }}
20-
IMAGE_TAG: ${{ github.sha }}
16+
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}
2117

2218
jobs:
2319
build:
24-
name: Build and test
20+
name: Build Angular Application
2521
runs-on: ubuntu-latest
2622
steps:
2723
- name: Checkout
28-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2925
with:
3026
fetch-depth: 0
31-
27+
3228
- name: Set up Node 20.x
33-
uses: actions/setup-node@v3
29+
uses: actions/setup-node@v4
3430
with:
3531
node-version: "20.x"
3632
cache: 'npm'
37-
33+
3834
- name: Install dependencies
3935
run: npm ci
40-
41-
- name: Build
36+
37+
- name: Build application
4238
run: npm run build:ci
43-
44-
- name: Set up Docker Buildx
45-
uses: docker/setup-buildx-action@v2
46-
47-
- name: Build and export Docker image
48-
uses: docker/build-push-action@v4
49-
with:
50-
context: .
51-
load: true
52-
tags: ${{ env.DOCKER_HUB_USERNAME }}/${{ env.DOCKER_HUB_REPOSITORY }}:${{ env.IMAGE_TAG }}
53-
54-
- name: Test Docker image
55-
run: |
56-
docker run --rm ${{ env.DOCKER_HUB_USERNAME }}/${{ env.DOCKER_HUB_REPOSITORY }}:${{ env.IMAGE_TAG }} echo "Docker image built successfully"
57-
58-
- name: Archive build
39+
40+
- name: Archive build artifacts
5941
if: success()
6042
uses: actions/upload-artifact@v4
6143
with:
62-
name: docker_meta
63-
path: |
64-
.docker/
65-
Dockerfile
66-
docker-compose.yml
67-
if-no-files-found: ignore
44+
name: browser-build
45+
path: dist/utilplex/browser/
46+
retention-days: 1
6847

6948
deploy:
70-
name: Deploy to Docker Hub
49+
name: Deploy to Azure Storage
7150
runs-on: ubuntu-latest
7251
needs: build
73-
if: github.event_name != 'pull_request'
7452
steps:
75-
- name: Checkout
76-
uses: actions/checkout@v3
77-
7853
- name: Download build artifacts
7954
uses: actions/download-artifact@v4
8055
with:
81-
name: docker_meta
82-
path: .
83-
84-
- name: Set up Docker Buildx
85-
uses: docker/setup-buildx-action@v2
86-
87-
- name: Login to Docker Hub
88-
uses: docker/login-action@v3
89-
with:
90-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
91-
password: ${{ secrets.DOCKER_HUB_TOKEN }}
92-
93-
- name: Build and push Docker image
94-
uses: docker/build-push-action@v4
95-
with:
96-
context: .
97-
push: true
98-
tags: |
99-
${{ env.DOCKER_HUB_USERNAME }}/${{ env.DOCKER_HUB_REPOSITORY }}:${{ env.IMAGE_TAG }}
100-
${{ env.DOCKER_HUB_USERNAME }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest
56+
name: browser-build
57+
path: ./browser
58+
59+
- name: Install Azure CLI
60+
run: |
61+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
62+
63+
- name: Login to Azure
64+
run: |
65+
az storage account show \
66+
--name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \
67+
--query 'name' \
68+
--output tsv
69+
env:
70+
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}
71+
AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }}
72+
73+
- name: Enable static website hosting
74+
run: |
75+
az storage blob service-properties update \
76+
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \
77+
--account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \
78+
--static-website \
79+
--index-document index.html \
80+
--404-document index.html
81+
82+
- name: Upload files to Azure Storage
83+
run: |
84+
# Upload index.html with short cache (5 minutes)
85+
az storage blob upload-batch \
86+
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \
87+
--account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \
88+
--destination '$web' \
89+
--source ./browser \
90+
--pattern "index.html" \
91+
--content-cache-control "public, max-age=300, must-revalidate" \
92+
--overwrite
93+
94+
# Upload hashed JS/CSS files with long cache (1 year)
95+
az storage blob upload-batch \
96+
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \
97+
--account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \
98+
--destination '$web' \
99+
--source ./browser \
100+
--pattern "*.js" \
101+
--content-cache-control "public, max-age=31536000, immutable" \
102+
--overwrite
103+
104+
az storage blob upload-batch \
105+
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \
106+
--account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \
107+
--destination '$web' \
108+
--source ./browser \
109+
--pattern "*.css" \
110+
--content-cache-control "public, max-age=31536000, immutable" \
111+
--overwrite
112+
113+
# Upload all other files with medium cache (1 day)
114+
az storage blob upload-batch \
115+
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \
116+
--account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \
117+
--destination '$web' \
118+
--source ./browser \
119+
--content-cache-control "public, max-age=86400" \
120+
--overwrite
121+
122+
- name: Display deployment URL
123+
run: |
124+
echo "🚀 Deployment successful!"
125+
echo "Static website URL: https://${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}.z13.web.core.windows.net/"
126+
echo "Note: The exact URL format depends on your Azure region."

README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,80 @@ All tools feature:
9595

9696
- `npm start` - Start development server
9797
- `npm run build` - Production build
98-
- `npm run build:ci` - CI production build
98+
- `npm run build:ci` - CI production build
9999
- `npm test` - Run unit tests
100100
- `npm run lint` - Run ESLint
101101
- `npm run serve:ssr:utilplex` - Serve SSR build
102102

103+
## Deployment
104+
105+
UtilPlex is configured for automated deployment to Azure Storage static website hosting via GitHub Actions.
106+
107+
### Azure Storage Setup
108+
109+
1. **Create Azure Storage Account**:
110+
```bash
111+
az storage account create \
112+
--name <your-storage-account-name> \
113+
--resource-group <your-resource-group> \
114+
--location <your-region> \
115+
--sku Standard_LRS \
116+
--kind StorageV2
117+
```
118+
119+
2. **Enable Static Website Hosting**:
120+
```bash
121+
az storage blob service-properties update \
122+
--account-name <your-storage-account-name> \
123+
--static-website \
124+
--index-document index.html \
125+
--404-document index.html
126+
```
127+
128+
3. **Get Storage Account Key**:
129+
```bash
130+
az storage account keys list \
131+
--account-name <your-storage-account-name> \
132+
--query "[0].value" \
133+
--output tsv
134+
```
135+
136+
### GitHub Secrets Configuration
137+
138+
Add the following secrets to your GitHub repository (Settings → Secrets and variables → Actions):
139+
140+
- `AZURE_STORAGE_ACCOUNT_NAME` - Your Azure Storage account name
141+
- `AZURE_STORAGE_ACCOUNT_KEY` - Your Azure Storage account access key
142+
143+
### Deployment Workflow
144+
145+
The GitHub Actions workflow automatically:
146+
1. Builds the Angular application on push to `main` branch
147+
2. Deploys pre-rendered static files to Azure Storage `$web` container
148+
3. Configures optimal cache headers:
149+
- `index.html`: 5 minutes (frequent updates)
150+
- Hashed JS/CSS: 1 year (immutable content)
151+
- Other assets: 1 day (moderate caching)
152+
153+
### Manual Deployment
154+
155+
To deploy manually:
156+
```bash
157+
# Build the application
158+
npm run build:ci
159+
160+
# Upload to Azure Storage
161+
az storage blob upload-batch \
162+
--account-name <your-storage-account-name> \
163+
--account-key <your-storage-account-key> \
164+
--destination '$web' \
165+
--source dist/utilplex/browser/
166+
```
167+
168+
Your site will be available at: `https://<your-storage-account-name>.z13.web.core.windows.net/`
169+
170+
Note: The exact URL format depends on your Azure region. Check your storage account properties for the correct endpoint.
171+
103172
### Project Structure
104173

105174
```

0 commit comments

Comments
 (0)