We are going to be auto-generating a "dummy" application to represent what we want to host. For this use-case, we will be using create-react-app
. This is not required, as is simply just a simple use-case for generating a dummy application with unit tests. Feel free to use something like Java, Ruby, etc. If that is your language of choice.
In your Terminal, execute the following commands.
$ npx create-react-app my-sample-application
It's good practice to separate development and production Docker. This will allow you to easily iterate locally within a Docker-based environment. When you want to go prod, the pipeline will reference the production-based Dockerfile.
Dockerfile.development
FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
docker-compose-dev.yml
version: '3'
services:
web:
stdin_open: true
build:
context: .
dockerfile: Dockerfile.development
ports:
- '3000:3000'
volumes:
- /app/node_modules
- .:/app
Now, whenever we want to run our development environment, we can simply execute the following:
docker-compose -f docker-compose-dev.yml up