Newer
Older
This section will allow you to properly deploy Ecolyo-Agent in a production environment
## Deploy Ecolyo-Agent application
To deploy ecolyo-agent application in a production environment, you need to create docker-compose.yml, site.conf and .env files
### docker-compose.yml
```
version: '3.7'
services:
nginx:
image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:dev
restart: unless-stopped
ports:
- 8080:8080
depends_on:
- backend
networks:
backoffice:
volumes:
- ./site.conf:/etc/nginx/conf.d/default.conf
- ./image-lib:/usr/share/nginx/html/lib
database-agent:
image: mysql:5
ports:
- 3306:3306
networks:
backoffice:
environment:
MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
MYSQL_DATABASE: ${DATABASE_NAME}
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
interval: 5s
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
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- ./configs:/app/configs
- ./letsencrypt_cache:/app/letsencrypt_cache
- ./data:/app/data
- ./${IMAGE_FOLDER}:/app/${IMAGE_FOLDER}
ports:
- ${HTTPS_PORT}:${HTTPS_PORT}
- 8190:8090
environment:
- HOSTNAME=${HOSTNAME}
- HTTPS_PORT=${HTTPS_PORT}
- ADMIN_ROLE=${ADMIN_ROLE}
- REDIRECT_URL=${REDIRECT_URL}
- CLIENT_ID=${CLIENT_ID}
- CLIENT_SECRET=${CLIENT_SECRET}
- AUTH_URL=${AUTH_URL}
- IMAGE_FOLDER=${IMAGE_FOLDER}
- MOCK_OAUTH2=${MOCK_OAUTH2}
- TOKEN_URL=${TOKEN_URL}
- USERINFO_URL=${USERINFO_URL}
- DEBUG_MODE=${DEBUG_MODE}
- DATABASE_USER=${DATABASE_USER}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_HOST=database-agent
networks:
backoffice:
```
### site.conf
```
server {
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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;
}
}
```
### .env
In this file, add the variables as described in the env-template file in the git repo
To use OAuth2 login ask your client ID and client secret
Here is the config to run the app
```
NODE_TLS_REJECT_UNAUTHORIZED = '0'
HTTPS=true
SSL_CRT_FILE=cert.pem
SSL_KEY_FILE=key.pem
# Common settings
HOSTNAME=your_url.com
ADMIN_ROLE=******
DEBUG_MODE=false
MOCK_OAUTH2=false
HTTPS_PORT=1443
IMAGE_FOLDER=image-lib
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Needed to user OAuth2 authentication :
REDIRECT_URL=https://${HOSTNAME}:443/OAuth2Callback
CLIENT_ID=**get one from your IDP**
CLIENT_SECRET=**get one from your IDP**
AUTH_URL=**get it from your IDP**
TOKEN_URL=**get it from your IDP**
USERINFO_URL=**get it from your IDP**
LOGOUT_URL=/
# Access to the database
DATABASE_USER=******
DATABASE_PASSWORD=*******
DATABASE_NAME=backoffice
```
## Start the application
Then start the app by launching the command :
```
docker-compose up -d
```
To check if the application starts successfully, launch the command
```
docker logs backoffice-client_backend_1
```
You should obtain the following messages:
> --- Server is starting ---
> Token signing key set