Refactor auth-service to iam-service and update related configurations
- Renamed auth-service to iam-service across various files for consistency. - Updated deployment workflows, database migration scripts, and documentation to reflect the service name change. - Enhanced bilingual documentation for clarity on the new service structure and usage. - Removed outdated references to auth-service in scripts and configuration files to streamline the project structure.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
name: Auth Service CI
|
||||
name: IAM Service CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'services/auth-service/**'
|
||||
- 'services/iam-service/**'
|
||||
- 'packages/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'services/auth-service/**'
|
||||
- 'services/iam-service/**'
|
||||
- 'packages/**'
|
||||
|
||||
jobs:
|
||||
@@ -48,26 +48,26 @@ jobs:
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Generate Prisma Client
|
||||
run: pnpm --filter @goodgo/auth-service prisma:generate
|
||||
run: pnpm --filter @goodgo/iam-service prisma:generate
|
||||
env:
|
||||
# Use Neon test DB if available, otherwise fallback to local PostgreSQL
|
||||
DATABASE_URL: ${{ secrets.NEON_DATABASE_URL_TEST != '' && secrets.NEON_DATABASE_URL_TEST || 'postgresql://testuser:testpass@localhost:5432/test_db' }}
|
||||
|
||||
- name: Run migrations
|
||||
run: pnpm --filter @goodgo/auth-service prisma migrate deploy
|
||||
run: pnpm --filter @goodgo/iam-service prisma migrate deploy
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.NEON_DATABASE_URL_TEST != '' && secrets.NEON_DATABASE_URL_TEST || 'postgresql://testuser:testpass@localhost:5432/test_db' }}
|
||||
|
||||
- name: Lint
|
||||
run: pnpm --filter @goodgo/auth-service lint
|
||||
run: pnpm --filter @goodgo/iam-service lint
|
||||
|
||||
- name: Type check
|
||||
run: pnpm --filter @goodgo/auth-service typecheck
|
||||
run: pnpm --filter @goodgo/iam-service typecheck
|
||||
|
||||
- name: Build
|
||||
run: pnpm --filter @goodgo/auth-service build
|
||||
run: pnpm --filter @goodgo/iam-service build
|
||||
|
||||
- name: Test
|
||||
run: pnpm --filter @goodgo/auth-service test
|
||||
run: pnpm --filter @goodgo/iam-service test
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.NEON_DATABASE_URL_TEST != '' && secrets.NEON_DATABASE_URL_TEST || 'postgresql://testuser:testpass@localhost:5432/test_db' }}
|
||||
10
.github/workflows/deploy-production.yml
vendored
10
.github/workflows/deploy-production.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
- name: Run database migrations
|
||||
run: |
|
||||
cd services/auth-service
|
||||
cd services/iam-service
|
||||
pnpm prisma generate
|
||||
pnpm prisma migrate deploy
|
||||
env:
|
||||
@@ -43,13 +43,13 @@ jobs:
|
||||
echo "${{ secrets.KUBECONFIG_PRODUCTION }}" | base64 -d > kubeconfig
|
||||
export KUBECONFIG=./kubeconfig
|
||||
|
||||
- name: Deploy Auth Service
|
||||
- name: Deploy IAM Service
|
||||
run: |
|
||||
export KUBECONFIG=./kubeconfig
|
||||
kubectl apply -f deployments/production/kubernetes/auth-service.yaml
|
||||
kubectl apply -f deployments/production/kubernetes/configmap.yaml
|
||||
kubectl apply -f deployments/production/kubernetes/iam-service.yaml
|
||||
kubectl apply -f deployments/production/kubernetes/iam-service-configmap.yaml
|
||||
kubectl apply -f deployments/production/kubernetes/ingress.yaml
|
||||
kubectl rollout status deployment/auth-service -n production
|
||||
kubectl rollout status deployment/iam-service -n production
|
||||
|
||||
- name: Deploy Web App
|
||||
run: |
|
||||
|
||||
10
.github/workflows/deploy-staging.yml
vendored
10
.github/workflows/deploy-staging.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
|
||||
- name: Run database migrations
|
||||
run: |
|
||||
cd services/auth-service
|
||||
cd services/iam-service
|
||||
pnpm prisma generate
|
||||
pnpm prisma migrate deploy
|
||||
env:
|
||||
@@ -42,13 +42,13 @@ jobs:
|
||||
echo "${{ secrets.KUBECONFIG_STAGING }}" | base64 -d > kubeconfig
|
||||
export KUBECONFIG=./kubeconfig
|
||||
|
||||
- name: Deploy Auth Service
|
||||
- name: Deploy IAM Service
|
||||
run: |
|
||||
export KUBECONFIG=./kubeconfig
|
||||
kubectl apply -f deployments/staging/kubernetes/auth-service.yaml
|
||||
kubectl apply -f deployments/staging/kubernetes/configmap.yaml
|
||||
kubectl apply -f deployments/staging/kubernetes/iam-service.yaml
|
||||
kubectl apply -f deployments/staging/kubernetes/iam-service-configmap.yaml
|
||||
kubectl apply -f deployments/staging/kubernetes/ingress.yaml
|
||||
kubectl rollout status deployment/auth-service -n staging
|
||||
kubectl rollout status deployment/iam-service -n staging
|
||||
|
||||
- name: Deploy Web App
|
||||
run: |
|
||||
|
||||
16
.github/workflows/docker-build.yml
vendored
16
.github/workflows/docker-build.yml
vendored
@@ -6,12 +6,12 @@ on:
|
||||
- main
|
||||
- develop
|
||||
paths:
|
||||
- 'services/auth-service/**'
|
||||
- 'services/iam-service/**'
|
||||
- 'apps/web-*/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-auth-service:
|
||||
build-iam-service:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -25,16 +25,16 @@ jobs:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push Auth Service
|
||||
- name: Build and push IAM Service
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./services/auth-service
|
||||
context: ./services/iam-service
|
||||
push: true
|
||||
tags: |
|
||||
goodgo/auth-service:latest
|
||||
goodgo/auth-service:${{ github.sha }}
|
||||
cache-from: type=registry,ref=goodgo/auth-service:buildcache
|
||||
cache-to: type=registry,ref=goodgo/auth-service:buildcache,mode=max
|
||||
goodgo/iam-service:latest
|
||||
goodgo/iam-service:${{ github.sha }}
|
||||
cache-from: type=registry,ref=goodgo/iam-service:buildcache
|
||||
cache-to: type=registry,ref=goodgo/iam-service:buildcache,mode=max
|
||||
|
||||
build-web-admin:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -23,7 +23,7 @@ Monorepo này tuân theo mô hình kiến trúc microservices với:
|
||||
│ ├── app-admin/ # App admin (Flutter)
|
||||
│ └── app-client/ # App client (Flutter)
|
||||
├── services/ # Backend microservices
|
||||
│ ├── auth-service/ # Dịch vụ xác thực (Node.js)
|
||||
│ ├── iam-service/ # Dịch vụ IAM (Identity & Access Management) (Node.js)
|
||||
│ └── _template/ # Template mẫu cho service mới
|
||||
├── packages/ # Thư viện dùng chung
|
||||
│ ├── auth-sdk/ # Tiện ích xác thực và guards
|
||||
@@ -107,14 +107,14 @@ pnpm prisma:generate
|
||||
|
||||
3. **Chạy Migrations**:
|
||||
```bash
|
||||
./scripts/db/migrate.sh auth-service dev
|
||||
./scripts/db/migrate.sh iam-service dev
|
||||
```
|
||||
|
||||
4. **Khởi động Services**:
|
||||
```bash
|
||||
./scripts/dev/start-all.sh
|
||||
# Hoặc khởi động service cụ thể:
|
||||
# ./scripts/dev/start-service.sh auth-service
|
||||
# ./scripts/dev/start-service.sh iam-service
|
||||
```
|
||||
|
||||
## 🛠️ Các Script Hỗ trợ
|
||||
|
||||
@@ -76,7 +76,7 @@ EMAIL_FROM=noreply@goodgo.vn
|
||||
# ---------------------------------
|
||||
# The following are defined PER SERVICE in docker-compose.yml:
|
||||
# - PORT: Unique port for each service (5001, 5002, 5003, etc.)
|
||||
# - SERVICE_NAME: Service identifier (auth-service, user-service, etc.)
|
||||
# - SERVICE_NAME: Service identifier (iam-service, user-service, etc.)
|
||||
# - DATABASE_URL: Can override for service-specific database
|
||||
#
|
||||
# Traefik API Gateway:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Use this as a template to create secrets
|
||||
|
||||
# Create secret using kubectl:
|
||||
# kubectl create secret generic auth-service-secrets \
|
||||
# kubectl create secret generic iam-service-secrets \
|
||||
# --from-literal=database-url='postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=true' \
|
||||
# --from-literal=jwt-secret='your-production-jwt-secret-min-32-chars' \
|
||||
# --from-literal=jwt-refresh-secret='your-production-refresh-secret-min-32-chars' \
|
||||
@@ -18,7 +18,7 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: auth-service-secrets
|
||||
name: iam-service-secrets
|
||||
namespace: production
|
||||
type: Opaque
|
||||
stringData:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Use this as a template to create secrets
|
||||
|
||||
# Create secret using kubectl:
|
||||
# kubectl create secret generic auth-service-secrets \
|
||||
# kubectl create secret generic iam-service-secrets \
|
||||
# --from-literal=database-url='postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=true' \
|
||||
# --from-literal=jwt-secret='your-staging-jwt-secret-min-32-chars' \
|
||||
# --from-literal=jwt-refresh-secret='your-staging-refresh-secret-min-32-chars' \
|
||||
@@ -18,7 +18,7 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: auth-service-secrets
|
||||
name: iam-service-secrets
|
||||
namespace: staging
|
||||
type: Opaque
|
||||
stringData:
|
||||
|
||||
@@ -67,7 +67,7 @@ postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=
|
||||
### Development
|
||||
|
||||
```bash
|
||||
cd services/auth-service
|
||||
cd services/iam-service
|
||||
pnpm prisma migrate dev
|
||||
```
|
||||
|
||||
|
||||
@@ -59,6 +59,6 @@ echo ""
|
||||
echo "1. Add staging URL to GitHub Secrets: NEON_DATABASE_URL_STAGING"
|
||||
echo "2. Add production URL to GitHub Secrets: NEON_DATABASE_URL_PRODUCTION"
|
||||
echo "3. Create Kubernetes secrets for staging/production"
|
||||
echo "4. Run migrations: ./scripts/db/migrate.sh auth-service dev"
|
||||
echo "4. Run migrations: ./scripts/db/migrate.sh iam-service dev"
|
||||
echo ""
|
||||
echo "✅ Setup complete! See infra/databases/neon/README.md for details."
|
||||
|
||||
@@ -14,7 +14,7 @@ logger.error('Error occurred', { error: err });
|
||||
// Create custom logger
|
||||
const customLogger = createLogger({
|
||||
level: 'debug',
|
||||
serviceName: 'auth-service',
|
||||
serviceName: 'iam-service',
|
||||
enableFile: true,
|
||||
logDir: './logs',
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import { initTracing } from '@goodgo/tracing';
|
||||
|
||||
// Initialize tracing at application startup
|
||||
initTracing({
|
||||
serviceName: 'auth-service',
|
||||
serviceName: 'iam-service',
|
||||
jaegerEndpoint: process.env.JAEGER_ENDPOINT,
|
||||
enabled: process.env.TRACING_ENABLED === 'true',
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ BACKUP_DIR="${2:-./backups}"
|
||||
# VI: Xác thực tham số
|
||||
if [ -z "$SERVICE" ]; then
|
||||
echo "Usage: $0 <service-name> [backup-dir]"
|
||||
echo "Example: $0 auth-service"
|
||||
echo "Example: $0 iam-service"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ SERVICE=$1
|
||||
# VI: Xác thực tham số tên service
|
||||
if [ -z "$SERVICE" ]; then
|
||||
echo "Usage: $0 <service-name> [dev|deploy] / Cách dùng: $0 <tên-service> [dev|deploy]"
|
||||
echo "Example: $0 auth-service dev / Ví dụ: $0 auth-service dev"
|
||||
echo "Example: $0 auth-service deploy / Ví dụ: $0 auth-service deploy"
|
||||
echo "Example: $0 iam-service dev / Ví dụ: $0 iam-service dev"
|
||||
echo "Example: $0 iam-service deploy / Ví dụ: $0 iam-service deploy"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ SERVICE=$1
|
||||
# VI: Xác thực tham số
|
||||
if [ -z "$SERVICE" ]; then
|
||||
echo "Usage: $0 <service-name>"
|
||||
echo "Example: $0 auth-service"
|
||||
echo "Example: $0 iam-service"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -63,10 +63,10 @@ echo " See: deployments/staging/kubernetes/secrets.yaml.example"
|
||||
echo " See: deployments/production/kubernetes/secrets.yaml.example"
|
||||
echo ""
|
||||
echo "3. Run initial migration:"
|
||||
echo " ./scripts/db/migrate.sh auth-service dev"
|
||||
echo " ./scripts/db/migrate.sh iam-service dev"
|
||||
echo ""
|
||||
echo "4. Seed database (optional):"
|
||||
echo " ./scripts/db/seed.sh auth-service"
|
||||
echo " ./scripts/db/seed.sh iam-service"
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ Setup instructions complete!${NC}"
|
||||
echo ""
|
||||
|
||||
@@ -26,6 +26,6 @@ fi
|
||||
# EN: Apply Kubernetes configurations and wait for rollout
|
||||
# VI: Áp dụng cấu hình Kubernetes và đợi quá trình rollout hoàn tất
|
||||
kubectl apply -f deployments/production/kubernetes/
|
||||
kubectl rollout status deployment/auth-service -n production
|
||||
kubectl rollout status deployment/iam-service -n production
|
||||
|
||||
echo "✅ Deployment completed!"
|
||||
|
||||
@@ -14,6 +14,6 @@ fi
|
||||
# EN: Apply Kubernetes configurations and wait for rollout
|
||||
# VI: Áp dụng cấu hình Kubernetes và đợi quá trình rollout hoàn tất
|
||||
kubectl apply -f deployments/staging/kubernetes/
|
||||
kubectl rollout status deployment/auth-service -n staging
|
||||
kubectl rollout status deployment/iam-service -n staging
|
||||
|
||||
echo "✅ Deployment completed!"
|
||||
|
||||
@@ -6,7 +6,7 @@ SERVICE=$1
|
||||
# VI: Kiểm tra cách sử dụng
|
||||
if [ -z "$SERVICE" ]; then
|
||||
echo "Usage: $0 <service-name> / Cách dùng: $0 <tên-service>"
|
||||
echo "Example: $0 auth-service"
|
||||
echo "Example: $0 iam-service"
|
||||
echo ""
|
||||
echo "Or use 'docker' to view Docker logs: / Hoặc dùng 'docker' để xem log Docker:"
|
||||
echo " $0 docker <container-name>"
|
||||
|
||||
@@ -92,12 +92,12 @@ echo " - Set DATABASE_URL from Neon Console"
|
||||
echo " - Each service needs its own database"
|
||||
echo ""
|
||||
echo "3. Create databases in Neon:"
|
||||
echo " - goodgo_auth_dev (for auth-service)"
|
||||
echo " - goodgo_iam_dev (for iam-service)"
|
||||
echo " - goodgo_user_dev (for user-service)"
|
||||
echo " - etc."
|
||||
echo ""
|
||||
echo "4. Run migrations:"
|
||||
echo " ./scripts/db/migrate.sh auth-service dev"
|
||||
echo " ./scripts/db/migrate.sh iam-service dev"
|
||||
echo ""
|
||||
echo "5. Start development:"
|
||||
echo " ./scripts/dev/start-all.sh"
|
||||
|
||||
@@ -8,7 +8,7 @@ SERVICE=$1
|
||||
# VI: Xác thực tham số
|
||||
if [ -z "$SERVICE" ]; then
|
||||
echo "Usage: $0 <service-name>"
|
||||
echo "Example: $0 auth-service"
|
||||
echo "Example: $0 iam-service"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -23,16 +23,15 @@ pnpm install
|
||||
# EN: Generate Prisma clients
|
||||
# VI: Tạo Prisma generic clients
|
||||
echo "🔧 Generating Prisma clients..."
|
||||
cd services/auth-service
|
||||
cd services/iam-service
|
||||
pnpm prisma:generate || echo "⚠️ Prisma generation skipped (database not available)"
|
||||
cd ../..
|
||||
|
||||
# EN: Setup environment files
|
||||
# VI: Thiết lập các file biến môi trường
|
||||
echo "📝 Setting up environment files..."
|
||||
if [ ! -f "services/auth-service/.env" ]; then
|
||||
cp services/auth-service/env.example services/auth-service/.env
|
||||
echo "✅ Created services/auth-service/.env"
|
||||
if [ ! -f "services/iam-service/.env" ]; then
|
||||
cp services/iam-service/env.local.example services/iam-service/.env.local 2>/dev/null || echo "⚠️ IAM service .env file not found"
|
||||
fi
|
||||
|
||||
if [ ! -f "deployments/local/.env.local" ]; then
|
||||
@@ -55,8 +54,8 @@ echo "Next steps:"
|
||||
echo "1. Setup Neon database: ./scripts/db/setup-neon.sh"
|
||||
echo "2. Update .env files with your Neon DATABASE_URL"
|
||||
echo "3. Start all services: ./scripts/dev/start-all.sh"
|
||||
echo "4. Run migrations: ./scripts/db/migrate.sh auth-service dev"
|
||||
echo "5. Seed database: ./scripts/db/seed.sh auth-service"
|
||||
echo "4. Run migrations: ./scripts/db/migrate.sh iam-service dev"
|
||||
echo "5. Seed database: ./scripts/db/seed.sh iam-service"
|
||||
echo "6. Start services: pnpm dev"
|
||||
echo ""
|
||||
echo "📚 See infra/databases/neon/README.md for Neon setup details"
|
||||
|
||||
@@ -122,7 +122,7 @@ curl -X GET "http://localhost:4000/api/v1/rbac/permissions/check?resource=users&
|
||||
|
||||
```bash
|
||||
cd ../../deployments/local
|
||||
docker-compose up -d auth-service
|
||||
docker-compose up -d iam-service
|
||||
```
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
Reference in New Issue
Block a user