Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
63 additions
and 0 deletions.
- +1 −0 .env-prod
- +29 −0 Dockerfile
- +25 −0 docker-compose.prod.yml
- +5 −0 process.yml
- +3 −0 run-prod.sh
@@ -0,0 +1 @@ | ||
# specific environtment variables for prod mode |
@@ -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"] |
@@ -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 |
@@ -0,0 +1,5 @@ | ||
apps: | ||
- script : './app.js' | ||
name : 'nodejs-hello-world' | ||
exec_mode: 'cluster' | ||
instances: 1 |
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
pm2-docker --raw process.yml |