bradtraversy / proshop_mern

Shopping cart built with MERN & Redux
1.99k stars 1.18k forks source link

Docker Compose file for the App #192

Closed henri-edward closed 1 year ago

xosteve26 commented 2 years ago

@henri-edward

Docker Compose

This is the compose file that I used

Compose File

 services:
  server:
    build: ./
    ports:
      - '5000:5000'

    container_name: mern-e-commerce_server

    env_file:
      - .env

  client:
    build: ./frontend
    ports:
      - '3000:3000'

    container_name: mern-e-commerce_client

I have 2 docker files present, 1 in the root directory of the project ./ and the other one in the ./frontend directory

Dockerfile [Backend ./]

# DOCKERFILE FOR THE BACKEND
FROM node:14.16.0
WORKDIR /usr/src/app/server
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 5000
CMD ["npm", "run","start"]

Dockefile [Frontend ./frontend]

# DOCKERFILE FOR THE FRONTEND
FROM node:14.16.0

WORKDIR /usr/src/app/client
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm","run", "start"]

Check out my repo for better clarity on my directory tree

No description provided.