Skip to content

Commit

Permalink
build(docker): Update Dockerfile with starter-kit performance improve…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
ryanoglesby08 committed Aug 24, 2017
1 parent 8782b2d commit 0dd841c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

node_modules/

designs/
dist/
# Temporary until we remove the old docs
docs/

icons/
styleguide/
21 changes: 10 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@
FROM node:6-alpine

# Set the working directory for following commands.
ENV HOME=/app
WORKDIR /app

# Add a user so that we don't run as root:
# https://github.com/telusdigital/reference-architecture/blob/master/delivery/docker.md#root-vs-user-mode
ENV UID=911 GID=0 HOME=/root
RUN adduser -D -u $UID -G root -h $HOME nodeuser
RUN set -ex && \
adduser node root && \
chmod g+w /app

# Copy only the files necessary to install dependencies into the working directory.
# Docker builds the image in layers and caches them. Because the app files change more often than the dependencies, we
# copy the app files only after we install the depencendies.
COPY package.json yarn.lock .npmrc ./
COPY .npmrc package.json yarn.lock ./

# Install dependencies.
RUN yarn install
RUN set -ex && \
yarn install --pure-lockfile && \
yarn cache clean

# Copy all source and test files into the working directory.
# We use a .dockerignore file to prevent unnecessary or large files from being inadvertently copied.
COPY . /app

# Build the app.
# Then give access to the app directory
RUN set -ex && \
yarn build && \
yarn cache clean && \
chmod -R g+rw /app $HOME && \
chmod g+x $HOME
RUN yarn run build

# Set the container's user to the newly created one.
USER nodeuser
USER node

# The entrypoint configures the container to be run as an executable.
# Arguments supplied on the command line will be forwarded onto the entrypoint.
Expand Down

0 comments on commit 0dd841c

Please sign in to comment.