From 03c4155c4854bc4452a5a3448b8a58210b87c66c Mon Sep 17 00:00:00 2001 From: Maxence Date: Mon, 1 Apr 2024 11:47:06 +0200 Subject: [PATCH 01/25] add comment et modif import dotenv --- server/config/db.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/config/db.js b/server/config/db.js index ed98b2ed..a34bb99c 100644 --- a/server/config/db.js +++ b/server/config/db.js @@ -1,15 +1,15 @@ -const { config } = require("dotenv"); -const mongoose = require("mongoose"); +require("dotenv").config(); // this reads the .env file and sets the environment variables. +const mongoose = require("mongoose"); // this is the ODM for MongoDB -mongoose - .connect( +mongoose // this connects to the MongoDB database + .connect( // the connection string is stored in the .env file "mongodb+srv://" + process.env.DB_USER_PASS + - "@cluster0.v8rv1aj.mongodb.net/khagu-dev?retryWrites=true&w=majority", + "@cluster0.v8rv1aj.mongodb.net/khagu-dev?retryWrites=true&w=majority", // this is the connection string { - useNewUrlParser: true, - useUnifiedTopology: true, + useNewUrlParser: true, // these are some options to avoid deprecation warnings + useUnifiedTopology: true, // these are some options to avoid deprecation warnings } ) - .then(() => console.log("connected to MongoDB")) - .catch((err) => console.log("Failed to connect to MongoDB :", err)); + .then(() => console.log("connected to MongoDB")) // if the connection is successful, this message is printed + .catch((err) => console.log("Failed to connect to MongoDB :", err)); // if the connection fails, this message is printed From 5dd78e28d81b596cad720dc29a627caf3dff66bf Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 15:26:25 +0200 Subject: [PATCH 02/25] first try deploiement raspberry pi --- .github/workflows/ci.yml | 80 +---- .github/workflows/logging.yml | 59 ---- .github/workflows/prod.yml | 506 ++++++++++++++++---------------- .github/workflows/raspberry.yml | 107 +++++++ client/Dockerfile | 2 +- docker-compose.yml | 10 + server/Dockerfile | 4 +- 7 files changed, 378 insertions(+), 390 deletions(-) delete mode 100644 .github/workflows/logging.yml create mode 100644 .github/workflows/raspberry.yml create mode 100644 docker-compose.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 879f9e54..3941c039 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,12 +47,7 @@ jobs: # Jobs de l'action npm test mv ./test-report.html ./back-jest-report.html - # - name: run back server # execution du serveur backend afin de pouvoir executer l'ensemble des tests du front - # run: | - # cd server - # npm run watch & - - - name: Run front Jest tests # execution des tests Jest du frontend + - name: Run front Jest tests # execution des tests Jest du frontendD run: | cd client npm test @@ -66,73 +61,8 @@ jobs: # Jobs de l'action ./client/front-jest-report.html ./server/back-jest-report.html - Eslint-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v2 - with: - node-version: 20 - - - name: Install front dependencies - run: | - npm ci - working-directory: client - - - name: Install back dependencies - run: | - npm ci - working-directory: server - - - name: Where am i - run: | - pwd - ls - - - name: Where am i server - run: | - pwd - ls -la - working-directory: server - - - name: Where am i client - run: | - pwd - ls -la - working-directory: client - - - name: Create eslint directory if not exists - run: mkdir -p eslint - working-directory: server - - - name: Create eslint directory if not exists - run: mkdir -p eslint - working-directory: client - - - name: Run front Eslint test - run: | - npm run lint || true - working-directory: client - - - name: Run back Eslint test - run: | - npm run lint || true - working-directory: server - - - name: Eslint reports - uses: actions/upload-artifact@v3 - with: - name: eslint reports - path: | - client/eslint-report.html - server/eslint-report.html - build-and-push: - needs: [Jest-tests, Eslint-test] + needs: [Jest-tests] runs-on: ubuntu-latest steps: @@ -165,13 +95,13 @@ jobs: # Jobs de l'action run: | echo "DB_USER_PASS=${{ secrets.DB_USER_PASS }}" > ./server/config/.env cat ./server/config/.env - echo "REACT_APP_URL_API=${{ secrets.REACT_APP_URL_API }}" > ./client/.env + echo "REACT_APP_URL_API=${{ secrets.REACT_APP_URL_API_RASPBERRY }}" > ./client/.env cat ./client/.env - name: Build front if: ${{ success() }} env: - REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API }} + REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API_RASPBERRY }} run: | cd client npm run build @@ -179,7 +109,7 @@ jobs: # Jobs de l'action - name: Build and push front uses: docker/build-push-action@v2 env: - REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API }} + REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API_RASPBERRY }} with: context: ./client/ file: ./client/Dockerfile diff --git a/.github/workflows/logging.yml b/.github/workflows/logging.yml deleted file mode 100644 index 613905e5..00000000 --- a/.github/workflows/logging.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Pipeline Logging - -on: - push: - branches: - - logging - pull_request: - branches: - - logging - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: "Google auth" - id: "auth" - uses: "google-github-actions/auth@v1" - with: - credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" - - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v1 - with: - project_id: ${{ secrets.GCP_PROJECT }} - install_components: "gke-gcloud-auth-plugin" - - - name: Configure gcloud - run: gcloud config set compute/region europe-west2 - - - name: Get cluster credential - uses: google-github-actions/get-gke-credentials@v1 - with: - cluster_name: khagu-dev-cluster - location: europe-west2 - - - name: Set up ECK - run: | - # Liste des CRDs ECK - crds=("agents.agent.k8s.elastic.co" "apmservers.apm.k8s.elastic.co" "beats.beat.k8s.elastic.co" "elasticmapsservers.maps.k8s.elastic.co" "elasticsearchautoscalers.autoscaling.k8s.elastic.co" "elasticsearches.elasticsearch.k8s.elastic.co" "enterprisesearches.enterprisesearch.k8s.elastic.co" "kibanas.kibana.k8s.elastic.co" "logstashes.logstash.k8s.elastic.co" "stackconfigpolicies.stackconfigpolicy.k8s.elastic.co") - - # Vérifiez chaque CRD - for crd in "${crds[@]}" - do - if ! kubectl get crd $crd > /dev/null 2>&1; then - # Si le CRD n'existe pas, créez les CRDs - kubectl create -f https://download.elastic.co/downloads/eck/2.11.1/crds.yaml - break - fi - done - - # Appliquez l'opérateur ECK - kubectl apply -f https://download.elastic.co/downloads/eck/2.11.1/operator.yaml - - - name: Deploy to GKE - run: | - kubectl apply -f ./logging/fleet.yml diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index d19bbefc..4bee72ae 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -1,253 +1,253 @@ -name: Pipeline Prod - -on: # Triggers the workflow - pull_request: # This workflow will run only for pull requests - branches: # This workflow will run only for the main branch - - main - -permissions: - pull-requests: write - -env: - # Use docker.io for Docker Hub if empty - SHA: ${{ github.event.pull_request.head.sha || github.event.after }} - REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API }} - -jobs: - ##### Check de l'image Front ###### - ################################### - check-front-image: - runs-on: ubuntu-latest # OS - steps: - - name: Checkout # Checkout the repository - uses: actions/checkout@v3 # Checkout the repository - - - name: Login to Docker Hub # Login to Docker Hub - uses: docker/login-action@v2 # Docker login action - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} # Docker Hub username - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} # Docker Hub access token - - - name: Extract Docker Front metadata # Extract Docker Front metadata - id: meta # Step ID - uses: docker/metadata-action@v4.4.0 # Docker metadata action - with: - images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }} # Docker Front image - labels: | - org.opencontainers.image.revision=${{ env.SHA }} - tags: | - type=edge,branch=$repo.default_branch - type=semver,pattern=v{{version}} - type=sha,prefix=,suffix=,format=short - - - name: Check Front image # Check Front image - uses: docker/scout-action@v0.18.1 # Docker scout action - with: - command: cves # Command to run on the image - image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} # Docker Front image version to check - exit-code: true # Exit code - - ##### Check de l'image Back ###### - ################################### - check-back-image: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Extract Docker Back metadata - id: meta - uses: docker/metadata-action@v4.4.0 - with: - images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }} - labels: | - org.opencontainers.image.revision=${{ env.SHA }} - tags: | - type=edge,branch=$repo.default_branch - type=semver,pattern=v{{version}} - type=sha,prefix=,suffix=,format=short - - - name: Check Back image - uses: docker/scout-action@v0.18.1 - with: - command: cves - image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - exit-code: true - - ##### Push front image to GAR ###### - #################################### - push-front-image-to-GAR: - needs: [check-front-image] - runs-on: ubuntu-latest - permissions: - contents: "read" - id-token: "write" - - steps: - - uses: actions/checkout@v3 - - - name: "Google auth" - id: "auth" - uses: "google-github-actions/auth@v1" - with: - credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" - - - name: "Pull image from Docker Hub" - run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - - - name: "Tag image" - run: docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - - - name: "config docker" - run: gcloud auth configure-docker "europe-west1-docker.pkg.dev" - - - name: "Push image to GAR" - run: docker push europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - - ##### Push back image to GAR ###### - ################################### - push-back-image-to-GAR: - needs: [check-back-image] - runs-on: ubuntu-latest - permissions: - contents: "read" - id-token: "write" - - steps: - - uses: actions/checkout@v3 - - - name: "Google auth" - id: "auth" - uses: "google-github-actions/auth@v1" - with: - credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" - - - name: "Pull image from Docker Hub" - run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - - - name: "Tag image" - run: docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - - - name: "config docker" - run: gcloud auth configure-docker "europe-west1-docker.pkg.dev" - - - name: "Push image to GAR" - run: docker push europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - # - name: "Build and push" - # uses: RafikFarhad/push-to-gcr-github-action@v5-beta - # with: - # registry: europe-west1-docker.pkg.dev - # project_id: ${{ secrets.GCP_PROJECT }} - # image_name: ${{ vars.DOCKER_BACK }} - # image_tag: ${{ vars.DOCKER_BACK_VERSION }} - # dockerfile: ./server/Dockerfile - # context: ./server - - ##### Deploiement Terraform ###### - ################################## - deploy-terraform: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v2 - - - name: Terraform Init - run: | - cd terraform - terraform init - env: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - - - name: Terraform Plan - run: | - cd terraform - terraform plan - env: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - - - name: Terraform Apply - run: | - cd terraform - terraform apply -auto-approve - env: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - - ##### Deploy front to GKE ###### - ################################ - deploy-front-to-gke: - needs: [push-front-image-to-GAR, deploy-terraform] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: "Google auth" - id: "auth" - uses: "google-github-actions/auth@v1" - with: - credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" - - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v1 - with: - project_id: ${{ secrets.GCP_PROJECT }} - install_components: "gke-gcloud-auth-plugin" - - - name: Configure gcloud - run: gcloud config set compute/region europe-west2 - - - name: Get cluster credential - uses: google-github-actions/get-gke-credentials@v1 - with: - cluster_name: khagu-dev-cluster - location: europe-west2 - - - name: Deploy to GKE - run: | - gcloud auth configure-docker europe-west1-docker.pkg.dev - kubectl apply -f ./client/prod-front.yml - - - ##### Deploy back to GKE ###### - ############################### - deploy-back-to-gke: - needs: [push-back-image-to-GAR, deploy-terraform] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: "Google auth" - id: "auth" - uses: "google-github-actions/auth@v1" - with: - credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" - - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v1 - with: - project_id: ${{ secrets.GCP_PROJECT }} - install_components: "gke-gcloud-auth-plugin" - - - name: Configure gcloud - run: gcloud config set compute/region europe-west2 - - - name: Get cluster credential - uses: google-github-actions/get-gke-credentials@v1 - with: - cluster_name: khagu-dev-cluster - location: europe-west2 - - - name: Deploy to GKE - run: | - gcloud auth configure-docker europe-west1-docker.pkg.dev - kubectl apply -f ./server/prod-back.yml +# name: Pipeline Prod + +# on: # Triggers the workflow +# # pull_request: # This workflow will run only for pull requests +# # branches: # This workflow will run only for the main branch +# # # - main + +# permissions: +# pull-requests: write + +# env: +# # Use docker.io for Docker Hub if empty +# SHA: ${{ github.event.pull_request.head.sha || github.event.after }} +# REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API }} + +# jobs: +# ##### Check de l'image Front ###### +# ################################### +# check-front-image: +# runs-on: ubuntu-latest # OS +# steps: +# - name: Checkout # Checkout the repository +# uses: actions/checkout@v3 # Checkout the repository + +# - name: Login to Docker Hub # Login to Docker Hub +# uses: docker/login-action@v2 # Docker login action +# with: +# username: ${{ secrets.DOCKER_HUB_USERNAME }} # Docker Hub username +# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} # Docker Hub access token + +# - name: Extract Docker Front metadata # Extract Docker Front metadata +# id: meta # Step ID +# uses: docker/metadata-action@v4.4.0 # Docker metadata action +# with: +# images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }} # Docker Front image +# labels: | +# org.opencontainers.image.revision=${{ env.SHA }} +# tags: | +# type=edge,branch=$repo.default_branch +# type=semver,pattern=v{{version}} +# type=sha,prefix=,suffix=,format=short + +# - name: Check Front image # Check Front image +# uses: docker/scout-action@v0.18.1 # Docker scout action +# with: +# command: cves # Command to run on the image +# image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} # Docker Front image version to check +# exit-code: true # Exit code + +# ##### Check de l'image Back ###### +# ################################### +# check-back-image: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Login to Docker Hub +# uses: docker/login-action@v2 +# with: +# username: ${{ secrets.DOCKER_HUB_USERNAME }} +# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + +# - name: Extract Docker Back metadata +# id: meta +# uses: docker/metadata-action@v4.4.0 +# with: +# images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }} +# labels: | +# org.opencontainers.image.revision=${{ env.SHA }} +# tags: | +# type=edge,branch=$repo.default_branch +# type=semver,pattern=v{{version}} +# type=sha,prefix=,suffix=,format=short + +# - name: Check Back image +# uses: docker/scout-action@v0.18.1 +# with: +# command: cves +# image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} +# exit-code: true + +# ##### Push front image to GAR ###### +# #################################### +# push-front-image-to-GAR: +# needs: [check-front-image] +# runs-on: ubuntu-latest +# permissions: +# contents: "read" +# id-token: "write" + +# steps: +# - uses: actions/checkout@v3 + +# - name: "Google auth" +# id: "auth" +# uses: "google-github-actions/auth@v1" +# with: +# credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" + +# - name: "Pull image from Docker Hub" +# run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + +# - name: "Tag image" +# run: docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + +# - name: "config docker" +# run: gcloud auth configure-docker "europe-west1-docker.pkg.dev" + +# - name: "Push image to GAR" +# run: docker push europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + +# ##### Push back image to GAR ###### +# ################################### +# push-back-image-to-GAR: +# needs: [check-back-image] +# runs-on: ubuntu-latest +# permissions: +# contents: "read" +# id-token: "write" + +# steps: +# - uses: actions/checkout@v3 + +# - name: "Google auth" +# id: "auth" +# uses: "google-github-actions/auth@v1" +# with: +# credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" + +# - name: "Pull image from Docker Hub" +# run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + +# - name: "Tag image" +# run: docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + +# - name: "config docker" +# run: gcloud auth configure-docker "europe-west1-docker.pkg.dev" + +# - name: "Push image to GAR" +# run: docker push europe-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GAR }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} +# # - name: "Build and push" +# # uses: RafikFarhad/push-to-gcr-github-action@v5-beta +# # with: +# # registry: europe-west1-docker.pkg.dev +# # project_id: ${{ secrets.GCP_PROJECT }} +# # image_name: ${{ vars.DOCKER_BACK }} +# # image_tag: ${{ vars.DOCKER_BACK_VERSION }} +# # dockerfile: ./server/Dockerfile +# # context: ./server + +# ##### Deploiement Terraform ###### +# ################################## +# deploy-terraform: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Setup Terraform +# uses: hashicorp/setup-terraform@v2 + +# - name: Terraform Init +# run: | +# cd terraform +# terraform init +# env: +# GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} + +# - name: Terraform Plan +# run: | +# cd terraform +# terraform plan +# env: +# GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} + +# - name: Terraform Apply +# run: | +# cd terraform +# terraform apply -auto-approve +# env: +# GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} + +# ##### Deploy front to GKE ###### +# ################################ +# deploy-front-to-gke: +# needs: [push-front-image-to-GAR, deploy-terraform] +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: "Google auth" +# id: "auth" +# uses: "google-github-actions/auth@v1" +# with: +# credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" + +# - name: Set up Cloud SDK +# uses: google-github-actions/setup-gcloud@v1 +# with: +# project_id: ${{ secrets.GCP_PROJECT }} +# install_components: "gke-gcloud-auth-plugin" + +# - name: Configure gcloud +# run: gcloud config set compute/region europe-west2 + +# - name: Get cluster credential +# uses: google-github-actions/get-gke-credentials@v1 +# with: +# cluster_name: khagu-dev-cluster +# location: europe-west2 + +# - name: Deploy to GKE +# run: | +# gcloud auth configure-docker europe-west1-docker.pkg.dev +# kubectl apply -f ./client/prod-front.yml + + +# ##### Deploy back to GKE ###### +# ############################### +# deploy-back-to-gke: +# needs: [push-back-image-to-GAR, deploy-terraform] +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: "Google auth" +# id: "auth" +# uses: "google-github-actions/auth@v1" +# with: +# credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" + +# - name: Set up Cloud SDK +# uses: google-github-actions/setup-gcloud@v1 +# with: +# project_id: ${{ secrets.GCP_PROJECT }} +# install_components: "gke-gcloud-auth-plugin" + +# - name: Configure gcloud +# run: gcloud config set compute/region europe-west2 + +# - name: Get cluster credential +# uses: google-github-actions/get-gke-credentials@v1 +# with: +# cluster_name: khagu-dev-cluster +# location: europe-west2 + +# - name: Deploy to GKE +# run: | +# gcloud auth configure-docker europe-west1-docker.pkg.dev +# kubectl apply -f ./server/prod-back.yml diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml new file mode 100644 index 00000000..7f3c11bb --- /dev/null +++ b/.github/workflows/raspberry.yml @@ -0,0 +1,107 @@ +name: Pipeline Prod + +on: # Triggers the workflow + pull_request: # This workflow will run only for pull requests + branches: # This workflow will run only for the main branch + - main + +permissions: + pull-requests: write + +env: + # Use docker.io for Docker Hub if empty + SHA: ${{ github.event.pull_request.head.sha || github.event.after }} + REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API }} + +jobs: + ##### Check de l'image Front ###### + ################################### + check-front-image: + runs-on: ubuntu-latest # OS + steps: + - name: Checkout # Checkout the repository + uses: actions/checkout@v3 # Checkout the repository + + - name: Login to Docker Hub # Login to Docker Hub + uses: docker/login-action@v2 # Docker login action + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} # Docker Hub username + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} # Docker Hub access token + + - name: Extract Docker Front metadata # Extract Docker Front metadata + id: meta # Step ID + uses: docker/metadata-action@v4.4.0 # Docker metadata action + with: + images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }} # Docker Front image + labels: | + org.opencontainers.image.revision=${{ env.SHA }} + tags: | + type=edge,branch=$repo.default_branch + type=semver,pattern=v{{version}} + type=sha,prefix=,suffix=,format=short + + - name: Check Front image # Check Front image + uses: docker/scout-action@v0.18.1 # Docker scout action + with: + command: cves # Command to run on the image + image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} # Docker Front image version to check + exit-code: true # Exit code + + ##### Check de l'image Back ###### + ################################### + check-back-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Extract Docker Back metadata + id: meta + uses: docker/metadata-action@v4.4.0 + with: + images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }} + labels: | + org.opencontainers.image.revision=${{ env.SHA }} + tags: | + type=edge,branch=$repo.default_branch + type=semver,pattern=v{{version}} + type=sha,prefix=,suffix=,format=short + + - name: Check Back image + uses: docker/scout-action@v0.18.1 + with: + command: cves + image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + exit-code: true + + + + ##### Deploiement docker compose ###### + ################################ + deploy: + needs: [check-front-image, check-back-image] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Deploy to Raspberry Pi + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.RASPBERRY_PI_HOST }} + username: ${{ secrets.RASPBERRY_PI_USERNAME }} + key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} + passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} + script: | + docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + scp ./docker-compose.yml ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }}:/Documents/docker-compose.yml + ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} 'docker-compose -f /Documents/docker-compose.yml up -d' + + diff --git a/client/Dockerfile b/client/Dockerfile index 3e0f282a..3081a5c0 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:latest +FROM nginx:latest-arm RUN apt-get update -y diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..7e484b6c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' +services: + frontend: + image: khagu/khagu-dev-front:1.2 + ports: + - 80:80 + backend: + image: khagu/khagu-dev-back:1.1 + ports: + - 7000:7000 \ No newline at end of file diff --git a/server/Dockerfile b/server/Dockerfile index c434e554..0d71d7b8 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,6 +1,6 @@ -FROM node:latest +FROM node:latest-arm -RUN apt-get update && apt-get install -y +RUN apt-get update -y COPY . . From ad3410c337347b580034747a0cd8c37905456159 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 15:51:17 +0200 Subject: [PATCH 03/25] remove arm --- client/Dockerfile | 2 +- server/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index 3081a5c0..3e0f282a 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:latest-arm +FROM nginx:latest RUN apt-get update -y diff --git a/server/Dockerfile b/server/Dockerfile index 0d71d7b8..77102394 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,4 +1,4 @@ -FROM node:latest-arm +FROM node:latest RUN apt-get update -y From 4bf6d9bfbab398309c931c2b4bec4e238b4cef7a Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 16:40:55 +0200 Subject: [PATCH 04/25] replace scp by cat | ssh --- .github/workflows/raspberry.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 7f3c11bb..7bfb3b4d 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -99,9 +99,9 @@ jobs: key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | - docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - scp ./docker-compose.yml ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }}:/Documents/docker-compose.yml + sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + cat ./docker-compose.yml | ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} 'cat > /Documents/docker-compose.yml' ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} 'docker-compose -f /Documents/docker-compose.yml up -d' From 10e6073ebb41413f8c53a0d541eed9dac2628cb2 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 16:58:36 +0200 Subject: [PATCH 05/25] ajout step pour scp docker-compose.yml et modif de la step de deploiement --- .github/workflows/raspberry.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 7bfb3b4d..eadb6a01 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -90,6 +90,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + + - name: Copy docker-compose.yml to Raspberry Pi + uses: appleboy/scp-action@master + with: + host: ${{ secrets.RASPBERRY_PI_HOST }} + username: ${{ secrets.RASPBERRY_PI_USERNAME }} + key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} + passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} + source: "./docker-compose.yml" + target: "/Documents/docker-compose.yml" - name: Deploy to Raspberry Pi uses: appleboy/ssh-action@master @@ -99,9 +109,8 @@ jobs: key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | - sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - cat ./docker-compose.yml | ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} 'cat > /Documents/docker-compose.yml' - ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} 'docker-compose -f /Documents/docker-compose.yml up -d' + sudo docker pull --platform linux/arm64 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + sudo docker pull --platform linux/arm64 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + docker-compose -f /Documents/docker-compose.yml up -d From 67a2c596a1db344f3131ac53708a55051b2897b2 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:04:42 +0200 Subject: [PATCH 06/25] /Documents/docker-compose.yml -> ./Documents... --- .github/workflows/raspberry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index eadb6a01..c31d6fcd 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -99,7 +99,7 @@ jobs: key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} source: "./docker-compose.yml" - target: "/Documents/docker-compose.yml" + target: "./Documents/docker-compose.yml" - name: Deploy to Raspberry Pi uses: appleboy/ssh-action@master From 983787228eb57e553fdef2c44a9e45db912180fe Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:11:58 +0200 Subject: [PATCH 07/25] connexion ssh mano pour deploiement --- .github/workflows/raspberry.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index c31d6fcd..a6ec1a44 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -102,15 +102,10 @@ jobs: target: "./Documents/docker-compose.yml" - name: Deploy to Raspberry Pi - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.RASPBERRY_PI_HOST }} - username: ${{ secrets.RASPBERRY_PI_USERNAME }} - key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} - passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} - script: | - sudo docker pull --platform linux/arm64 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - sudo docker pull --platform linux/arm64 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} + run: | + ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} + sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} + sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} docker-compose -f /Documents/docker-compose.yml up -d From c8000a0d7a188f1e30379eebd8cc0264fa62cec2 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:15:41 +0200 Subject: [PATCH 08/25] specification de la cle dans la connexion --- .github/workflows/prod.yml | 15 +++++++++------ .github/workflows/raspberry.yml | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 4bee72ae..86e40033 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -1,9 +1,12 @@ -# name: Pipeline Prod - -# on: # Triggers the workflow -# # pull_request: # This workflow will run only for pull requests -# # branches: # This workflow will run only for the main branch -# # # - main +name: Pipeline Prod + +on: # Triggers the workflow + # pull_request: # This workflow will run only for pull requests + # branches: # This workflow will run only for the main branch + # - blabla + push: + branches: + - noexist # permissions: # pull-requests: write diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index a6ec1a44..039aeced 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -103,7 +103,7 @@ jobs: - name: Deploy to Raspberry Pi run: | - ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} + ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i ${{ secrets.RASPBERRY_PI_SSH_KEY }} -o StrictHostKeyChecking=no sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} docker-compose -f /Documents/docker-compose.yml up -d From 94f859df406fcda96c78fff086021f0c70875c65 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:21:13 +0200 Subject: [PATCH 09/25] creation de la cle ssh avec le secret et specification de la cle --- .github/workflows/raspberry.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 039aeced..011ca67f 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -103,7 +103,8 @@ jobs: - name: Deploy to Raspberry Pi run: | - ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i ${{ secrets.RASPBERRY_PI_SSH_KEY }} -o StrictHostKeyChecking=no + cat ${{ secrets.RASPBERRY_PI_SSH_KEY }} >> $HOME/.ssh/id_ed25519 + ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i $HOME/.ssh/id_ed25519 sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} docker-compose -f /Documents/docker-compose.yml up -d From 95cbb668fcade28aca1faab00b618dba507ee7fa Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:23:52 +0200 Subject: [PATCH 10/25] .. --- .github/workflows/raspberry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 011ca67f..aa6db6ab 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -103,7 +103,7 @@ jobs: - name: Deploy to Raspberry Pi run: | - cat ${{ secrets.RASPBERRY_PI_SSH_KEY }} >> $HOME/.ssh/id_ed25519 + echo ${{ secrets.RASPBERRY_PI_SSH_KEY }} >> $HOME/.ssh/id_ed25519 ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i $HOME/.ssh/id_ed25519 sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} From d0189423b0517e805a7761afbb68f2834ef6f44d Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:28:56 +0200 Subject: [PATCH 11/25] ajout << EOF --- .github/workflows/raspberry.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index aa6db6ab..483124a6 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -104,9 +104,10 @@ jobs: - name: Deploy to Raspberry Pi run: | echo ${{ secrets.RASPBERRY_PI_SSH_KEY }} >> $HOME/.ssh/id_ed25519 - ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i $HOME/.ssh/id_ed25519 + ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i $HOME/.ssh/id_ed25519 << EOF sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} docker-compose -f /Documents/docker-compose.yml up -d + EOF From 4389507f59919665aeee855f1e279c6d85ba3a20 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 17:53:01 +0200 Subject: [PATCH 12/25] ajout platform arm64 et amd64 au build des images et modif cd pour utiliser ssh-action pour juste docker-compose up --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3941c039..87045b5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ env: # Variables d'environnement declarées dans la vm de l'action DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} DB_USER_PASS: ${{ secrets.DB_USER_PASS }} REACT_APP_URL_API: ${{ vars.REACT_APP_LOCAL_URL_API }} # les vars sont des variables d'environnement stockées dans le répertoire vars du repo sur github + TARGET_PLATFORM: linux/amd64, linux/arm64 jobs: # Jobs de l'action Jest-tests: # Job de l'action pour les tests Jest @@ -113,6 +114,7 @@ jobs: # Jobs de l'action with: context: ./client/ file: ./client/Dockerfile + platforms: ${{ env.TARGET_PLATFORM }} push: true tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} @@ -123,5 +125,6 @@ jobs: # Jobs de l'action with: context: ./server/ file: ./server/Dockerfile + platforms: ${{ env.TARGET_PLATFORM }} push: true tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} From fb833c0986f8ce5c30ca45ecbb43e4e618f033f6 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:05:41 +0200 Subject: [PATCH 13/25] modif chemin scp --- .github/workflows/raspberry.yml | 18 ++++++++++-------- docker-compose.yml | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 483124a6..40bb7a39 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -99,15 +99,17 @@ jobs: key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} source: "./docker-compose.yml" - target: "./Documents/docker-compose.yml" + target: "./Documents/" - name: Deploy to Raspberry Pi - run: | - echo ${{ secrets.RASPBERRY_PI_SSH_KEY }} >> $HOME/.ssh/id_ed25519 - ssh ${{ secrets.RASPBERRY_PI_USERNAME }}@${{ secrets.RASPBERRY_PI_HOST }} -i $HOME/.ssh/id_ed25519 << EOF - sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} - sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} - docker-compose -f /Documents/docker-compose.yml up -d - EOF + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.RASPBERRY_PI_HOST }} + username: ${{ secrets.RASPBERRY_PI_USERNAME }} + key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} + passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} + script: | + cd Documents/ + docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index 7e484b6c..5480cb39 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ version: '3' services: frontend: - image: khagu/khagu-dev-front:1.2 + image: khagu/khagu-dev-front:1.3 ports: - 80:80 backend: - image: khagu/khagu-dev-back:1.1 + image: khagu/khagu-dev-back:1.2 ports: - 7000:7000 \ No newline at end of file From f4773a648100c504ba9afbf48c32bfb5edc8cdb4 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:12:43 +0200 Subject: [PATCH 14/25] docker-compose up > docker compose up --- .github/workflows/raspberry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 40bb7a39..9655fd04 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -110,6 +110,6 @@ jobs: passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | cd Documents/ - docker-compose up -d + docker compose up -d From da6b240536c2b3ef52b0dca80525de19555feea0 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:14:29 +0200 Subject: [PATCH 15/25] docker compose up > sudo docker compose up ... --- .github/workflows/raspberry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 9655fd04..8574f560 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -110,6 +110,6 @@ jobs: passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | cd Documents/ - docker compose up -d + sudo docker compose up -d From c37f584bd07cedfeef345915be57b4cc888455c2 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:17:54 +0200 Subject: [PATCH 16/25] remove version dans docker-compose.yml --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5480cb39..4db6c9ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3' services: frontend: image: khagu/khagu-dev-front:1.3 From cb1c62a4168b9b7569d425af4f863ae0543a5783 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:30:17 +0200 Subject: [PATCH 17/25] change API url --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4db6c9ed..e3d69b89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: frontend: - image: khagu/khagu-dev-front:1.3 + image: khagu/khagu-dev-front:1.4 ports: - 80:80 backend: From 3a8658fcaa78d589c19ab8de09363f8252310ad3 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:40:44 +0200 Subject: [PATCH 18/25] change pipeline name --- .github/workflows/prod.yml | 2 +- .github/workflows/raspberry.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 86e40033..66346d55 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -6,7 +6,7 @@ on: # Triggers the workflow # - blabla push: branches: - - noexist + - logging # permissions: # pull-requests: write diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 8574f560..8c2fc534 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -1,4 +1,4 @@ -name: Pipeline Prod +name: Pipeline Raspberry on: # Triggers the workflow pull_request: # This workflow will run only for pull requests From 8981712a21d5be18ddd92046432db423c4028c6b Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 18:45:13 +0200 Subject: [PATCH 19/25] utilisation ip pour api --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e3d69b89..34e26d56 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: frontend: - image: khagu/khagu-dev-front:1.4 + image: khagu/khagu-dev-front:1.5 ports: - 80:80 backend: From 49857b5242183f4651f3a7b5fa8e358e6e4930a5 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 19:26:00 +0200 Subject: [PATCH 20/25] essais certbot dans conteneur pour ssl --- .github/workflows/prod.yml | 3 +-- .github/workflows/raspberry.yml | 2 ++ client/Dockerfile | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 66346d55..ca858831 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -5,8 +5,7 @@ on: # Triggers the workflow # branches: # This workflow will run only for the main branch # - blabla push: - branches: - - logging + branches: [logging] # permissions: # pull-requests: write diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 8c2fc534..ddd6d844 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -110,6 +110,8 @@ jobs: passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | cd Documents/ + sudo docker-compose run --rm frontend certbot --nginx -d raspberry.khagu-dev.fr -d www.raspberry.khagu-dev.fr + sudo docker-compose run --rm frontend certbot renew --dry-run sudo docker compose up -d diff --git a/client/Dockerfile b/client/Dockerfile index 3e0f282a..e78f141f 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,7 +1,8 @@ FROM nginx:latest -RUN apt-get update -y - +RUN apt-get update \ + && apt-get install -y certbot python-certbot-nginx + COPY ./build/ /usr/share/nginx/html EXPOSE 80 From 04c3c47f496862c88595d1e274656fd8753295f1 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 19:41:16 +0200 Subject: [PATCH 21/25] modif pyhton-certbot... to python3-certbo... --- client/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index e78f141f..dcdb6590 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,8 +1,8 @@ FROM nginx:latest RUN apt-get update \ - && apt-get install -y certbot python-certbot-nginx - + && apt-get install -y certbot python3-certbot-nginx + COPY ./build/ /usr/share/nginx/html EXPOSE 80 From 265f86a2bd267b7f2ed112bc510d06349c059028 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 20:19:50 +0200 Subject: [PATCH 22/25] 1.6 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 34e26d56..6331632c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: frontend: - image: khagu/khagu-dev-front:1.5 + image: khagu/khagu-dev-front:1.6 ports: - 80:80 backend: From 937f860492354954de31e488e742d7b29533cd4c Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 20:33:03 +0200 Subject: [PATCH 23/25] daw --- .github/workflows/raspberry.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index ddd6d844..56822f6c 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -110,8 +110,8 @@ jobs: passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | cd Documents/ - sudo docker-compose run --rm frontend certbot --nginx -d raspberry.khagu-dev.fr -d www.raspberry.khagu-dev.fr - sudo docker-compose run --rm frontend certbot renew --dry-run + sudo docker compose run --rm frontend certbot --nginx -d raspberry.khagu-dev.fr -d www.raspberry.khagu-dev.fr + sudo docker compose run --rm frontend certbot renew --dry-run sudo docker compose up -d From 4ba06b29b4370b931348f3d6f3443d3ffbb07941 Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 20:37:10 +0200 Subject: [PATCH 24/25] remove certbot du script de deploiement --- .github/workflows/raspberry.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry.yml index 56822f6c..91c2a644 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry.yml @@ -109,9 +109,7 @@ jobs: key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} script: | - cd Documents/ - sudo docker compose run --rm frontend certbot --nginx -d raspberry.khagu-dev.fr -d www.raspberry.khagu-dev.fr - sudo docker compose run --rm frontend certbot renew --dry-run + cd Documents sudo docker compose up -d From ccfc612c984c71244a519cf8e1b8fe87e16d77ff Mon Sep 17 00:00:00 2001 From: Maxence Date: Sat, 13 Apr 2024 20:46:52 +0200 Subject: [PATCH 25/25] modif dockerfile front --- client/Dockerfile | 3 ++- docker-compose.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index dcdb6590..661eb2b1 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,7 +1,8 @@ FROM nginx:latest RUN apt-get update \ - && apt-get install -y certbot python3-certbot-nginx + && apt-get install -y certbot python3-certbot-nginx \ + && echo 'location ~ /.well-known/acme-challenge/ { allow all; root /var/www/html; }' > /etc/nginx/conf.d/default.conf COPY ./build/ /usr/share/nginx/html diff --git a/docker-compose.yml b/docker-compose.yml index 6331632c..01f47ca6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: frontend: - image: khagu/khagu-dev-front:1.6 + image: khagu/khagu-dev-front:1.7 ports: - 80:80 backend: