Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

479
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda