diff --git a/Dockerfile b/Dockerfile index 5a5baee68b4a9d3c19fdf638dd47302fb4653ff3..ecebd1c25fa2f551943745424879f8bf854f97ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ COPY ./webapp /app/webapp WORKDIR /app/webapp # Install npm dependencies RUN npm install +RUN npm rebuild node-sass # Building the Angular app /dist i18n RUN npm run build-i18n @@ -17,5 +18,7 @@ COPY --from=builder /app/webapp/dist /usr/share/nginx/html ## Install dependency to get lua module in .conf RUN apt-get update + RUN apt-get --assume-yes install nginx-extras + diff --git a/node-server/.gitignore b/node-server/.gitignore deleted file mode 100644 index b2d59d1f7578b05e96f3b3f8a7d5039df3d06fb6..0000000000000000000000000000000000000000 --- a/node-server/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/node_modules -/dist \ No newline at end of file diff --git a/node-server/package.json b/node-server/package.json deleted file mode 100644 index 4f9b449aa4ca782723061647aea5c44db202d4e8..0000000000000000000000000000000000000000 --- a/node-server/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "node-server", - "version": "1.0.0", - "description": "", - "main": "server.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" - }, - "author": "", - "license": "ISC", - "dependencies": { - "body-parser": "^1.18.2", - "compression": "^1.7.2", - "express": "^4.16.3" - } -} diff --git a/node-server/server.js b/node-server/server.js deleted file mode 100644 index b60e3e7d0941b1f2cd8b998df953ba041dcf4242..0000000000000000000000000000000000000000 --- a/node-server/server.js +++ /dev/null @@ -1,43 +0,0 @@ -// Use ng build to build your app into build directory. -// Create nodejs app to server the build directory as static content, then create route for api. -// Following is an example of nodejs app using express that will serve the Angular2 app: - -/* -Put content of angular2 build into 'public' folder. -*/ -const html = __dirname + '/dist'; - -const port = 8080; - -// Express -const bodyParser = require('body-parser'); -const compression = require('compression'); -const express = require('express'); -var app = express(); - -app - .use(compression()) - .use(bodyParser.json()) - // Static content - .use(express.static(html)) - .use('/', function(req, res) { - // Check if language is set in url else take browser settings from http request header - const language = req.path.split('/')[1] || req.acceptsLanguages()[0]; - let redirect = ''; - - switch (language) { - case 'fr': - case 'fr-FR': - redirect = '/fr'; - break; - default: - redirect = '/en'; - - } - res.redirect(redirect); - }) - // Start server - .listen(port, function () { - console.log('Port: ' + port); - console.log('Html: ' + html); - }); \ No newline at end of file diff --git a/webapp-nginx.conf b/webapp-nginx.conf index 49e82096e4161e7c86c0ed08747165c751e1417d..3cd6d4af67c280841eb5a6eb3f1cc5ecea569e7d 100644 --- a/webapp-nginx.conf +++ b/webapp-nginx.conf @@ -2,29 +2,28 @@ server { listen 8080; server_name portail-data; - root /usr/share/nginx/html; + root /usr/share/nginx/html/; -location = / { -rewrite_by_lua ' -for lang in (ngx.var.http_accept_language .. ","):gmatch("([^,]*),") do - if string.sub(lang, 0, 2) == "en" then - ngx.redirect("/en/") - end - if string.sub(lang, 0, 2) == "fr" then - ngx.redirect("/fr/") - end -end -'; -#rewrite ^/$ /en/ permanent; + location = / { + rewrite_by_lua ' + for lang in (ngx.var.http_accept_language .. ","):gmatch("([^,]*),") do + if string.sub(lang, 0, 2) == "en" then + ngx.redirect("/en/") + end + if string.sub(lang, 0, 2) == "fr" then + ngx.redirect("/fr/") + end + end + ngx.redirect("/en/") + '; + } -# First attempt to serve request as file, then -# as directory, then fall back to displaying a 404. -# Uncomment to enable naxsi on this location -# include /etc/nginx/naxsi.rules -} - error_page 404 = @notfound; + location /en/ { + try_files $uri$args $uri/ /en/index.html; + } - location @notfound { - return 301 /; + location /fr/ { + try_files $uri$args $uri/ /fr/index.html; } + } \ No newline at end of file