Simple Build on Linux
Apache web server no Dockerfile, $(pwd) prints path to current folder
docker run -d --name apa -e TZ=UTC -p 8080:80 -v $(pwd)/html/:/var/www/html/ ubuntu/apache2
Development Build
docker build -t reactapp:1.0 .
docker run -p 3000:3000 \ --env REACT_APP_BASE_URL=localhost \ --name react-app reactapp:1.0
docker logs -f YOUR_CONTAINER_SHA
Prod build & push to registry
Create empty private image repo at DOCKER_HUB_USERNAME/REPO_NAMEThe repo should be visible in browser at https://hub.docker.com/repository/docker/DOCKER_HUB_USERNAME/REPO_NAME
For production you need to set env variable in Dockerfile-prod not in docker run. Here's how
RUN REACT_APP_BASE_URL=example.com yarn build
build, run and push to registry
docker run -d \ -p 80:80 \ --name react-app-prod DOCKER_HUB_USERNAME/REPO_NAME:1.0 docker build -t DOCKER_HUB_USERNAME/REPO_NAME:1.0 \ -f Dockerfile-prod . docker login docker push DOCKER_HUB_USERNAME/REPO_NAME:1.0DOCKER_HUB_USERNAME/REPO_NAME:1.0
No comments:
Post a Comment