Skip to content

Commit

Permalink
Splitting into multistage
Browse files Browse the repository at this point in the history
  • Loading branch information
gja committed Nov 13, 2017
1 parent ce54780 commit 53b9e74
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/Dockerfile
/node_modules
/run
*.log
/test
40 changes: 27 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
FROM node:8.2-alpine
FROM node:8.9-alpine AS build

MAINTAINER Quintype Developers <[email protected]>

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 <[email protected]>

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"]

0 comments on commit 53b9e74

Please sign in to comment.