first sync
Some checks failed
CI/CD Docker Compose / Validate (push) Successful in 8s
CI/CD Docker Compose / Deploy-And-Test (push) Has been cancelled

This commit is contained in:
Hubert Cornet 2025-02-01 12:34:52 +01:00
parent 40bad51310
commit 6588389fa1
4 changed files with 184 additions and 98 deletions

View File

@ -1,70 +1,113 @@
# Template # Template
name: Deployment Verification name: CI/CD Docker Compose
on: on:
push: push:
branches: branches:
- develop - develop
tags:
- "v[0-9]+.[0-9]+.[0-9]"
pull_request:
branches:
- main
workflow_dispatch:
jobs: jobs:
deploy-and-test: Validate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
#
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action#usage # https://github.com/docker/setup-qemu-action#usage
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0 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 # https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx # id: buildx
uses: docker/setup-buildx-action@v3.6.1 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: | run: |
docker network create back_network || true docker compose build
docker network create traefik_front_network || true
# - 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 - 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 - name: Modify /etc/hosts for internal routing
# run: | run: |
# echo "127.0.0.1 gitea.tips-of-mine.com" | sudo tee -a /etc/hosts 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 - name: Print Docker Compose services status
run: docker ps run: docker ps
- name: Wait for the application to be ready via Traefik # - name: Wait for the application to be ready via Traefik
run: | # run: |
echo "Checking the routing and availability of application via Traefik..." # 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' # 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 # - name: Inspect Network Configuration
run: | # run: |
docker network inspect back_network # docker network inspect back_network
docker network inspect traefik_front_network # docker network inspect traefik_front_network
- name: Shutdown Docker Compose services - name: Shutdown Docker Compose services
if: always() if: always()
run: docker compose -f docker-compose.yml down run: docker compose down
- name: Cleanup - name: Incrémenter le numéro de version
if: always() if: success()
run: | run: |
docker compose --profile setup down current_version=$(cat VERSION)
rm -rf /workspace/tips-of-mine/metabase/* 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

View File

@ -5,24 +5,38 @@ on:
push: push:
branches: branches:
- main - main
tags:
- "v[0-9]+.[0-9]+.[0-9]"
pull_request: pull_request:
branches: branches:
- main - main
workflow_dispatch:
jobs: jobs:
deploy-and-test: deploy-and-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx # https://github.com/docker/setup-qemu-action#usage
uses: docker/setup-buildx-action@v3 - name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0
# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker 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: Create necessary Docker networks
run: | run: |
docker network create back_network_{ vars.APPLICATION_NAME } || true docker network create back_network || true
docker network create traefik_front_network || true docker network create traefik_front_network || true
- name: Start up services using Docker Compose - name: Start up services using Docker Compose
@ -30,8 +44,7 @@ jobs:
# - name: Modify /etc/hosts for internal routing # - name: Modify /etc/hosts for internal routing
# run: | # run: |
# echo "127.0.0.1 { vars.APPLICATION_URL }" | sudo tee -a /etc/hosts # echo "127.0.0.1 gitea.tips-of-mine.com" | sudo tee -a /etc/hosts
# echo "127.0.0.1 dashboard.tips-of-mine.com" | sudo tee -a /etc/hosts
- name: Print Docker Compose services status - name: Print Docker Compose services status
run: docker ps run: docker ps
@ -39,13 +52,19 @@ jobs:
- name: Wait for the application to be ready via Traefik - name: Wait for the application to be ready via Traefik
run: | run: |
echo "Checking the routing and availability of application via Traefik..." 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' 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 - name: Inspect Network Configuration
run: | run: |
docker network inspect back_network_{ vars.APPLICATION_NAME } docker network inspect back_network
docker network inspect traefik_front_network docker network inspect traefik_front_network
- name: Shutdown Docker Compose services - name: Shutdown Docker Compose services
if: always() if: always()
run: docker compose -f docker-compose.yml down 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/*

1
access_token Normal file
View File

@ -0,0 +1 @@
ATirjITfsXP2SMk

View File

@ -1,42 +1,65 @@
#### NETWORKS secrets:
networks: access_token:
traefik_front_network: file: access_token
external: true
back_network_:
driver: bridge
attachable: true
#### SERVICES
services: services:
### hello_world watchtower:
hello_world: image: containrrr/watchtower
container_name: gitea-app restart: unless-stopped
hostname: gitea-app secrets:
image: hello-world - access_token
environment: environment:
restart: always - TZ=Europe/Paris
networks: # the below will ignore labels set. It is worth checking out labels as that can be a more scalabe solution (automatic)
# - back_network_gitea # - WATCHTOWER_DISABLE_CONTAINERS=traefik crowdsec bouncer-traefik deconz frigate home-assistant homeassistant-db
- traefik_front_network # 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: volumes:
labels: - /var/run/docker.sock:/var/run/docker.sock
- "traefik.enable=true" - /root/.docker/config.json:/config.json # - Enable this when using a custom repo
- "traefik.docker.network=traefik_front_network" command: --interval 30 #--http-api-metrics --http-api-token demotoken --debug prometheus grafana parent child # change this interval to whatever suits you
# HTTP ports:
- "traefik.http.routers.hello-world-http.rule=Host(`hello-world.tips-of-mine.com`)" - 8087:8080
- "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"