xxxxxxxxxx
# It uses node:18-alpine as the base image for the Node.js application
FROM node:18-alpine
# It installs the nodemon package globally for monitoring and watching the backend Express server
RUN npm install -g nodemon
# Creating the working directory named `app`
WORKDIR /app
# Copying all the tools and dependencies in the package.json file to the working directory `app`
COPY package.json .
#Installing all the tools and dependencies in the container
RUN npm install
#Copying all the application source code and files to the working directory `app`
COPY . .
#Exposing the container to run on this port 4000
EXPOSE 4000
#Command to start the Docker container for the backed server application
CMD ["npm", "run", "dev"]
xxxxxxxxxx
version: '3.3'
services:
myApp:
image: myapp:1.0
container_name: my-app
build: .
ports:
- 80:8080
xxxxxxxxxx
version: '3'
services:
backend:
env_file:
"./backend/backend.env"
build:
context: ./backend
dockerfile: ./Dockerfile
image: "dmurphy1217/twitter-sentiment-backend"
ports:
- "5000:5000"
frontend:
build:
context: ./client
dockerfile: ./Dockerfile
image: "dmurphy1217/twitter-sentiment-frontend"
ports:
- "3000:3000"
links:
- "backend:be"
xxxxxxxxxx
react
# It uses node:18-alpine as the base image for the frontend React.js application
FROM node:18-alpine
# Creating the working directory named `app`
WORKDIR /app
# Copying all the tools and dependencies in the package.json file to the working directory `app`
COPY package.json .
#Installing all the tools and dependencies in the container
RUN npm install
#Copying all the application source code and files to the working directory `app`
COPY . .
#Exposing the container to run on this port 3000
EXPOSE 3000
#Command to start the Docker container for the frontend React.js application
CMD ["npm", "start"]
xxxxxxxxxx
node
# It uses node:18-alpine as the base image for the Node.js application
FROM node:18-alpine
# It installs the nodemon package globally for monitoring and watching the backend Express server
RUN npm install -g nodemon
# Creating the working directory named `app`
WORKDIR /app
# Copying all the tools and dependencies in the package.json file to the working directory `app`
COPY package.json .
#Installing all the tools and dependencies in the container
RUN npm install
#Copying all the application source code and files to the working directory `app`
COPY . .
#Exposing the container to run on this port 4000
EXPOSE 4000
#Command to start the Docker container for the backed server application
CMD ["npm", "run", "dev"]
xxxxxxxxxx
# Version of Docker-compose for node
version: '3.9'
services:
# Add the node-js service
node:
# Location to the node.js dockerfile
build:
context: ./node
# Name of the dockerfile
dockerfile: Dockerfile
container_name: node-container
ports:
# Host port:Container port
- '4000:4000'
volumes:
# Bind-mounts configuration
- ./node:/app
# Ignoring any changes made in the "node_modules" folder
- ./app/node_modules
xxxxxxxxxx
# Version of Docker-compose for react and node
version: '3.9'
services:
# Add the node-js service
node:
# Location to the node.js dockerfile
build:
context: ./node
# Name of the dockerfile
dockerfile: Dockerfile
container_name: node-container
ports:
# Host port:Container port
- '4000:4000'
volumes:
# Bind-mounts configuration
- ./node:/app
# Ignoring any changes made in the "node_modules" folder
- ./app/node_modules
react:
# Location to the react.js dockerfile
build:
context: ./react
# Name of the dockerfile
dockerfile: Dockerfile
container_name: react-container
ports:
# Host port:Container port
- '3000:3000'
stdin_open: true