Skip to content

Commit

Permalink
Adding ngnix
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Nov 4, 2020
1 parent c986850 commit ceb63d0
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
27 changes: 23 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM node:14.11
FROM node:14.11 as build
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_ENV=${NODE_ENV:-development}
ENV PORT=${PORT:-4000}
ENV API_URL=${API_URL:-http://127.0.0.1:8000}
RUN mkdir /app
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
Expand All @@ -19,11 +21,28 @@ ADD package.json /app/
ADD package-lock.json /app/

ADD start.sh /app/
ADD start-prod.sh /app/
RUN chmod +x start.sh
RUN chmod +x start-prod.sh

RUN npm run build
RUN cp public/bootstrap.min.css dist/
RUN cp public/favicon.ico dist/
CMD ["bash", "-c", "./start-prod.sh"]

CMD ["bash", "-c", "./start.sh"]

# Stage-2 Production Environment
FROM nginx:1.12-alpine

# Add bash
RUN apk add --no-cache bash

# Copy the tagged files from the build to the production environmnet of the nginx server
COPY --from=build /app/dist/ /usr/share/nginx/html/

# Copy nginx configuration
ADD ngnix /etc/nginx/conf.d/

# Make port 80 available to the world outside the container
EXPOSE 80

# Start the server
CMD nginx -g "daemon off;"
17 changes: 17 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'

services:
web:
image: openconceptlab/oclweb2:dev
build:
context: .
target: build
ports:
- "4000:4000"
- "4001:35729"
- "6006:6006"
restart: on-failure
volumes:
- .:/app:z
environment:
- PORT=4000
13 changes: 4 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ version: '3'

services:
web:
build: .
image: openconceptlab/oclweb2:${ENVIRONMENT-latest}
build:
context: .
ports:
- "4000:4000"
- "4001:35729"
- "6006:6006"
- "80:4000"
restart: on-failure
command: ["bash", "-c", "./start.sh"]
volumes:
- .:/app:z
environment:
- API_URL=${API_URL-http://127.0.0.1:8000}
- NODE_ENV=${NODE_ENV-development}
- PORT=4000
14 changes: 14 additions & 0 deletions ngnix/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2 changes: 0 additions & 2 deletions start-prod.sh

This file was deleted.

2 changes: 2 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash
# Startup in development mode

npm update && npm install
npm start

0 comments on commit ceb63d0

Please sign in to comment.