Skip to content
Snippets Groups Projects
Commit 05b2efa1 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

feat: updates and corrections about the backoffice

parent c6401ad5
No related branches found
No related tags found
1 merge request!5feat: updates and corrections about the backoffice
...@@ -13,7 +13,7 @@ The location of the backup folder on the server is specified in the volumes of t ...@@ -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 : 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 ## Restore manually
...@@ -21,5 +21,5 @@ docker exec -it backoffice-client_database-backup_1 sh /etc/cron.d/restore.sh ec ...@@ -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 : 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
...@@ -28,7 +28,7 @@ services: ...@@ -28,7 +28,7 @@ services:
- 3306:3306 - 3306:3306
networks: networks:
backoffice: backoffice:
restart: unless-stopped restart: always
environment: environment:
MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
MYSQL_DATABASE: ${DATABASE_NAME} MYSQL_DATABASE: ${DATABASE_NAME}
...@@ -38,20 +38,34 @@ services: ...@@ -38,20 +38,34 @@ services:
timeout: 10s timeout: 10s
retries: 60 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: backend:
image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev
networks: networks:
backoffice: backoffice:
depends_on: depends_on:
database-agent: database-agent:
condition: service_healthy condition: service_healthy
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
- ./configs:/app/configs - ./configs:/app/configs
- ./letsencrypt_cache:/app/letsencrypt_cache - ./letsencrypt_cache:/app/letsencrypt_cache
- ./data:/app/data - ./data:/app/data
- ./image-lib/${IMAGE_FOLDER}:/app/${IMAGE_FOLDER} - ./${IMAGE_FOLDER}:/app/${IMAGE_FOLDER}
ports: ports:
- ${HTTPS_PORT}:${HTTPS_PORT} - ${HTTPS_PORT}:${HTTPS_PORT}
- 8190:8090 - 8190:8090
...@@ -72,7 +86,6 @@ services: ...@@ -72,7 +86,6 @@ services:
- DATABASE_NAME=${DATABASE_NAME} - DATABASE_NAME=${DATABASE_NAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD} - DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_HOST=database-agent - DATABASE_HOST=database-agent
networks: networks:
backoffice: backoffice:
``` ```
...@@ -81,44 +94,44 @@ networks: ...@@ -81,44 +94,44 @@ networks:
``` ```
server { server {
listen 8080; listen 8080;
server_name ecolyo-agent-rec.grandlyon.com; server_name ecolyo-agent.grandlyon.com;
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html index.htm; index index.html index.htm;
try_files $uri $uri/ /index.html =404; try_files $uri $uri/ /index.html =404;
} }
location /api { location /api {
proxy_pass https://backend:1443/api; proxy_pass https://backend:1443/api;
} }
location /OAuth2Login { location /OAuth2Login {
proxy_pass https://backend:1443/OAuth2Login; proxy_pass https://backend:1443/OAuth2Login;
} }
location /OAuth2Callback { location /OAuth2Callback {
proxy_pass https://backend:1443/OAuth2Callback; proxy_pass https://backend:1443/OAuth2Callback;
} }
location /Logout { location /Logout {
proxy_pass https://backend:1443/Logout; proxy_pass https://backend:1443/Logout;
} }
location /swagger { location /swagger {
proxy_pass https://backend:1443/swagger; proxy_pass https://backend:1443/swagger;
} }
location /imageNames { location /imageNames {
proxy_pass https://backend:1443/api/admin/imageNames; proxy_pass https://backend:1443/api/admin/imageNames;
} }
# cozy-doctypes workaround # cozy-doctypes workaround
location /email { 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; # 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; proxy_pass https://backend:1443/api/common/monthlyReport/$arg_param;
# rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; # rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent;
} }
location ~ ^/assets/(.+\.(?:gif|jpe?g|svg|png))$ { location ~ ^/assets/(.+\.(?:gif|jpe?g|svg|png))$ {
alias /usr/share/nginx/html/lib/$1; alias /usr/share/nginx/html/lib/$1;
gzip_static on; gzip_static on;
expires max; expires max;
add_header Cache-Control public; add_header Cache-Control public;
} }
} }
``` ```
...@@ -141,7 +154,7 @@ ADMIN_ROLE=****** ...@@ -141,7 +154,7 @@ ADMIN_ROLE=******
DEBUG_MODE=false DEBUG_MODE=false
MOCK_OAUTH2=false MOCK_OAUTH2=false
HTTPS_PORT=1443 HTTPS_PORT=1443
IMAGE_FOLDER=ecogesture IMAGE_FOLDER=image-lib
# Needed to user OAuth2 authentication : # Needed to user OAuth2 authentication :
REDIRECT_URL=https://${HOSTNAME}:443/OAuth2Callback REDIRECT_URL=https://${HOSTNAME}:443/OAuth2Callback
......
This section will allow you to import the assets used in the newletters from Ecolyo 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 ## 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 #!/bin/bash
#Login and pull assets container image # Get env variables
docker login -u USERNAME -p PASSWORD https://registry.forge.grandlyon.com/v2/web-et-numerique/llle_project/backoffice-client . ../.env
docker pull registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:assets EMAIL_ASSETS_PATH="src/assets/icons/email"
ECOGESTURE_ASSETS_PATH="src/assets/icons/visu/ecogesture"
# Instanciate container EXPORT_FORMAT=".png"
docker rm assets pwd=$(pwd)
docker run --name assets -it registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:assets sh
# Fetch and convert email assets
# Copy files curl "https://forge.grandlyon.com/api/v4/projects/409/repository/archive?path=${EMAIL_ASSETS_PATH}" --output email.tar.gz
sudo rm -rf ../image-lib tar -xf email.tar.gz
sudo docker cp assets:/image-lib ../image-lib 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
# Give permission to the container user
sudo chown -R 1000:1000 ../image-lib # 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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment