diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..4e36010f3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +/Dockerfile +/node_modules +/run +*.log +/test diff --git a/Dockerfile b/Dockerfile index c02cdf86d..a1abc117a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,40 @@ -FROM node:8.2-alpine +FROM node:8.9-alpine AS build MAINTAINER Quintype Developers -EXPOSE 3000 +RUN apk update && \ + apk add git + +RUN mkdir /app +WORKDIR /app + +COPY package.json yarn.lock /app/ +RUN npm install -g yarn && \ + yarn install --cache-folder /app/yarn-cache + +ENV NODE_ENV production +COPY . /app +RUN git log -n1 --pretty="Commit Date: %aD%nBuild Date: `date --rfc-2822`%n%h %an%n%s%n" > public/round-table.txt && \ + yarn run compile && \ + rm -rf .node-modules && \ + yarn install --production --cache-folder /app/yarn-cache && \ + rm -rf /app/yarn-cache + +FROM node:8.9-alpine + +MAINTAINER Quintype Developers RUN apk update && \ - apk add htop git curl && \ + apk add curl tini && \ addgroup -S app && \ adduser -S -g app app -ADD . /app +ENV NODE_ENV production +COPY --from=build /app /app RUN chown -R app:app /app USER app WORKDIR /app -RUN git log -n1 --pretty="Commit Date: %aD%nBuild Date: `date --rfc-2822`%n%h %an%n%s%n" > public/round-table.txt && \ - npm install yarn && \ - ./node_modules/.bin/yarn - -ENV NODE_ENV production -RUN npm run compile - -ENTRYPOINT ["npm"] -CMD ["start"] +ENTRYPOINT ["/sbin/tini", "--"] +CMD ["node", "start.js"]