generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
155 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,157 @@ | ||
version: '3' | ||
services: | ||
mongodb: | ||
container_name: mongodb-${teamname:-wiq5a} | ||
image: mongo | ||
profiles: ["dev", "prod"] | ||
volumes: | ||
- mongodb_data:/data/db | ||
ports: | ||
- "27017:27017" | ||
networks: | ||
- mynetwork | ||
name: Deploy on release | ||
|
||
questionservice: | ||
container_name: questionservice-${teamname:-wiq5a} | ||
image: ghcr.io/arquisoft/wiq_5a/questionservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./questionservice | ||
ports: | ||
- "8003:8003" | ||
environment: | ||
- ACCESS_CONTROL_ALLOW_ORIGIN=http://webapp:3000 | ||
- ACCESS_CONTROL_ALLOW_ORIGIN=http://localhost:3000/game | ||
networks: | ||
- mynetwork | ||
on: | ||
release: | ||
types: [published] | ||
|
||
authservice: | ||
container_name: authservice-${teamname:-wiq5a} | ||
image: ghcr.io/arquisoft/wiq_5a/authservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./userservice/authservice | ||
depends_on: | ||
- mongodb | ||
ports: | ||
- "8002:8002" | ||
networks: | ||
- mynetwork | ||
environment: | ||
MONGODB_URI: mongodb://mongodb:27017/userdb | ||
|
||
userservice: | ||
container_name: userservice-${teamname:-wiq5a} | ||
image: ghcr.io/arquisoft/wiq_5a/userservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./userservice/userservice | ||
depends_on: | ||
- mongodb | ||
ports: | ||
- "8001:8001" | ||
networks: | ||
- mynetwork | ||
environment: | ||
MONGODB_URI: mongodb://mongodb:27017/userdb | ||
|
||
gatewayservice: | ||
container_name: gatewayservice-${teamname:-wiq5a} | ||
image: ghcr.io/arquisoft/wiq_5a/gatewayservice:latest | ||
profiles: ["dev", "prod"] | ||
build: ./gatewayservice | ||
depends_on: | ||
- mongodb | ||
- userservice | ||
- authservice | ||
- questionservice | ||
ports: | ||
- "8000:8000" | ||
networks: | ||
- mynetwork | ||
environment: | ||
AUTH_SERVICE_URL: http://authservice:8002 | ||
USER_SERVICE_URL: http://userservice:8001 | ||
QUESTION_SERVICE_URL: http://questionservice:8003 | ||
|
||
webapp: | ||
container_name: webapp-${teamname:-wiq5a} | ||
image: ghcr.io/arquisoft/wiq_5a/webapp:latest | ||
profiles: ["dev", "prod"] | ||
build: ./webapp | ||
depends_on: | ||
- gatewayservice | ||
ports: | ||
- "3000:3000" | ||
|
||
prometheus: | ||
image: ghcr.io/arquisoft/wiq_5a/prometheus:latest | ||
container_name: prometheus-${teamname:-wiq5a} | ||
build: ./monitoring/prometheus | ||
profiles: ["dev", "prod"] | ||
networks: | ||
- mynetwork | ||
volumes: | ||
- prometheus_data:/prometheus | ||
ports: | ||
- "9090:9090" | ||
depends_on: | ||
- gatewayservice | ||
|
||
grafana: | ||
image: ghcr.io/arquisoft/wiq_5a/grafana:latest | ||
container_name: grafana-${teamname:-wiq5a} | ||
build: ./monitoring/grafana | ||
profiles: ["dev", "prod"] | ||
networks: | ||
- mynetwork | ||
volumes: | ||
- grafana_data:/var/lib/grafana | ||
environment: | ||
- GF_SERVER_HTTP_PORT=9091 | ||
- GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER:-admin} | ||
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD:-changeme} | ||
- GF_SERVER_SERVE_FROM_SUB_PATH=${GF_SERVER_SERVE_FROM_SUB_PATH:-true} | ||
ports: | ||
- "9091:9091" | ||
depends_on: | ||
- prometheus | ||
|
||
volumes: | ||
mongodb_data: | ||
prometheus_data: | ||
grafana_data: | ||
|
||
networks: | ||
mynetwork: | ||
driver: bridge | ||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: npm --prefix userservice/authservice ci | ||
- run: npm --prefix userservice/userservice ci | ||
- run: npm --prefix gatewayservice ci | ||
- run: npm --prefix webapp ci | ||
- run: npm --prefix questionservice ci | ||
- run: npm --prefix userservice/authservice test -- --coverage | ||
- run: npm --prefix userservice/userservice test -- --coverage | ||
- run: npm --prefix gatewayservice test -- --coverage | ||
- run: npm --prefix webapp test -- --coverage | ||
- run: npm --prefix questionservice test -- --coverage | ||
- name: Analyze with SonarCloud | ||
uses: sonarsource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
# e2e-tests: | ||
# needs: [unit-tests] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: actions/setup-node@v4 | ||
# with: | ||
# node-version: 20 | ||
# - run: npm --prefix userservice/authservice install | ||
# - run: npm --prefix userservice/userservice install | ||
# - run: npm --prefix gatewayservice install | ||
# - run: npm --prefix questionservice install | ||
# - run: npm --prefix webapp install | ||
# - run: npm --prefix webapp run build | ||
# - run: npm --prefix webapp run test:e2e | ||
docker-push-webapp: | ||
name: Push webapp Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# needs: [e2e-tests] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@v5 | ||
env: | ||
API_URI: http://${{ secrets.DEPLOY_HOST }}:8000 | ||
with: | ||
name: arquisoft/wiq_es05a/webapp | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
workdir: webapp | ||
buildargs: API_URI | ||
docker-push-authservice: | ||
name: Push auth service Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# needs: [e2e-tests] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@v5 | ||
with: | ||
name: arquisoft/wiq_es05a/authservice | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
workdir: userservice/authservice | ||
docker-push-userservice: | ||
name: Push user service Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# needs: [e2e-tests] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@v5 | ||
with: | ||
name: arquisoft/wiq_es05a/userservice | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
workdir: userservice/userservice | ||
docker-push-gatewayservice: | ||
name: Push gateway service Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# needs: [e2e-tests] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Update OpenAPI configuration | ||
run: | | ||
DEPLOY_HOST=${{ secrets.DEPLOY_HOST }} | ||
sed -i "s/SOMEIP/${DEPLOY_HOST}/g" gatewayservice/openapi.yaml | ||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@v5 | ||
with: | ||
name: arquisoft/wiq_es05a/gatewayservice | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
workdir: gatewayservice | ||
docker-push-questionservice: | ||
name: Push questionservice Docker Image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# needs: [e2e-tests] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@v5 | ||
with: | ||
name: arquisoft/wiq_es05a/questionservice | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
workdir: questionservice | ||
deploy: | ||
name: Deploy over SSH | ||
runs-on: ubuntu-latest | ||
needs: | ||
- docker-push-userservice | ||
- docker-push-authservice | ||
- docker-push-gatewayservice | ||
- docker-push-questionservice | ||
- docker-push-webapp | ||
steps: | ||
- name: Deploy over SSH | ||
uses: fifsky/ssh-action@master | ||
with: | ||
host: ${{ secrets.DEPLOY_HOST }} | ||
user: ${{ secrets.DEPLOY_USER }} | ||
key: ${{ secrets.DEPLOY_KEY }} | ||
command: | | ||
wget https://raw.githubusercontent.com/arquisoft/wiq_es05a/master/docker-compose.yml -O docker-compose.yml | ||
wget https://raw.githubusercontent.com/arquisoft/wiq_es05a/master/.env -O .env | ||
docker compose --profile prod down | ||
docker compose --profile prod up -d --pull always |