diff --git a/Dockerfile b/Dockerfile index 83be11124a5f29739d9eec1be917877e9bf2ee1f..bee682a15c8297a99baf8b87a0fb52c7f50a759f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ COPY /src ./src ARG conf # Building the Angular app /dist i18n -RUN npm run build:dev +RUN npm run build:prod # Stage 1, based on Nginx, to have only the compiled app FROM nginx diff --git a/angular.json b/angular.json index 6e95360f6a90b5417e30d67c101ad0e1abe2b9be..962c5cd18d48fe6f6aa52040ec860e7d1878885b 100644 --- a/angular.json +++ b/angular.json @@ -14,9 +14,15 @@ "sourceRoot": "src", "prefix": "app", "i18n": { - "sourceLocale": "fr", + "sourceLocale": { + "code": "fr", + "baseHref": "" + }, "locales": { - "en": "src/locale/messages.en.xlf" + "en": { + "baseHref": "/en/", + "translation": "src/locale/messages.en.xlf" + } } }, "architect": { @@ -54,6 +60,7 @@ "with": "src/environments/environment.prod.ts" } ], + "aot": true, "optimization": true, "outputHashing": "all", "sourceMap": false, diff --git a/nginx/dev.conf b/nginx/dev.conf index 4265eb65e22870cbc8b3a4d515aca6b0a8572f41..9496c647f0737219e07008b68a98f6d0d9788b63 100644 --- a/nginx/dev.conf +++ b/nginx/dev.conf @@ -1,24 +1,17 @@ -upstream api_node_js { - server service-ram:3000; -} - server { listen 8080 default_server; - root /usr/share/nginx/html; - index index.html; + root /usr/share/nginx/html/; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. - try_files $uri $uri/ $uri/index.html @backend; + try_files $uri $uri/ /index.html; } - location @backend { - rewrite /api/?(.*) /$1 break; - proxy_pass http://api_node_js; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Real-IP $remote_addr; + location /api { + rewrite ^/api/(.*) /$1 break; + proxy_pass http://service-ram:3000/api; } location /base-adresse/base-adresse-nationale/streets { @@ -38,6 +31,7 @@ server { proxy_pass https://download.data.grandlyon.com/wfs/grandlyon; } + # REALLY important for JavaScript modules (type="module") to work as expected!!! location ~ \.js { add_header Content-Type text/javascript; diff --git a/src/index.html b/src/index.html index 9e350807caa211c6211153b2bd75853378be4ac2..034e83f362a671532cf29573af2a2b3ebd73ad4a 100644 --- a/src/index.html +++ b/src/index.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="fr"> <head> <meta charset="utf-8" /> <title>Réseau des Acteurs de la Médiation</title>