Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dockerfile Client (React)
FROM node:lts-alpine
# A directory inside the docker container
WORKDIR /usr/src/app
# Copies everything over to Docker environment
COPY ./client .
# Installs all node packages
RUN npm install
# Install serve globally
RUN npm i -g serve
# Just a peek inside the working directory
RUN ls -al
# build the app
RUN npm run build
# Alternative http server option
COPY ./client/nodeServer.ts build/nodeServer.js
# Uses port which is used by the actual application
# Finally runs the application
CMD [ "npm", "run", "serve" ]
# If you are using nodeServer.js uncomment the next 2 lines
# WORKDIR /usr/src/app/build
# CMD ["node", "prod"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment