Skip to content

Instantly share code, notes, and snippets.

@yveshema
Last active January 10, 2020 21:13
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 yveshema/d8525b4275745568b6251bb60c5a835e to your computer and use it in GitHub Desktop.
Save yveshema/d8525b4275745568b6251bb60c5a835e to your computer and use it in GitHub Desktop.
A simple docker setup for a React application
docker-compose run my_app npx create-react-app my_app
version: '3'
services:
app:
build: .
volumes:
- ./myapp:/home/node
ports:
- "3000:3000"
restart: always
container_name: my_app
#!/bin/sh
set -e
if [ -d /home/node/myapp ]; then
echo >&2 "Now building ..."
cd /home/node/myapp
npm install && npm run build
echo >&2 "Done! You can now deploy your application"
npm start
fi
exec "$@"
FROM node:10.16-alpine
USER node
WORKDIR /home/node
COPY ./myapp /home/node/
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment