Allow client .env into Docker build debug #36
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: CI & Docker | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - lorenc-ci | |
| - paython-mcp | |
| - feature/configure-chat-ui | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: | | |
| cd server | |
| npm ci | |
| - name: Run tests | |
| run: | | |
| cd server | |
| npm test --if-present | |
| #backend image | |
| docker-image: | |
| needs: build-test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE_NAME: mcp-backend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Docker image | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
| VERSION=${{ github.sha }} | |
| echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| docker build -t $IMAGE_ID:$VERSION -t $IMAGE_ID:latest . | |
| - name: Push Docker image | |
| run: | | |
| docker push $IMAGE_ID:$VERSION | |
| docker push $IMAGE_ID:latest | |
| #frontend image | |
| frontend-docker-image: | |
| needs: build-test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE_NAME: mcp-frontend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build frontend Docker image | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
| VERSION=${{ github.sha }} | |
| echo "FRONTEND_IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV | |
| echo "FRONTEND_VERSION=$VERSION" >> $GITHUB_ENV | |
| docker build -f Dockerfile.frontend \ | |
| --build-arg VITE_API_BASE_URL=${{ secrets.FRONTEND_API_BASE_URL }} \ | |
| -t $IMAGE_ID:$VERSION -t $IMAGE_ID:latest . | |
| - name: Push frontend Docker image | |
| run: | | |
| docker push $FRONTEND_IMAGE_ID:$FRONTEND_VERSION | |
| docker push $FRONTEND_IMAGE_ID:latest | |
| #backend cloud deployment | |
| deploy-gcp: | |
| needs: docker-image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | |
| - name: Set up gcloud | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| project_id: ${{ secrets.GCP_PROJECT_ID }} | |
| - name: Configure Docker for Artifact Registry | |
| run: | | |
| gcloud auth configure-docker us-east1-docker.pkg.dev --quiet | |
| - name: Pull image from GHCR | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ github.repository_owner }}/mcp-backend | |
| VERSION=${{ github.sha }} | |
| echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin | |
| docker pull $IMAGE_ID:$VERSION | |
| - name: Tag and push image to Artifact Registry | |
| run: | | |
| AR_IMAGE=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/mcp-backend/mcp-backend | |
| docker tag ghcr.io/${{ github.repository_owner }}/mcp-backend:${{ github.sha }} $AR_IMAGE:${{ github.sha }} | |
| docker push $AR_IMAGE:${{ github.sha }} | |
| echo "AR_IMAGE=$AR_IMAGE" >> $GITHUB_ENV | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy mcp-backend \ | |
| --image $AR_IMAGE:${{ github.sha }} \ | |
| --region ${{ secrets.GCP_REGION }} \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --port 3000 | |
| # frontend cloud deployment | |
| deploy-gcp-frontend: | |
| needs: frontend-docker-image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | |
| - name: Set up gcloud | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| project_id: ${{ secrets.GCP_PROJECT_ID }} | |
| - name: Configure Docker for Artifact Registry | |
| run: | | |
| gcloud auth configure-docker us-east1-docker.pkg.dev --quiet | |
| - name: Pull frontend image from GHCR | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ github.repository_owner }}/mcp-frontend | |
| VERSION=${{ github.sha }} | |
| echo "FRONTEND_IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV | |
| echo "FRONTEND_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin | |
| docker pull $IMAGE_ID:$VERSION | |
| - name: Tag & push frontend image to Artifact Registry | |
| run: | | |
| AR_FRONTEND_IMAGE=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/mcp-frontend/mcp-frontend | |
| docker tag ghcr.io/${{ github.repository_owner }}/mcp-frontend:${{ github.sha }} $AR_FRONTEND_IMAGE:${{ github.sha }} | |
| docker push $AR_FRONTEND_IMAGE:${{ github.sha }} | |
| echo "AR_FRONTEND_IMAGE=$AR_FRONTEND_IMAGE" >> $GITHUB_ENV | |
| - name: Deploy frontend to Cloud Run | |
| run: | | |
| gcloud run deploy mcp-frontend \ | |
| --image $AR_FRONTEND_IMAGE:${{ github.sha }} \ | |
| --region ${{ secrets.GCP_REGION }} \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --port 80 |