Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

482
Views
Docker Compose with React and Nginx

I'm trying to use docker-compose for deployment of my React app, which uses an express backend and Postgres Database. My idea is to have shared volumes from my docker-compose. Then build from my Dockerfile into the volume, so that Nginx will be able to serve the files. The problem now is that it works when i build the project the first time, but if I change something in my React Client and run "docker-compose up --build" it looks like everything is building as it should, but the files served are still the same. Is COPY command in my dockerfile not overwriting the old files?

Dockerfile in my React Client Project

FROM node:13.12.0-alpine as build
WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
RUN npm install
COPY . ./
RUN npm run build
FROM node:13.12.0-alpine
COPY --from=build /app/build /var/lib/frontend

docker-compose

version: "3.7"
services:
 callstat_backend:
  build: ./callstat-backend
  restart: always
  ports:
    - "3000:3000"
  env_file:
   - keys.env
  depends_on:
  - postgres
 callstat_frontend:
  build: ./callstat-client
  volumes:
   - frontend/:/var/lib/frontend
 postgres:
  image: postgres:11.2-alpine
  ports:
   - "5432:5432"
  volumes:
   - pgdata:/var/lib/postgresql/data
  environment:
   POSTGRES_USER: postgres
   POSTGRES_PASSWORD: postgres
   POSTGRES_DB: callstat
 nginx:
  image: nginx
  volumes:
   - frontend:/usr/share/nginx/html
   - ./nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "80:80"
  depends_on:
   - callstat_frontend
volumes:
 pgdata:
 frontend:

Maybe i'm taking a totaly wrong approach here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can run the commands in the following order:

# stop down the services
docker-compose stop

# remove the previously created docker resources
docker-compose rm

# bring up the services again
docker-compose up --build

This was your previous volume be removed and new one will be created with the updated changes.

NOTE: This is okay from the development perspective, but docker volumes are really expected to persist between deployments. For artifacts like code changes ideally images should be published as part of build process. To get little more insight into this topic you can refer to https://github.com/docker/compose/issues/2127

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!