Skip to content

Instantly share code, notes, and snippets.

@armand1m
Last active July 6, 2019 17:41
Show Gist options
  • Save armand1m/b96d8e7f82cec7be6371ed8e28153e77 to your computer and use it in GitHub Desktop.
Save armand1m/b96d8e7f82cec7be6371ed8e28153e77 to your computer and use it in GitHub Desktop.
Dockerfile for serving static assets from a CRA-generated application build
# Stage 1 - prepare application dependencies and bundle it
FROM node:dubnium as build-assets
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci
COPY . ./
RUN npm run build
# Stage 2 - serve only build assets through a static server
FROM node:dubnium
RUN npm i --global serve
COPY --from=build-assets /usr/src/app/build /usr/src/app/build
EXPOSE 5000
CMD ["serve", "-s", "/usr/src/app/build"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment