From 051c8ffa21a4d042df7f33595ad2a1b43ceed523 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes de Oliveira <lfo14@inf.ufpr.br> Date: Mon, 11 Dec 2017 11:26:15 -0200 Subject: [PATCH] Add Dockerfile and .dockerignore Signed-off-by: Lucas Fernandes de Oliveira <lfo14@inf.ufpr.br> --- .dockerignore | 12 ++++++++++++ Dockerfile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..77b9ea6b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +/artwork +/config +/coverage +/database +/doc +/node_modules +nodemon.json +/service +/.git + +*.swp +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..df24ec04 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +# Avoid the use of floating tags like: latest, boron, argon and carbon +ARG VERSION=6.12.2 +FROM node:$VERSION + +LABEL autor="C3SL - Centro de Computação Científica e Software Livre" + + +# Node was not designed to run as PID 1 (process in docker run with PID 1). +# Its recommended to use the flag --init or use tine to start node process +# in docker + +# Add Tini +ENV TINI_VERSION="v0.16.1" WORKSPACE="/home/node/app/" +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) + +COPY package*.json $WORKSPACE +RUN \ + chmod +x /tini &&\ + chown -R node:node $WORKSPACE + +USER node +WORKDIR $WORKSPACE + +RUN npm install + +# Bundle app source +# COPY copy files as root so chown must be used +USER root +COPY . . +RUN find . -user root | xargs chown node:node +USER node + +VOLUME ["/home/node/app/config"] + +EXPOSE 3000 + +HEALTHCHECK CMD curl -f http://localhost:3000/v1/metrics || exit 1 + +# Instead of using npm start to start the container, directly put the command +# that npm start executes. +# First off this reduces the number of processes running inside of your container +# Secondly it causes exit signals such as SIGTERM and SIGINT to be received by +# the Node.js process instead of npm swallowing them. + + +ENTRYPOINT ["/tini", "--"] +CMD ["node", "index" ] -- GitLab