Skip to content
Snippets Groups Projects
Commit cd292f76 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Remove node.js server, clean Dockerfile and nginx conf

parents b230d205 04041d1d
No related branches found
No related tags found
No related merge requests found
# Stage 0, based on Node.js, to build and compile Angular
FROM node:8.10.0 as builder
# Copy the current directory contents into the container at /app
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
# Stage 1, based on Nginx, to have only the compiled app
FROM nginx FROM nginx
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 update
RUN apt-get --yes --allow install nginx-extras
RUN apt-get --yes --force-yes install nginx-extras
\ No newline at end of file
version: "2" version: "2"
services: services:
# node-server:
# build: ./webapp
proxy-elasticsearch: proxy-elasticsearch:
image: nginx image: nginx
volumes: volumes:
...@@ -17,7 +13,6 @@ services: ...@@ -17,7 +13,6 @@ services:
context: ./ context: ./
volumes: volumes:
- ./webapp-nginx.conf:/etc/nginx/conf.d/default.conf - ./webapp-nginx.conf:/etc/nginx/conf.d/default.conf
- ./webapp/dist:/usr/share/nginx/html
ports: ports:
- 8080:8080 - 8080:8080
/node_modules
/dist
\ No newline at end of file
{
"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"
}
}
// 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
...@@ -16,12 +16,6 @@ server { ...@@ -16,12 +16,6 @@ server {
end end
ngx.redirect("/en/") ngx.redirect("/en/")
'; ';
#rewrite ^/$ /en/ permanent;
# 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
} }
location /en/ { location /en/ {
......
FROM node:8.10.0
# Copy the current directory contents into the container at /app
COPY . /app/webapp
#COPY ../node-server /app/node-server
WORKDIR /app/webapp
# Install npm dependencies
RUN npm install
# Building the Angular app /dist i18n
RUN npm run win-build-i18n:fr
#RUN cp -r ./dist ../node-server/dist
# Set the working directory to /node-server
#WORKDIR /app/node-server
# Install npm dependencies
#RUN npm install
#EXPOSE 8080
#CMD npm start
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment