Last active
January 10, 2020 21:13
-
-
Save yveshema/d8525b4275745568b6251bb60c5a835e to your computer and use it in GitHub Desktop.
A simple docker setup for a React application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose run my_app npx create-react-app my_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
app: | |
build: . | |
volumes: | |
- ./myapp:/home/node | |
ports: | |
- "3000:3000" | |
restart: always | |
container_name: my_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:10.16-alpine | |
USER node | |
WORKDIR /home/node | |
COPY ./myapp /home/node/ | |
COPY docker-entrypoint.sh /entrypoint.sh | |
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose up -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment