Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.

(WIP) Feature/docker deploy prod #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .docker/dist-build.development.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:6.6

# prepare a user which runs everything locally! - required in child images!
RUN useradd --user-group --create-home --shell /bin/false app

ENV HOME=/home/app
WORKDIR $HOME

RUN npm install -g [email protected] && npm cache clean

ENV APP_NAME=crudular

# before switching to user we need to set permission properly
# copy all files, except the ignored files from .dockerignore
COPY . $HOME/$APP_NAME/
RUN chown -R app:app $HOME/*

USER app
WORKDIR $HOME/$APP_NAME

RUN npm install &&\
npm cache clean

CMD ["ng", "serve", "--host", "0.0.0.0", "--port", "4200"]
24 changes: 24 additions & 0 deletions .docker/dist-build.production.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:6.6

# prepare a user which runs everything locally! - required in child images!
RUN useradd --user-group --create-home --shell /bin/false app

ENV HOME=/home/app
WORKDIR $HOME

RUN npm install -g [email protected] && npm cache clean

ENV APP_NAME=crudular

# before switching to user we need to set permission properly
# copy all files, except the ignored files from .dockerignore
COPY . $HOME/$APP_NAME/
RUN chown -R app:app $HOME/*

USER app
WORKDIR $HOME/$APP_NAME

RUN npm install &&\
npm cache clean

CMD ["ng", "serve", "--prod", "--host", "0.0.0.0", "--port", "4200"]
12 changes: 12 additions & 0 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen ${NGINX_PORT};
server_name ${NGINX_HOST};

root /var/tmp/crudular/dist/prod;

index index.html;

location ~ ^/.+/$ {
rewrite .* /index.html last;
}
}
32 changes: 32 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# compiled output
dist
tmp

# dependencies
node_modules
bower_components

# IDEs and editors
.idea
.vscode
.project
.classpath
*.launch
.settings/

# misc
.sass-cache
connect.lock
coverage/*
libpeerconnection.log
npm-debug.log
testem.log
typings

# e2e
e2e/*.js
e2e/*.map

#System Files
.DS_Store
Thumbs.db
32 changes: 32 additions & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '2'

services:

dist-build:
container_name: dist-build
image: dist-build
build:
context: .
dockerfile: ./.docker/dist-build.production.dockerfile
ports:
- '4200:4200'
networks:
- dist-network

nginx:
container_name: nginx
image: nginx
volumes:
- ./.docker/nginx.conf:/etc/nginx/conf.d/crudular.template
ports:
- "8080:80"
environment:
- NGINX_HOST=localhost
- NGINX_PORT=80
command: /bin/bash -c "envsubst '$$NGINX_HOST $$NGINX_PORT' < /etc/nginx/conf.d/crudular.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
networks:
- dist-network

networks:
dist-network:
driver: bridge
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '2'

services:

dist-build:
container_name: dist-build
image: dist-build
build:
context: .
dockerfile: ./.docker/dist-build.development.dockerfile
ports:
- '4200:4200'
networks:
- dist-network

networks:
dist-network:
driver: bridge