Skip to content

chore: add cicd docker compose #5

chore: add cicd docker compose

chore: add cicd docker compose #5

Workflow file for this run

name: Docker Compose Pipeline
on:
push:
branches:
- main
- staging
pull_request:
branches:
- main
- staging
jobs:
test:
runs-on: ubuntu-latest
services:
docker:
image: docker:19.03.12
options: --privileged
ports:
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Compose
run: sudo apt-get update && sudo apt-get install docker-compose -y
- name: Create Environment Files
run: |
cd "./apps/frontend"
echo "NEXT_PUBLIC_QUESTION_SERVICE_URL=${{ env.QUESTION_SERVICE_URL }}" >> .env
echo "NEXT_PUBLIC_USER_SERVICE_URL=${{ env.USER_SERVICE_URL }} >> .env
cd "../question-service"
echo "FIREBASE_CREDENTIAL_PATH=${{ env.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}" >> .env
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env
cd "../user-service"
echo "DB_CLOUD_URI=${{ env.USER_SERVICE_DB_CLOUD_URI }}" >> .env
echo "PORT=${{ env.USER_SERVICE_PORT }}" >> .env
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env
- name: Build and Run Services
run: |
cd ./apps
docker-compose up --build -d
- name: Clean up environment files
run: |
rm ./frontend/.env
rm ./question-service/.env
rm ./user-service/.env
- name: Wait for services to be ready
run: sleep 10 # this is the estimated service startup time
- name: Run Tests
run: |
curl --fail http://localhost:3000 # Adjust based on the app
# We can add more tests here