Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
prod mode setup
  • Loading branch information
hoatle committed Jul 7, 2017
1 parent 7876be5 commit a710fda
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env-prod
@@ -0,0 +1 @@
# specific environtment variables for prod mode
29 changes: 29 additions & 0 deletions Dockerfile
@@ -0,0 +1,29 @@
FROM node:8.1.3-alpine

LABEL authors="hoatle <hoatle@teracy.com>"

RUN mkdir -p /opt/app

ENV TERM=xterm APP=/opt/app

# add more arguments from CI to the image so that `$ env` should reveal more info
ARG CI_BUILD_ID
ARG CI_BUILD_REF
ARG CI_REGISTRY_IMAGE
ARG CI_BUILD_TIME
ARG NODE_ENV

ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \
CI_BUILD_TIME=$CI_BUILD_TIME NODE_ENV=$NODE_ENV

WORKDIR $APP

ADD package.json yarn.lock $APP/

RUN yarn install && \
yarn global add pm2 && \
yarn cache clean

ADD . $APP

CMD ["sh", "run-prod.sh"]
25 changes: 25 additions & 0 deletions docker-compose.prod.yml
@@ -0,0 +1,25 @@
version: '3'

services:

prod:
build:
context: .
dockerfile: Dockerfile
args:
CI_BUILD_ID: ${CI_BUILD_ID}
CI_BUILD_REF: ${CI_BUILD_REF}
CI_BUILD_TIME: ${CI_BUILD_TIME}
CI_REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE}
NODE_ENV: production
image: ${DOCKER_IMAGE_PROD:-acme101/nodejs-hello-world:develop}
environment:
PORT: 8080
VIRTUAL_HOST: nodejs.teracy.dev, ~^nodejs\..*\.xip\.io
HTTPS_METHOD: noredirect # support both http and https
env_file:
- .env-common
- .env-prod
ports:
- "8080"
network_mode: bridge
5 changes: 5 additions & 0 deletions process.yml
@@ -0,0 +1,5 @@
apps:
- script : './app.js'
name : 'nodejs-hello-world'
exec_mode: 'cluster'
instances: 1
3 changes: 3 additions & 0 deletions run-prod.sh
@@ -0,0 +1,3 @@
#!/bin/bash

pm2-docker --raw process.yml

0 comments on commit a710fda

Please sign in to comment.