Skip to content

Commit a710fda

Browse files
committed
prod mode setup
1 parent 7876be5 commit a710fda

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

.env-prod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# specific environtment variables for prod mode

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM node:8.1.3-alpine
2+
3+
LABEL authors="hoatle <hoatle@teracy.com>"
4+
5+
RUN mkdir -p /opt/app
6+
7+
ENV TERM=xterm APP=/opt/app
8+
9+
# add more arguments from CI to the image so that `$ env` should reveal more info
10+
ARG CI_BUILD_ID
11+
ARG CI_BUILD_REF
12+
ARG CI_REGISTRY_IMAGE
13+
ARG CI_BUILD_TIME
14+
ARG NODE_ENV
15+
16+
ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \
17+
CI_BUILD_TIME=$CI_BUILD_TIME NODE_ENV=$NODE_ENV
18+
19+
WORKDIR $APP
20+
21+
ADD package.json yarn.lock $APP/
22+
23+
RUN yarn install && \
24+
yarn global add pm2 && \
25+
yarn cache clean
26+
27+
ADD . $APP
28+
29+
CMD ["sh", "run-prod.sh"]

docker-compose.prod.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3'
2+
3+
services:
4+
5+
prod:
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
args:
10+
CI_BUILD_ID: ${CI_BUILD_ID}
11+
CI_BUILD_REF: ${CI_BUILD_REF}
12+
CI_BUILD_TIME: ${CI_BUILD_TIME}
13+
CI_REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE}
14+
NODE_ENV: production
15+
image: ${DOCKER_IMAGE_PROD:-acme101/nodejs-hello-world:develop}
16+
environment:
17+
PORT: 8080
18+
VIRTUAL_HOST: nodejs.teracy.dev, ~^nodejs\..*\.xip\.io
19+
HTTPS_METHOD: noredirect # support both http and https
20+
env_file:
21+
- .env-common
22+
- .env-prod
23+
ports:
24+
- "8080"
25+
network_mode: bridge

process.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apps:
2+
- script : './app.js'
3+
name : 'nodejs-hello-world'
4+
exec_mode: 'cluster'
5+
instances: 1

run-prod.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
pm2-docker --raw process.yml

0 commit comments

Comments
 (0)