/FrontToBack

React front-end Node backend Develop in Docker:

Primary LanguageJavaScript

Front To Back

mkdir newproject
cd newproject
npx create-react-app client --use-npm
npx express-generator --view=ejs --git server
sudo rm -r /client.git
git init
git add .
git add remote
git push

If you have the Docker Plugin for VSCode, F1 will automate most of the dockerfiles for you..

before deleting the Dockerfile from the root of the project, copy it to each of the client and server directories. Then Edit the docker-copmpose.yml to launch both containers in the default network at the same time on different ports.

client/Dockerfile

FROM node:10.13-alpine
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production  && mv node_modules ../
COPY . .
EXPOSE 3000
CMD npm start

server/Dockerfile

FROM node:10.13-alpine
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production && mv node_modules ../
COPY . .
EXPOSE 3000
CMD npm start

docker-copmpose.yml

version: '2.4'

services:
  client:
    image: client
    build: ./client
    environment:
      NODE_ENV: production
    ports:
      - 3000:3000
    stdin_open: true
    tty: true

  server:
    image: server
    build: ./server
    environment:
      NODE_ENV: production
    ports:
      - 3001:3000