TEST :
npm run test
Dockerfile
:Dockerfile.dev
- use
docker-compose.yml
- entrypoint command :
npm run start
- use react
development-server
- use docker
volumes
option to mapping : - url : http://localhost:3000/
Manually using docker-cli
to build the docker image.
docker build -f Dockerfile.dev .
Using docker-compose
to Create Container With Build Option
docker-compose up
If there is a changes to Dockerfile.dev
or new sevices added to docker-composer.yml
file.
docker-compose up --build
List the services :
docker ps -a
Then get the container id of the web-app. Then run script below. Replace [CONTAINER-ID]
with the actual container id value.
docker exec -it [CONTAINER-ID] npm run test
run the test with coverage
, and immediate exit with 0
, after finished. To avoid the watch
mode, never ending process.
docker run harryosmar/react-docker npm run test -- --coverage
Dockerfile
:Dockerfile
- do not use
docker-compose.yml
- entrypoint command :
npm run build
- use
nginx
server - only container
public/
folder - Has 2 phases :
- url : http://localhost:8080/
docker build .
docker run -p 8080:80 [CONTAINER-ID]