-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker configurations for dev and prod environments
- Loading branch information
Pavle Portic
committed
May 28, 2019
1 parent
5008ad4
commit b8c91e6
Showing
10 changed files
with
2,095 additions
and
2,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:lts-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
COPY . . | ||
|
||
EXPOSE 3000 | ||
CMD [ "npm", "run", "start:dev" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM nginx:alpine | ||
|
||
COPY ./docker/entrypoint-nginx.sh / | ||
|
||
RUN set -ex && \ | ||
apk add --no-cache bash && \ | ||
chmod +x /entrypoint-nginx.sh | ||
|
||
COPY ./docker/vhost.template /etc/nginx/conf.d/vhost.template | ||
|
||
CMD ["/entrypoint-nginx.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM node:lts-alpine as builder | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json /app/ | ||
RUN set -x && npm install | ||
COPY . /app | ||
COPY ormconfig.json /app/dist | ||
RUN set -x && npm run prestart:prod | ||
|
||
EXPOSE 3000 | ||
|
||
CMD [ "npm", "run", "start:prod" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
version: "3" | ||
services: | ||
nest: | ||
image: nest | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: on-failure | ||
volumes: | ||
- .env:/app/.env | ||
depends_on: | ||
- db | ||
|
||
nginx: | ||
image: nginx | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: on-failure | ||
depends_on: | ||
- nest | ||
environment: | ||
- NGINX_SERVER_NAME=_ | ||
- NEST_HOST=nest | ||
- NEST_PORT=3000 | ||
- NGINX_MAX_BODY=100M | ||
ports: | ||
- 127.0.0.1:80:80 | ||
|
||
db: | ||
image: mariadb:10 | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: on-failure | ||
environment: | ||
MYSQL_DATABASE: nest | ||
MYSQL_USER: nest | ||
MYSQL_PASSWORD: nest | ||
MYSQL_ROOT_PASSWORD: root | ||
volumes: | ||
- mariadbdata:/var/lib/mysql | ||
|
||
volumes: | ||
mariadbdata: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
version: "2" | ||
services: | ||
nest: | ||
build: . | ||
container_name: nest | ||
depends_on: | ||
- db | ||
volumes: | ||
- ./src:/app/src | ||
- .env:/app/.env | ||
- ./ormconfig.json:/app/ormconfig.json | ||
|
||
nginx: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile-nginx | ||
container_name: nest-nginx | ||
depends_on: | ||
- nest | ||
environment: | ||
- NGINX_SERVER_NAME=localhost | ||
- NEST_HOST=nest | ||
- NEST_PORT=3000 | ||
- NGINX_MAX_BODY=100M | ||
ports: | ||
- 80:80 | ||
|
||
db: | ||
image: mariadb:10 | ||
container_name: nest-db | ||
environment: | ||
MYSQL_DATABASE: nest | ||
MYSQL_USER: nest | ||
MYSQL_PASSWORD: nest | ||
MYSQL_ROOT_PASSWORD: root | ||
ports: | ||
- 3306:3306 | ||
volumes: | ||
- mariadbdata:/var/lib/mysql | ||
|
||
volumes: | ||
mariadbdata: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
vars=$(compgen -A variable) | ||
subst=$(printf '${%s} ' $vars) | ||
envsubst "$subst" < /etc/nginx/conf.d/vhost.template > /etc/nginx/conf.d/default.conf | ||
nginx -g 'daemon off;' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# vim: ft=nginx | ||
|
||
server { | ||
listen 80; | ||
server_name ${NGINX_SERVER_NAME}; | ||
root /app/public; | ||
client_max_body_size ${NGINX_MAX_BODY}; | ||
|
||
location / { | ||
# try_files $uri =404; | ||
proxy_pass http://${NEST_HOST}:${NEST_PORT}; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Host $server_name; | ||
proxy_set_header X-Forwarded-Proto https; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{ | ||
"type": "sqlite", | ||
"database": "./sqlite-example.sql", | ||
"entities": [ | ||
"src/**/**.entity{.ts,.js}" | ||
], | ||
"type": "mariadb", | ||
"host": "db", | ||
"port": 3306, | ||
"username": "nest", | ||
"password": "nest", | ||
"database": "nest", | ||
"entities": ["src/modules/**/*.entity{.ts,.js}"], | ||
"synchronize": true | ||
} | ||
} | ||
|
Oops, something went wrong.