From b7a0279cf08a8c249ce32be8c697aa7f72391e0c Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 22 Jan 2024 11:39:28 +0100 Subject: [PATCH] updating docker compose and actions --- .github/workflows/build.yml | 20 +++++ .../workflows/{asw2324.yml => release.yml} | 2 +- README.md | 2 +- docker-compose-deploy.override.yml | 41 ---------- docker-compose-dev.override.yml | 81 ------------------- docker-compose.yml | 80 ++++++++++++++++-- 6 files changed, 97 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{asw2324.yml => release.yml} (97%) delete mode 100644 docker-compose-deploy.override.yml delete mode 100644 docker-compose-dev.override.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2862b6ad --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +name: Build +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/asw2324.yml b/.github/workflows/release.yml similarity index 97% rename from .github/workflows/asw2324.yml rename to .github/workflows/release.yml index 41a4bad7..db5a0698 100644 --- a/.github/workflows/asw2324.yml +++ b/.github/workflows/release.yml @@ -125,4 +125,4 @@ jobs: wget https://raw.githubusercontent.com/pglez82/asw2324_0/master/docker-compose.yml wget https://raw.githubusercontent.com/pglez82/asw2324_0/master/docker-compose-deploy.override.yml docker compose down - docker compose -f docker-compose.yml -f docker-compose-deploy.override.yml up -d + docker compose --profile prod up -d diff --git a/README.md b/README.md index acafdad8..0afc13ab 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Both the user and auth service share a Mongo database that is accessed with mong The fastest way for launching this sample project is using docker. Just clone the project: ```git clone git@github.com:pglez82/asw2324_0.git``` and launch it with docker compose: -```docker compose -f docker-compose.yml -f docker-compose-dev.override.yml up --build``` +```docker compose --profile dev up --build``` ### Component by component start First, start the database. Either install and run Mongo or run it using docker: diff --git a/docker-compose-deploy.override.yml b/docker-compose-deploy.override.yml deleted file mode 100644 index 0dab2744..00000000 --- a/docker-compose-deploy.override.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '3' -services: - mongodb: - ports: - - "27017:27017" - networks: - - mynetwork - - authservice: - ports: - - "8002:8002" - networks: - - mynetwork - environment: - MONGODB_URI: mongodb://mongodb:27017/userdb - - userservice: - ports: - - "8001:8001" - networks: - - mynetwork - environment: - MONGODB_URI: mongodb://mongodb:27017/userdb - - gatewayservice: - ports: - - "8000:8000" - networks: - - mynetwork - environment: - AUTH_SERVICE_URL: http://authservice:8002 - USER_SERVICE_URL: http://userservice:8001 - - webapp: - ports: - - "3000:3000" - -networks: - mynetwork: - driver: bridge - diff --git a/docker-compose-dev.override.yml b/docker-compose-dev.override.yml deleted file mode 100644 index 4df99e0c..00000000 --- a/docker-compose-dev.override.yml +++ /dev/null @@ -1,81 +0,0 @@ -version: '3' -services: - mongodb: - image: mongo - ports: - - "27017:27017" - networks: - - mynetwork - volumes: - - mongodb_data:/data/db - - authservice: - build: ./users/authservice - ports: - - "8002:8002" - networks: - - mynetwork - environment: - MONGODB_URI: mongodb://mongodb:27017/userdb - - userservice: - build: ./users/userservice - ports: - - "8001:8001" - networks: - - mynetwork - environment: - MONGODB_URI: mongodb://mongodb:27017/userdb - - gatewayservice: - build: ./gatewayservice - ports: - - "8000:8000" - networks: - - mynetwork - environment: - AUTH_SERVICE_URL: http://authservice:8002 - USER_SERVICE_URL: http://userservice:8001 - - webapp: - build: ./webapp - ports: - - "3000:3000" - - prometheus: - image: prom/prometheus - networks: - - mynetwork - volumes: - - ./gatewayservice/monitoring/prometheus:/etc/prometheus - - prometheus_data:/prometheus - ports: - - "9090:9090" - depends_on: - - gatewayservice - - grafana: - image: grafana/grafana - networks: - - mynetwork - volumes: - - grafana_data:/var/lib/grafana - - ./gatewayservice/monitoring/grafana/provisioning:/etc/grafana/provisioning - environment: - - GF_SERVER_HTTP_PORT=9091 - - GF_AUTH_DISABLE_LOGIN_FORM=true - - GF_AUTH_ANONYMOUS_ENABLED=true - - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - ports: - - "9091:9091" - depends_on: - - prometheus - -networks: - mynetwork: - driver: bridge - -volumes: - mongodb_data: - prometheus_data: - grafana_data: diff --git a/docker-compose.yml b/docker-compose.yml index eddc7432..2fd2f552 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,38 +3,108 @@ services: mongodb: container_name: mongodb-${teamname:-defaultASW} image: mongo + profiles: ["dev", "prod"] volumes: - mongodb_data:/data/db + ports: + - "27017:27017" + networks: + - mynetwork authservice: container_name: authservice-${teamname:-defaultASW} - image: ghcr.io/pglez82/asw2324_0/authservice:latest + image: ghcr.io/arquisoft/asw2324_0/authservice:latest + profiles: ["dev", "prod"] build: ./users/authservice depends_on: - mongodb + ports: + - "8002:8002" + networks: + - mynetwork + environment: + MONGODB_URI: mongodb://mongodb:27017/userdb userservice: container_name: userservice-${teamname:-defaultASW} - image: ghcr.io/pglez82/asw2324_0/userservice:latest + image: ghcr.io/arquisoft/asw2324_0/userservice:latest + profiles: ["dev", "prod"] build: ./users/userservice depends_on: - mongodb + ports: + - "8001:8001" + networks: + - mynetwork + environment: + MONGODB_URI: mongodb://mongodb:27017/userdb gatewayservice: container_name: gatewayservice-${teamname:-defaultASW} - image: ghcr.io/pglez82/asw2324_0/gatewayservice:latest + image: ghcr.io/arquisoft/asw2324_0/gatewayservice:latest + profiles: ["dev", "prod"] build: ./gatewayservice depends_on: - mongodb - userservice - authservice + ports: + - "8000:8000" + networks: + - mynetwork + environment: + AUTH_SERVICE_URL: http://authservice:8002 + USER_SERVICE_URL: http://userservice:8001 webapp: container_name: webapp-${teamname:-defaultASW} - image: ghcr.io/pglez82/asw2324_0/webapp:latest + image: ghcr.io/arquisoft/asw2324_0/webapp:latest + profiles: ["dev", "prod"] build: ./webapp depends_on: - - gatewayservice + - gatewayservice + ports: + - "3000:3000" + + prometheus: + image: prom/prometheus + container_name: prometheus-${teamname:-defaultASW} + profiles: ["dev"] + networks: + - mynetwork + volumes: + - ./gatewayservice/monitoring/prometheus:/etc/prometheus + - prometheus_data:/prometheus + ports: + - "9090:9090" + depends_on: + - gatewayservice + + grafana: + image: grafana/grafana + container_name: grafana-${teamname:-defaultASW} + profiles: ["dev"] + networks: + - mynetwork + volumes: + - grafana_data:/var/lib/grafana + - ./gatewayservice/monitoring/grafana/provisioning:/etc/grafana/provisioning + environment: + - GF_SERVER_HTTP_PORT=9091 + - GF_AUTH_DISABLE_LOGIN_FORM=true + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + ports: + - "9091:9091" + depends_on: + - prometheus + volumes: mongodb_data: + prometheus_data: + grafana_data: + +networks: + mynetwork: + driver: bridge \ No newline at end of file