diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..227a11c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Use a specific version of Node.js +FROM node:16.13.1-alpine + +# Set the working directory in the container +WORKDIR /app + +# Copy package.json and package-lock.json to the working directory +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Build the React app +RUN npm run build + +# Expose port 3000 to the outside world +EXPOSE 3000 + +# Define the command to run your app +CMD ["npm", "start"] diff --git a/README.md b/README.md index 3eefa20..67eacd8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,27 @@ -Just an app to test react - docker - aws -cicd +Just an app to test react - docker - aws -cicd. +# From Windows Create a React app named - react-docker-aws-cicd +- Push to git hub repository - https://github.com/jeffbonson/react-docker-aws-cicd +# Create a Dockerfile in the root directory +- Build the docker image using the docker file - docker build -t jeffbonson85/react-docker-aws-cicd:latest . +- Check for jeffbonson85/react-docker-aws-cicd in the docker hub's Images page. +- Stop the react server +- Open Docker Desktop +- Run the image using the command - docker run -d -p 3000:3000 jeffbonson85/react-docker-aws-cicd:latest +- Run the command to see running containers - docker ps +- Check for an entry in containers +- open localhost:3000 in web browser +# Push to docker hub - hub.docker.com +- Tag the docker image using the command - docker tag jeffbonson85/react-docker-aws-cicd:latest jeffbonson85/react-docker-aws-cicd:latest +- Push to docker hub using the command - docker push jeffbonson85/react-docker-aws-cicd:latest +- Login to hub.docker.com and refresh the Repositories page to see the new repository named - jeffbonson85/react-docker-aws-cicd:latest. +# To use this in MacBook +- Install Docker Desktop / colima in mac OS +- docker login +- Go to hub.docker.com/repositories/react-docker-aws-cicd/tags and copy the command - docker pull jeffbonson85/react-docker-aws-cicd:latest +- run the command - docker run -d -p 3000:3000 jeffbonson85/react-app:latest +- open localhost:3000 in web browser +- yay! + # Getting Started with Create React App