From 04041d1d9652f834666b98a37e80d31106b5ad22 Mon Sep 17 00:00:00 2001 From: ncastejon <castejon.nicolas@gmail.com> Date: Wed, 11 Apr 2018 16:54:43 +0200 Subject: [PATCH] Merge webapp & nginx Docker services into one. --- Dockerfile | 18 +++++++++++++++++- docker-compose-staging.yml | 5 ----- webapp-nginx.conf | 1 - webapp/Dockerfile | 22 ---------------------- 4 files changed, 17 insertions(+), 29 deletions(-) delete mode 100644 webapp/Dockerfile diff --git a/Dockerfile b/Dockerfile index 12a84004..2d79d85f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,21 @@ +# 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 +# Building the Angular app /dist i18n +RUN npm run build-i18n + +# Stage 1, based on Nginx, to have only the compiled app 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 --yes --force-yes install nginx-extras -RUN apt-get --yes --force-yes install nginx-extras \ No newline at end of file diff --git a/docker-compose-staging.yml b/docker-compose-staging.yml index 32a233f5..0235e7f3 100644 --- a/docker-compose-staging.yml +++ b/docker-compose-staging.yml @@ -1,10 +1,6 @@ version: "2" services: - - node-server: - build: ./webapp - proxy-elasticsearch: image: nginx volumes: @@ -17,7 +13,6 @@ services: context: ./ volumes: - ./webapp-nginx.conf:/etc/nginx/conf.d/default.conf - - ./webapp/dist:/usr/share/nginx/html ports: - 8080:8080 diff --git a/webapp-nginx.conf b/webapp-nginx.conf index dd41d66b..49e82096 100644 --- a/webapp-nginx.conf +++ b/webapp-nginx.conf @@ -14,7 +14,6 @@ for lang in (ngx.var.http_accept_language .. ","):gmatch("([^,]*),") do ngx.redirect("/fr/") end end -ngx.redirect("/en/") '; #rewrite ^/$ /en/ permanent; diff --git a/webapp/Dockerfile b/webapp/Dockerfile deleted file mode 100644 index c381c792..00000000 --- a/webapp/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -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 -- GitLab