Skip to content
Snippets Groups Projects
Commit c8b65d2f authored by Hugo NOUTS's avatar Hugo NOUTS
Browse files

Merge branch 'feat/backoffice-corrections' into 'master'

feat: updates and corrections about the backoffice

See merge request web-et-numerique/llle_project/self-data-technical-doc!5
parents c6401ad5 05b2efa1
No related branches found
No related tags found
1 merge request!5feat: updates and corrections about the backoffice
Pipeline #20111 passed
......@@ -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
......@@ -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
......
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.
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