Skip to content

Instantly share code, notes, and snippets.

@pak11273
Last active January 24, 2021 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pak11273/77b3b85f4ce570da08ab43d2843c483d to your computer and use it in GitHub Desktop.
Save pak11273/77b3b85f4ce570da08ab43d2843c483d to your computer and use it in GitHub Desktop.
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
EXPOSE 3000
# 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