Home>

I'm new to docker.

There is a standard build with create-react-app.

I would like to ask how to make the build restart when the container code is updated?

For example, inApp.jsxi change the code from

<h1>hello world</h1>

on

<h1>hello world zuzu</h1>

I would like the code to be updated inlocalhost

docker-compose.yml

version: "3"
services:
  frontend:
    build: ./dashboard
    container_name: front end
    command: npm run start
    restart: unless-stopped
    stdin_open: true
    tty:true
    ports:
      -"3000:3000"
    environment:
      -PORT=3000

Dockerfile

FROM node:13.12.0-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm i
COPY. .
cmd ["npm", "start"]

Launching throughdocker-compose up --build

Tried to launch viadocker-compose up --build --no-cache

Also tried adding these settings

stdin_open: true
tty:true

to filedocker-compose.yml, did not help

  • Answer # 1

    CI\CD will help you with this. The process could be like this:

    1. You commit changes to your project repository
    2. Next, the CI /CD process is launched, which provides the build and deployment of the project

    Look away or Gitlab CI/CD