Skip to content

Commit b1744bd

Browse files
committed
Work on version 2
0 parents  commit b1744bd

File tree

158 files changed

+26194
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+26194
-0
lines changed

.github/workflows/README.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Rukhalt GitHub Actions Workflows
2+
3+
This directory contains CI/CD workflows for building and deploying Rukhalt components.
4+
5+
## Workflows
6+
7+
### 🔧 build-server.yml
8+
Builds and pushes the backend server Docker image to GitHub Container Registry.
9+
10+
**Triggers:**
11+
- Push to `main` branch with changes in `server/` directory
12+
- Tags matching `server-v*.*.*` pattern
13+
- Manual workflow dispatch
14+
15+
**Output:**
16+
- Image: `ghcr.io/OWNER/REPO-server:latest`
17+
- Platforms: linux/amd64, linux/arm64
18+
- Size: ~46MB (12MB compressed)
19+
20+
### 🎨 build-client.yml
21+
Builds and pushes the frontend client Docker image to GitHub Container Registry.
22+
23+
**Triggers:**
24+
- Push to `main` branch with changes in `client/` directory
25+
- Tags matching `client-v*.*.*` pattern
26+
- Manual workflow dispatch
27+
28+
**Output:**
29+
- Image: `ghcr.io/OWNER/REPO-client:latest`
30+
- Platforms: linux/amd64, linux/arm64
31+
- Size: ~75MB (20MB compressed)
32+
33+
## Features
34+
35+
**Smart Change Detection**: Only builds images when relevant files change
36+
**Multi-platform**: Builds for both AMD64 and ARM64 architectures
37+
**Layer Caching**: Uses GitHub Actions cache for faster builds
38+
**Automatic Tagging**: Creates semantic version tags and SHA-based tags
39+
**Infrastructure Integration**: Triggers deployment in nesohq-infra repository
40+
41+
## Configuration
42+
43+
### Required Secrets
44+
45+
Set these in your GitHub repository settings:
46+
47+
#### For Client Build
48+
- `VITE_API_URL` (optional): API endpoint URL
49+
- Default: `https://api.rukhalt.nesohq.org/api/v1`
50+
- Example: `https://api.rukhalt.nesohq.org/api/v1`
51+
52+
#### For Infrastructure Deployment
53+
- `INFRA_REPO_TOKEN`: GitHub Personal Access Token with `repo` scope
54+
- Used to trigger deployments in `opskraken/nesohq-infra`
55+
- Create at: https://github.com/settings/tokens
56+
57+
### Image Tags
58+
59+
Images are tagged with multiple formats:
60+
61+
1. **Branch name**: `main`, `develop`
62+
2. **Semantic version**: `v1.0.0`, `v1.0`, `v1`
63+
3. **Git SHA**: `main-abc1234`
64+
4. **Latest**: `latest` (only for main branch)
65+
66+
## Usage
67+
68+
### Manual Trigger
69+
70+
You can manually trigger builds from the Actions tab:
71+
72+
1. Go to Actions → Select workflow
73+
2. Click "Run workflow"
74+
3. Select branch
75+
4. Click "Run workflow"
76+
77+
### Version Release
78+
79+
Create a new release:
80+
81+
```bash
82+
# Server release
83+
git tag server-v1.0.0
84+
git push origin server-v1.0.0
85+
86+
# Client release
87+
git tag client-v1.0.0
88+
git push origin client-v1.0.0
89+
```
90+
91+
### Pull Images
92+
93+
```bash
94+
# Server
95+
docker pull ghcr.io/OWNER/REPO-server:latest
96+
97+
# Client
98+
docker pull ghcr.io/OWNER/REPO-client:latest
99+
```
100+
101+
## Build Optimization
102+
103+
Both workflows use:
104+
- Docker Buildx for multi-platform builds
105+
- GitHub Actions cache for layer caching
106+
- Multi-stage builds for minimal image size
107+
- Parallel builds for faster CI/CD
108+
109+
## Deployment Flow
110+
111+
```
112+
┌─────────────┐
113+
│ Push to main│
114+
└──────┬──────┘
115+
116+
├─────────────────┬─────────────────┐
117+
│ │ │
118+
▼ ▼ ▼
119+
Changes in Changes in No changes
120+
server/ client/
121+
│ │
122+
▼ ▼
123+
Build Server Build Client
124+
│ │
125+
▼ ▼
126+
Push to GHCR Push to GHCR
127+
│ │
128+
▼ ▼
129+
Trigger Infra Trigger Infra
130+
Deployment Deployment
131+
```
132+
133+
## Troubleshooting
134+
135+
### Build Fails
136+
137+
1. Check workflow logs in Actions tab
138+
2. Verify Dockerfile syntax
139+
3. Test build locally:
140+
```bash
141+
docker build -f server/Dockerfile server/
142+
docker build -f client/Dockerfile client/
143+
```
144+
145+
### Image Not Found
146+
147+
1. Check if workflow completed successfully
148+
2. Verify package visibility (should be public)
149+
3. Check image name format
150+
151+
### Deployment Not Triggered
152+
153+
1. Verify `INFRA_REPO_TOKEN` secret is set
154+
2. Check token has `repo` scope
155+
3. Verify infrastructure repository exists
156+
157+
## Monitoring
158+
159+
View build status:
160+
- Badge: `![Build Status](https://github.com/OWNER/REPO/workflows/Build%20and%20Push%20Server%20Image/badge.svg)`
161+
- Actions tab: https://github.com/OWNER/REPO/actions
162+
163+
## Best Practices
164+
165+
1. **Test locally first**: Always test Docker builds locally before pushing
166+
2. **Use semantic versioning**: Tag releases with proper version numbers
167+
3. **Monitor build times**: Optimize if builds take too long
168+
4. **Check image sizes**: Keep images as small as possible
169+
5. **Review logs**: Check workflow logs for warnings or issues
170+
171+
## Support
172+
173+
For issues or questions:
174+
- Check workflow logs
175+
- Review Dockerfile changes
176+
- Open an issue in the repository

