diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..e6dcaeb6cf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# base image +FROM node:9.5 + +EXPOSE 3000 + +# set working directory +WORKDIR /home/node/app + +# add `/home/node/app/node_modules/.bin` to $PATH +ENV PATH /home/node/app/node_modules/.bin:$PATH + +# install and cache app dependencies +COPY package.json ./package.json +RUN npm install react-scripts@1.1.1 -g --silent \ + && npm install --silent \ + && npm cache clean --force + +# Copy project source files +COPY . . + +# start app +CMD ["npm", "start"] \ No newline at end of file diff --git a/README.md b/README.md index 8a36e36b2c..5a48e78773 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,31 @@ The `jenkins` directory contains an example of the `Jenkinsfile` (i.e. Pipeline) you'll be creating yourself during the tutorial and the `scripts` subdirectory contains shell scripts with commands that are executed when Jenkins processes the "Test" and "Deliver" stages of your Pipeline. + +## Using the Registry + +Manually: + +```bash +docker image build -t localhost:5000/simple-react-app . +``` + +Push: + +```bash +docker push localhost:5000/simple-react-app +``` + +Remove local image: + +```bash +docker image rm localhost:5000/simple-react-app +``` + +Pull: + +```bash +docker pull localhost:5000/simple-react-app +``` + +## TODO - Set up Jenkins to build and push images into registry \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000000..33082e5e14 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,14 @@ +version: "3.1" + +services: + client: + build: + context: . + dockerfile: Dockerfile + volumes: + - '.:/home/node/app' + - '/home/node/app/node_modules' + ports: + - '3000:3000' + environment: + - NODE_ENV=development \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000000..8dee9d9e12 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,8 @@ +version: "3.1" + +services: + client: + ports: + - '3050:3000' + environment: + - NODE_ENV=production \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..ceb334ad2a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3.1" + +services: + client: + image: localhost:5000/simple-react-app + + \ No newline at end of file