deploy reactjs updated base on git repository on docker container

  deployment, docker, git, reactjs

Okey, there’s case
I want to deploy reactjs project to docker container base on repository. It’s successfull process deploy and the project run perfectly.

The problem is when I updated some code and build it on local, push to git repository and pull inside project reactjs container, the project not updated. How I can updated the project base folder build from repo git ???

Step to reproduce:

  1. project_to_deploy (example name of project) and has 2 branch (sandbox, refactor).
    sandbox (has folder build), and refactor doesn’t have folder build.
  2. I copied the repo from git to folder (example: /home/me/sources/project_to_deploy). I using
    branch refactor.
  3. On the project has a Dockerfile:
    # pull official base image
    FROM node
    # set working directory
    WORKDIR /var/www/app/
    # install app dependencies
    COPY package*.json ./
    RUN npm install
    # add app
    COPY . ./
    COPY .env ./
    EXPOSE 3000
    # start app
    CMD ["npm", "start"]
  1. And I create container with docker-compose
    version: "3.4"

                context: ./home/me/sources/project_to_deploy/
            container_name: my-react
            restart: always
                - "9014:3000"
                - "REACT_APP_NODE_ENV=production"
                - "REACT_APP_CHEC_PUBLIC_KEY=pk_26191a345ba9f0daa931b71d0162c719484b59cec2747"
  1. and I go to inside container and then git pull and checkout branch (refactor to sandbox). And everything what i change on local, I build and push to branch sandbox.

Thanks, for your help…

Source: Docker Questions