.github/workflows/build-client.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and Push Client Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'client/**'
8+
- '.github/workflows/build-client.yml'
9+
tags:
10+
- 'client-v*.*.*'
11+
workflow_dispatch:
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}-client
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: 📥 Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: 🔧 Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: 🔐 Login to GitHub Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: 🏷️ Extract metadata
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=sha,prefix={{branch}}-
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
50+
- name: 🐳 Build and push Client image
51+
uses: docker/build-push-action@v5
52+
with:
53+
context: ./client
54+
file: ./client/Dockerfile
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
build-args: |
59+
VITE_API_URL=${{ secrets.VITE_API_URL || 'https://api.rukhalt.nesohq.org/api/v1' }}
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max
62+
platforms: linux/amd64,linux/arm64
63+
64+
- name: 🚀 Trigger Infrastructure Deployment
65+
if: success() && github.ref == 'refs/heads/main'
66+
run: |
67+
curl -X POST \
68+
-H "Authorization: token ${{ secrets.INFRA_REPO_TOKEN }}" \
69+
-H "Accept: application/vnd.github.v3+json" \
70+
https://api.github.com/repos/opskraken/nesohq-infra/dispatches \
71+
-d '{"event_type":"deploy-rukhalt-client-staging"}'
72+
73+
- name: 🎉 Deployment triggered
74+
if: success() && github.ref == 'refs/heads/main'
75+
run: |
76+
echo "✅ Client image built and pushed successfully!"
77+
echo "🚀 Infrastructure deployment triggered for staging environment"
78+
echo "📦 Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
79+
echo "🌐 API URL: ${{ secrets.VITE_API_URL || 'https://api.rukhalt.nesohq.org/api/v1' }}"

.github/workflows/build-server.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and Push Server Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'server/**'
8+
- '.github/workflows/build-server.yml'
9+
tags:
10+
- 'server-v*.*.*'
11+
workflow_dispatch:
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}-server
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: 📥 Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: 🔧 Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: 🔐 Login to GitHub Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: 🏷️ Extract metadata
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=sha,prefix={{branch}}-
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
50+
- name: 🐳 Build and push Server image
51+
uses: docker/build-push-action@v5
52+
with:
53+
context: ./server
54+
file: ./server/Dockerfile
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
platforms: linux/amd64,linux/arm64
61+
62+
- name: 🚀 Trigger Infrastructure Deployment
63+
if: success() && github.ref == 'refs/heads/main'
64+
run: |
65+
curl -X POST \
66+
-H "Authorization: token ${{ secrets.INFRA_REPO_TOKEN }}" \
67+
-H "Accept: application/vnd.github.v3+json" \
68+
https://api.github.com/repos/opskraken/nesohq-infra/dispatches \
69+
-d '{"event_type":"deploy-rukhalt-server-staging"}'
70+
71+
- name: 🎉 Deployment triggered
72+
if: success() && github.ref == 'refs/heads/main'
73+
run: |
74+
echo "✅ Server image built and pushed successfully!"
75+
echo "🚀 Infrastructure deployment triggered for staging environment"
76+
echo "📦 Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
77+
echo "🔍 Size: $(docker images ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest --format '{{.Size}}')"

.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Environment files
2+
.env
3+
.env.local
4+
.env.*.local
5+
*.env
6+
7+
# Dependencies
8+
node_modules/
9+
vendor/
10+
11+
# Build outputs
12+
dist/
13+
build/
14+
*.out
15+
*.exe
16+
17+
# Logs
18+
logs/
19+
*.log
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
pnpm-debug.log*
24+
25+
# Backups
26+
backups/
27+
*.bak
28+
*.backup
29+
30+
# Go specific
31+
server/tmp/
32+
*.test
33+
coverage.txt
34+
coverage.html
35+
36+
# OS
37+
.DS_Store
38+
Thumbs.db
39+
*.swp
40+
*.swo
41+
*~
42+
43+
# IDE
44+
.vscode/
45+
.idea/
46+
*.iml
47+
48+
# Temporary files
49+
tmp/
50+
temp/
51+
*.tmp
52+
53+
# Database
54+
*.db
55+
*.sqlite
56+
*.sqlite3
57+
58+
# Docker
59+
.dockerignore

0 commit comments

Comments
 (0)