简体   繁体   中英

Docker / docker-compose workflow: angular changes not being reflected

When I make changes to my app source code and rebuild my docker images, the changes are not being reflected in the updated containers. I have:

  • Checked that the changes are being pulled to the remote machine correctly
  • Cleared the browser cache and double checked with different browsers
  • Checked that the development build files are not being pulled onto the remote machine by mistake
  • Banged my head against a number of nearby walls

Every time I pull new code from the repo or make a local change, I do the following in order to do a fresh rebuild:

sudo docker ps -a 
sudo docker rm <container-id>
sudo docker image prune -a
sudo docker-compose build --no-cache
sudo docker-compose up -d

But despite all that, the changes do not make it through - I simply dont know how it isn't working as the output during build appears to be taking the local files. Where can it be getting the old files from, cos I've checked and double checked that the local source has changed? Docker-compose:

version: '3'
services:

  angular:
    build: angular
    depends_on:
      - nodejs
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - certbot-etc:/etc/letsencrypt
      - certbot-var:/var/lib/letsencrypt
      - web-root:/usr/share/nginx/html
      - ./dhparam:/etc/ssl/certs
      - ./nginx-conf/prod:/etc/nginx/conf.d
    networks:
      - app-net

  nodejs:
    build: nodejs
    ports:
      - "8080:8080"

volumes:
  certbot-etc:
  certbot-var:
  web-root:

Angular dockerfile:

FROM node:14.2.0-alpine AS build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH

# install and cache app dependencies
COPY package.json /app/
RUN apk update && apk add --no-cache bash git 
RUN npm install
COPY . /app
RUN ng build --outputPath=./dist --configuration=production

### prod ###

FROM nginx:1.17.10-alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]

I found it. I followed tutorial to get https to work, and thats where the named volumes came in. Its a two step process, and it needed all those named volumes for the first step, but the web-root volume is what was screwing things up; deleting that solved my problem. At least I understand docker volumes better now...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM