From 6588389fa19c8f41a2ce37d2054d022795fc2d4d Mon Sep 17 00:00:00 2001 From: hcornet Date: Sat, 1 Feb 2025 12:34:52 +0100 Subject: [PATCH] first sync --- .gitea/workflows/ci-develop.yml | 111 ++++++++++++++++++++++---------- .gitea/workflows/ci-main.yml | 71 ++++++++++++-------- access_token | 1 + docker-compose.yml | 99 +++++++++++++++++----------- 4 files changed, 184 insertions(+), 98 deletions(-) create mode 100644 access_token diff --git a/.gitea/workflows/ci-develop.yml b/.gitea/workflows/ci-develop.yml index d9160d4..b94908e 100644 --- a/.gitea/workflows/ci-develop.yml +++ b/.gitea/workflows/ci-develop.yml @@ -1,70 +1,113 @@ # Template -name: Deployment Verification +name: CI/CD Docker Compose on: push: - branches: - - develop - tags: - - "v[0-9]+.[0-9]+.[0-9]" - pull_request: branches: - - main - workflow_dispatch: + - develop jobs: - deploy-and-test: + Validate: runs-on: ubuntu-latest steps: + # - name: Checkout uses: actions/checkout@v4 # https://github.com/docker/setup-qemu-action#usage - name: Set up QEMU uses: docker/setup-qemu-action@v3.2.0 + with: + platforms: all + + # + - name: Check the presence file docker-compose.yml + run: | + if [ ! -f "docker-compose.yml" ]; then + echo "Error : file docker-compose.yml is missing." + exit 1 + fi + docker compose config -q + + Deploy-And-Test: + runs-on: ubuntu-latest + + steps: + # + - name: Checkout + uses: actions/checkout@v4 + + # https://github.com/docker/setup-qemu-action#usage + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.2.0 + with: + platforms: all + + # + - name: Installer Docker Compose + run: | + apt-get update + apt-get install -y docker-compose + apt-get install -y bc # https://github.com/marketplace/actions/docker-setup-buildx - name: Set up Docker Buildx - id: buildx +# id: buildx uses: docker/setup-buildx-action@v3.6.1 - # https://github.com/docker/build-push-action - - name: Build and push - uses: docker/build-push-action@v6 - # - - name: Create necessary Docker networks + - name: Building images run: | - docker network create back_network || true - docker network create traefik_front_network || true + docker compose build + +# - name: Create necessary Docker networks +# run: | +# docker network create back_network || true +# docker network create traefik_front_network || true - name: Start up services using Docker Compose - run: docker compose -f docker-compose.yml up -d + run: docker compose up -d -# - name: Modify /etc/hosts for internal routing -# run: | -# echo "127.0.0.1 gitea.tips-of-mine.com" | sudo tee -a /etc/hosts + - name: Modify /etc/hosts for internal routing + run: | + echo "127.0.0.1 docuseal.tips-of-mine.com" | sudo tee -a /etc/hosts + + - name: Waiting for services to be ready + run: | + sleep 20 - name: Print Docker Compose services status run: docker ps - - name: Wait for the application to be ready via Traefik - run: | - echo "Checking the routing and availability of application via Traefik..." - timeout 5m bash -c 'while ! curl -fsSLk "https://metabase.tips-of-mine.com"; do echo "Waiting for the application to be ready..."; sleep 10; done' +# - name: Wait for the application to be ready via Traefik +# run: | +# echo "Checking the routing and availability of application via Traefik..." +# timeout 5m bash -c 'while ! curl -fsSLk "https://docuseal.tips-of-mine.com"; do echo "Waiting for the application to be ready..."; sleep 10; done' - - name: Inspect Network Configuration - run: | - docker network inspect back_network - docker network inspect traefik_front_network +# - name: Inspect Network Configuration +# run: | +# docker network inspect back_network +# docker network inspect traefik_front_network - name: Shutdown Docker Compose services if: always() - run: docker compose -f docker-compose.yml down + run: docker compose down - - name: Cleanup - if: always() + - name: Incrémenter le numéro de version + if: success() run: | - docker compose --profile setup down - rm -rf /workspace/tips-of-mine/metabase/* \ No newline at end of file + current_version=$(cat VERSION) + new_version=$(echo "$current_version + 1" | bc) + echo "$current_version" > VERSION + git config user.name 'Gitea Actions' + git config user.email 'actions@gitea.io' + git add VERSION + git commit -m "Incrémentation automatique de la version à $current_version" + + - name: Fusionner dans main + if: success() + run: | + git checkout main + git merge develop --no-ff -m "Fusion automatique de develop suite aux tests réussis" + git push origin main diff --git a/.gitea/workflows/ci-main.yml b/.gitea/workflows/ci-main.yml index bf77843..6ca1f85 100644 --- a/.gitea/workflows/ci-main.yml +++ b/.gitea/workflows/ci-main.yml @@ -3,49 +3,68 @@ name: Deployment Verification on: push: - branches: + branches: - main + tags: + - "v[0-9]+.[0-9]+.[0-9]" pull_request: branches: - main + workflow_dispatch: jobs: deploy-and-test: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + # https://github.com/docker/setup-qemu-action#usage + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.2.0 - - name: Create necessary Docker networks - run: | - docker network create back_network_{ vars.APPLICATION_NAME } || true - docker network create traefik_front_network || true + # https://github.com/marketplace/actions/docker-setup-buildx + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.6.1 - - name: Start up services using Docker Compose - run: docker compose -f docker-compose.yml up -d + # https://github.com/docker/build-push-action + - name: Build and push + uses: docker/build-push-action@v6 + + # + - name: Create necessary Docker networks + run: | + docker network create back_network || true + docker network create traefik_front_network || true + + - name: Start up services using Docker Compose + run: docker compose -f docker-compose.yml up -d # - name: Modify /etc/hosts for internal routing # run: | -# echo "127.0.0.1 { vars.APPLICATION_URL }" | sudo tee -a /etc/hosts -# echo "127.0.0.1 dashboard.tips-of-mine.com" | sudo tee -a /etc/hosts +# echo "127.0.0.1 gitea.tips-of-mine.com" | sudo tee -a /etc/hosts - - name: Print Docker Compose services status - run: docker ps + - name: Print Docker Compose services status + run: docker ps - - name: Wait for the application to be ready via Traefik - run: | - echo "Checking the routing and availability of application via Traefik..." - timeout 5m bash -c 'while ! curl -fsSLk "https://{ vars.APPLICATION_URL }"; do echo "Waiting for the application to be ready..."; sleep 10; done' + - name: Wait for the application to be ready via Traefik + run: | + echo "Checking the routing and availability of application via Traefik..." + timeout 5m bash -c 'while ! curl -fsSLk "https://metabase.tips-of-mine.com"; do echo "Waiting for the application to be ready..."; sleep 10; done' - - name: Inspect Network Configuration - run: | - docker network inspect back_network_{ vars.APPLICATION_NAME } - docker network inspect traefik_front_network + - name: Inspect Network Configuration + run: | + docker network inspect back_network + docker network inspect traefik_front_network - - name: Shutdown Docker Compose services - if: always() - run: docker compose -f docker-compose.yml down \ No newline at end of file + - name: Shutdown Docker Compose services + if: always() + run: docker compose -f docker-compose.yml down + + - name: Cleanup + if: always() + run: | + docker compose --profile setup down + rm -rf /workspace/tips-of-mine/metabase/* \ No newline at end of file diff --git a/access_token b/access_token new file mode 100644 index 0000000..df12b4e --- /dev/null +++ b/access_token @@ -0,0 +1 @@ +ATirjITfsXP2SMk \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4054566..e4f0e38 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,42 +1,65 @@ -#### NETWORKS -networks: - traefik_front_network: - external: true - back_network_: - driver: bridge - attachable: true +secrets: + access_token: + file: access_token -#### SERVICES services: -### hello_world - hello_world: - container_name: gitea-app - hostname: gitea-app - image: hello-world + watchtower: + image: containrrr/watchtower + restart: unless-stopped + secrets: + - access_token environment: - restart: always - networks: -# - back_network_gitea - - traefik_front_network + - TZ=Europe/Paris + # the below will ignore labels set. It is worth checking out labels as that can be a more scalabe solution (automatic) + # - WATCHTOWER_DISABLE_CONTAINERS=traefik crowdsec bouncer-traefik deconz frigate home-assistant homeassistant-db + # the docker host can also be remote by specifying tcp + # - DOCKER_HOST=tcp://hostname:port + # how frequently to check for images (default is 24 hours) + - WATCHTOWER_POLL_INTERVAL=3600 + # choose whether to restart the containers after updates +# - WATCHTOWER_INCLUDE_RESTARTING=true + # choose whether to update stopped and exited containers +# - WATCHTOWER_INCLUDE_STOPPED=true + # this will start containers that were stopped or exited if they are updated +# - WATCHTOWER_REVIVE_STOPPED=true + # watchtower can behave like DIUN by only notifying, and not updating +# - WATCHTOWER_MONITOR_ONLY=true + # you can tell watchtower to do updates and restarts one by one - can be helpful +# - WATCHTOWER_ROLLING_RESTART=true + # + - WATCHTOWER_LABEL_ENABLE=true + # Supprime les vieilles images après la mise à jour + - WATCHTOWER_CLEANUP=true + # Supprime les volumes anonymes après la mise à jour + - WATCHTOWER_REMOVE_VOLUMES=true + # Activer le mode de trace avec une diagraphie très verbeuse +# - WATCHTOWER_TRACE=false + # Le niveau de logarithme maximum qui sera écrit à STDERR + - WATCHTOWER_LOG_LEVEL=info # panic, fatal, error, warn, info, debug or trace + # Définit quel format d'enregistrement utiliser pour la sortie de la console. +# - WATCHTOWER_LOG_FORMAT=auto # Auto, LogFmt, Pretty or JSON + # +# - NO_COLOR=false + # +# - WATCHTOWER_DISABLE_CONTAINERS=false + # +# - WATCHTOWER_NO_RESTART=false + + - WATCHTOWER_NOTIFICATIONS=gotify + - WATCHTOWER_NOTIFICATION_GOTIFY_URL=https://gotify.tips-of-mine.com/ + - WATCHTOWER_NOTIFICATION_GOTIFY_TOKEN=/run/secrets/access_token + +# - WATCHTOWER_NOTIFICATIONS=email +# - WATCHTOWER_NOTIFICATION_EMAIL_FROM=fromaddress@gmail.com +# - WATCHTOWER_NOTIFICATION_EMAIL_TO=toaddress@gmail.com +# - WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com +# - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587 +# - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=fromaddress@gmail.com +# - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=app_password +# - WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2 volumes: - labels: - - "traefik.enable=true" - - "traefik.docker.network=traefik_front_network" -# HTTP - - "traefik.http.routers.hello-world-http.rule=Host(`hello-world.tips-of-mine.com`)" - - "traefik.http.routers.hello-world-http.entrypoints=http" - - "traefik.http.routers.hello-world-http.priority=49" -# HTTPS - - "traefik.http.routers.hello-world-https.rule=Host(`hello-world.tips-of-mine.com`)" - - "traefik.http.routers.hello-world-https.entrypoints=https" - - "traefik.http.routers.hello-world-https.tls=true" - - "traefik.http.routers.hello-world-https.priority=50" - - "traefik.http.routers.gitea.service=gitea-https-service" -# Middleware -# Service -# - "traefik.http.services.gitea-https-service.loadbalancer.server.port=3000" -# - "traefik.http.services.gitea-https-service.loadbalancer.server.scheme=https" -# - "traefik.http.services.gitea-https-service.loadbalancer.healthcheck.hostname=gitea.traefik.me" -# - "traefik.http.services.gitea-https-service.loadbalancer.healthcheck.method=foobar" -# - "traefik.http.services.gitea-https-service.loadbalancer.healthcheck.timeout=10" -# - "traefik.http.services.gitea-https-service.loadbalancer.healthcheck.interval=30" + - /var/run/docker.sock:/var/run/docker.sock + - /root/.docker/config.json:/config.json # - Enable this when using a custom repo + command: --interval 30 #--http-api-metrics --http-api-token demotoken --debug prometheus grafana parent child # change this interval to whatever suits you + ports: + - 8087:8080 \ No newline at end of file