diff --git a/docs/ecolyo/ecolyo-agent/development/backup.md b/docs/ecolyo/ecolyo-agent/development/backup.md index 1752221cfb84b7fdf0b1b29f7ea05bfd2974b34c..26410239bc3845860abd5d3eee91746417519b99 100644 --- a/docs/ecolyo/ecolyo-agent/development/backup.md +++ b/docs/ecolyo/ecolyo-agent/development/backup.md @@ -13,7 +13,7 @@ The location of the backup folder on the server is specified in the volumes of t To backup manually, run this command : ``` -docker exec -it backoffice-client_database-backup_1 sh /etc/cron.d/restore.sh ecolyo-agent-YEAR-MONTH-DAY-HOUR-MINUTE-SECOND +docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/backup.sh ``` ## Restore manually @@ -21,5 +21,5 @@ docker exec -it backoffice-client_database-backup_1 sh /etc/cron.d/restore.sh ec To restore a specific dump, run this command replacing YEAR etc.. by the date of the wanted backup : ``` -docker exec -it backoffice-client_database-backup_1 sh /etc/cron.d/restore.sh ecolyo-agent-YEAR-MONTH-DAY-HOUR-MINUTE-SECOND +docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/restore.sh ecolyo-agent-YEAR-MONTH-DAY-HOUR-MINUTE-SECOND ``` \ No newline at end of file diff --git a/docs/ecolyo/ecolyo-agent/development/deploy.md b/docs/ecolyo/ecolyo-agent/development/deploy.md index 3c88e3af82565c692997af24c2d1e687a403570a..ee836ece245c9839819b459765eb80b4100f7044 100644 --- a/docs/ecolyo/ecolyo-agent/development/deploy.md +++ b/docs/ecolyo/ecolyo-agent/development/deploy.md @@ -28,7 +28,7 @@ services: - 3306:3306 networks: backoffice: - restart: unless-stopped + restart: always environment: MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} MYSQL_DATABASE: ${DATABASE_NAME} @@ -38,20 +38,34 @@ services: timeout: 10s retries: 60 + database-backup: + image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:db-backup + networks: + backoffice: + environment: + MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} + MYSQL_DATABASE: ${DATABASE_NAME} + volumes: + - /mnt/local/data/backup:/backup + restart: unless-stopped + depends_on: + database-agent: + condition: service_healthy + backend: image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev networks: backoffice: depends_on: database-agent: - condition: service_healthy + condition: service_healthy restart: unless-stopped volumes: - /etc/localtime:/etc/localtime:ro - ./configs:/app/configs - ./letsencrypt_cache:/app/letsencrypt_cache - ./data:/app/data - - ./image-lib/${IMAGE_FOLDER}:/app/${IMAGE_FOLDER} + - ./${IMAGE_FOLDER}:/app/${IMAGE_FOLDER} ports: - ${HTTPS_PORT}:${HTTPS_PORT} - 8190:8090 @@ -72,7 +86,6 @@ services: - DATABASE_NAME=${DATABASE_NAME} - DATABASE_PASSWORD=${DATABASE_PASSWORD} - DATABASE_HOST=database-agent - networks: backoffice: ``` @@ -81,44 +94,44 @@ networks: ``` server { - listen 8080; - server_name ecolyo-agent-rec.grandlyon.com; - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html =404; - } - location /api { - proxy_pass https://backend:1443/api; - } - location /OAuth2Login { - proxy_pass https://backend:1443/OAuth2Login; - } - location /OAuth2Callback { - proxy_pass https://backend:1443/OAuth2Callback; - } - location /Logout { - proxy_pass https://backend:1443/Logout; - } - location /swagger { - proxy_pass https://backend:1443/swagger; - } - location /imageNames { - proxy_pass https://backend:1443/api/admin/imageNames; - } - # cozy-doctypes workaround - location /email { - # if ($arg_serviceName != overview) { return 404; } if ($arg_param !~ "^\d+$") { return 404; } if ($arg_serviceName ="image") { rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; - #} - proxy_pass https://backend:1443/api/common/monthlyReport/$arg_param; - # rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; - } - location ~ ^/assets/(.+\.(?:gif|jpe?g|svg|png))$ { - alias /usr/share/nginx/html/lib/$1; - gzip_static on; - expires max; - add_header Cache-Control public; - } + listen 8080; + server_name ecolyo-agent.grandlyon.com; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } + location /api { + proxy_pass https://backend:1443/api; + } + location /OAuth2Login { + proxy_pass https://backend:1443/OAuth2Login; + } + location /OAuth2Callback { + proxy_pass https://backend:1443/OAuth2Callback; + } + location /Logout { + proxy_pass https://backend:1443/Logout; + } + location /swagger { + proxy_pass https://backend:1443/swagger; + } + location /imageNames { + proxy_pass https://backend:1443/api/admin/imageNames; + } + # cozy-doctypes workaround + location /email { + # if ($arg_serviceName != overview) { return 404; } if ($arg_param !~ "^\d+$") { return 404; } if ($arg_serviceName = "image") { rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; + #} + proxy_pass https://backend:1443/api/common/monthlyReport/$arg_param; + # rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; + } + location ~ ^/assets/(.+\.(?:gif|jpe?g|svg|png))$ { + alias /usr/share/nginx/html/lib/$1; + gzip_static on; + expires max; + add_header Cache-Control public; + } } ``` @@ -141,7 +154,7 @@ ADMIN_ROLE=****** DEBUG_MODE=false MOCK_OAUTH2=false HTTPS_PORT=1443 -IMAGE_FOLDER=ecogesture +IMAGE_FOLDER=image-lib # Needed to user OAuth2 authentication : REDIRECT_URL=https://${HOSTNAME}:443/OAuth2Callback diff --git a/docs/ecolyo/ecolyo-agent/development/handle_assets.md b/docs/ecolyo/ecolyo-agent/development/handle_assets.md index f5d875609b0f25932abc6e8f7a46502ac99bd46c..047c620b28015174216247598f07e9136ff32fab 100644 --- a/docs/ecolyo/ecolyo-agent/development/handle_assets.md +++ b/docs/ecolyo/ecolyo-agent/development/handle_assets.md @@ -1,42 +1,47 @@ This section will allow you to import the assets used in the newletters from Ecolyo -## Export assets - -In Ecolyo project, open a terminal in "/src/assets" folder and run -``` -docker build . -t registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:assets -docker push registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:assets -``` -This will create a small docker image containing all the images needed, converted in png format, and push it to the container registry in the backoffice-client repository. ## Import assets -In the rec or prod server, create a import_assets.sh file and add execution permission. +In the rec or prod server, in the folder ```scripts```, there is the following script, named ```import-convert-assets.sh``` . -Copy the following content, replacing USERNAME and PASSWORD by the project access token -``` +```bash #!/bin/bash -#Login and pull assets container image -docker login -u USERNAME -p PASSWORD https://registry.forge.grandlyon.com/v2/web-et-numerique/llle_project/backoffice-client -docker pull registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:assets - -# Instanciate container -docker rm assets -docker run --name assets -it registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:assets sh - -# Copy files -sudo rm -rf ../image-lib -sudo docker cp assets:/image-lib ../image-lib - -# Give permission to the container user -sudo chown -R 1000:1000 ../image-lib +# Get env variables +. ../.env +EMAIL_ASSETS_PATH="src/assets/icons/email" +ECOGESTURE_ASSETS_PATH="src/assets/icons/visu/ecogesture" +EXPORT_FORMAT=".png" +pwd=$(pwd) + +# Fetch and convert email assets +curl "https://forge.grandlyon.com/api/v4/projects/409/repository/archive?path=${EMAIL_ASSETS_PATH}" --output email.tar.gz +tar -xf email.tar.gz +cd *-email/$EMAIL_ASSETS_PATH && for file in *.svg; do inkscape -h 200 -w 200 -e $(echo "$file" | sed "s/.svg/$EXPORT_FORMAT/") $file; done && rm *.svg +cd $pwd + +# Fetch and convert ecogesture assets +curl "https://forge.grandlyon.com/api/v4/projects/409/repository/archive?path=$ECOGESTURE_ASSETS_PATH" --output ecogesture.tar.gz +tar -xf ecogesture.tar.gz +cd *-ecogesture/$ECOGESTURE_ASSETS_PATH && for file in *.svg; do inkscape -h 200 -w 200 -e $(echo "$file" | sed "s/.svg/$EXPORT_FORMAT/") ${file}; done && rm *.svg + +# Cleanup +cd $pwd +rm -rf ../$IMAGE_FOLDER +mv *-email/$EMAIL_ASSETS_PATH ../$IMAGE_FOLDER +mv *-ecogesture/$ECOGESTURE_ASSETS_PATH ../$IMAGE_FOLDER/ecogesture +rm -rf email.tar.gz ecogesture.tar.gz *-email *-ecogesture + +# Give ownership to container user +chown -R 1000:1000 ../$IMAGE_FOLDER ``` -To import assets for the ecogesture images, run +To import assets for the ecogesture images, run (inside of ```scripts``` folder) ``` -sudo sh scripts/import_assets.sh +sudo sh import-convert-assets.sh ``` -Check that a "image-lib" folder has been created, that it contains a "ecogesture" folder and some images and that the owner of the "image-lib" folder is the user id 1000. + +Check that a "image-lib" folder has been created, that it contains a "ecogesture" folder and some PNG images and that the owner of the "image-lib" folder is the user id 1000.