Skip to content

Commit

Permalink
feat(docker): build from local source
Browse files Browse the repository at this point in the history
  • Loading branch information
jlegrone committed Mar 14, 2019
1 parent 7cb3b40 commit 2cbc619
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
build
45 changes: 30 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
FROM node:6.10
ARG BUILDER_IMAGE=node:8.10
ARG RUNTIME_IMAGE=node:8.10-alpine

# Install Spoke
ARG SPOKE_VERSION=1.4.1
ENV OUTPUT_DIR=/Spoke/build \
SPOKE_VERSION=$SPOKE_VERSION \
SUDO_USER=root
RUN wget https://github.com/MoveOnOrg/Spoke/archive/v$SPOKE_VERSION.tar.gz && \
tar zxf v$SPOKE_VERSION.tar.gz && \
rm v$SPOKE_VERSION.tar.gz && \
mv /Spoke-$SPOKE_VERSION /Spoke && \
cd /Spoke && \
npm install && \
npm install -g foreman
FROM ${BUILDER_IMAGE} as builder

ENV NODE_ENV=production \
OUTPUT_DIR=./build \
PUBLIC_DIR=./build/client \
ASSETS_DIR=./build/client/assets \
ASSETS_MAP_FILE=assets.json

COPY . /spoke
WORKDIR /spoke
RUN yarn install --ignore-scripts && \
yarn run prod-build && \
rm -rf node_modules && \
yarn install --production --ignore-scripts

# Spoke Runtime
WORKDIR /Spoke
FROM ${RUNTIME_IMAGE}
WORKDIR /spoke
COPY --from=builder /spoke/build build
COPY --from=builder /spoke/node_modules node_modules
COPY --from=builder /spoke/package.json /spoke/yarn.lock ./
ENV NODE_ENV=production \
PORT=3000 \
ASSETS_DIR=./build/client/assets \
ASSETS_MAP_FILE=assets.json \
JOBS_SAME_PROCESS=1

# Switch to non-root user https://github.com/nodejs/docker-node/blob/d4d52ac41b1f922242d3053665b00336a50a50b3/docs/BestPractices.md#non-root-user
USER node
EXPOSE 3000
CMD ["nf", "start", "--procfile", "./dev-tools/Procfile.dev"]
CMD ["npm", "start"]

0 comments on commit 2cbc619

Please sign in to comment.