fix: add database, Redis, and service integrations to Game Engine #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Game Engine CI/CD | |
| on: | |
| push: | |
| paths: | |
| - 'monopoly/game-engine/**' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: ./monopoly/game-engine | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: jeffreyxu2025/monopoly-game-engine:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Generate deployment manifest | |
| run: | | |
| mkdir -p infra-dev/manifests | |
| cat > infra-dev/manifests/game-engine.yaml << EOF | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: game-engine | |
| namespace: monopoly-game | |
| labels: | |
| app: game-engine | |
| spec: | |
| replicas: 2 | |
| selector: | |
| matchLabels: | |
| app: game-engine | |
| template: | |
| metadata: | |
| labels: | |
| app: game-engine | |
| spec: | |
| containers: | |
| - name: game-engine | |
| image: jeffreyxu2025/monopoly-game-engine:${{ github.sha }} | |
| ports: | |
| - containerPort: 3001 | |
| env: | |
| - name: PORT | |
| value: "3001" | |
| - name: DB_HOST | |
| valueFrom: | |
| secretKeyRef: | |
| name: db-credentials | |
| key: host | |
| - name: DB_PORT | |
| valueFrom: | |
| secretKeyRef: | |
| name: db-credentials | |
| key: port | |
| - name: DB_NAME | |
| value: "monopoly_game" | |
| - name: DB_USER | |
| valueFrom: | |
| secretKeyRef: | |
| name: db-credentials | |
| key: username | |
| - name: DB_PASSWORD | |
| valueFrom: | |
| secretKeyRef: | |
| name: db-credentials | |
| key: password | |
| - name: REDIS_HOST | |
| value: "monopoly-dev-redis.f2xiko.ng.0001.usw2.cache.amazonaws.com" | |
| - name: REDIS_PORT | |
| value: "6379" | |
| - name: USER_SERVICE_URL | |
| value: "http://user-service:3002" | |
| - name: NOTIFICATION_SERVICE_URL | |
| value: "http://notification-service:3004" | |
| resources: | |
| requests: | |
| memory: "256Mi" | |
| cpu: "200m" | |
| limits: | |
| memory: "512Mi" | |
| cpu: "400m" | |
| livenessProbe: | |
| httpGet: | |
| path: /health | |
| port: 3001 | |
| initialDelaySeconds: 30 | |
| periodSeconds: 10 | |
| readinessProbe: | |
| httpGet: | |
| path: /health | |
| port: 3001 | |
| initialDelaySeconds: 5 | |
| periodSeconds: 5 | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: game-engine-service | |
| namespace: monopoly-game | |
| spec: | |
| selector: | |
| app: game-engine | |
| ports: | |
| - port: 3001 | |
| targetPort: 3001 | |
| type: ClusterIP | |
| EOF | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-west-2 | |
| - name: Deploy Game Engine | |
| run: | | |
| aws eks update-kubeconfig --region us-west-2 --name monopoly-dev-jxre | |
| kubectl apply -f infra-dev/manifests/game-engine.yaml |