docker - How to have dockerized nginx pick up file change from other container -
how can configure nginx , client app (ember) pick file changes?
edit:
i'm thinking share volume, need specify volumes have same path within docker-compose file.
i have mounted shared volumes (maybe?) between nginx , frontend application changes made in frontend application not picked in nginx unless rebuild docker containers. i've read lot of questions , solutions boil down a. share volumes (i've done) b. set serve file off in nginx (it is):
docker-compose.yml
version: "3" services: client: build: "./client" command: npm start env_file: - .env-dev ports: - "4200:4200" - "35730:35730" volumes: - /var/www/app/client - /var/www/app/client/node_modules - .:/client nginx: build: ./nginx env_file: .env-dev volumes: - /var/www/app/nginx depends_on: - client networks: - clientnet ports: - "80:80" networks: clientnet: driver: bridge
nginx.conf
events { worker_connections 1024; } http { log_format compression '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$gzip_ratio"'; gzip on; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 500; gzip_disable "msie [1-6]\."; gzip_types text/plain text/xml text/css text/comma-separated-values text/javascript application/x-javascript application/atom+xml; upstream client_app { server client:4200; } server { sendfile off; listen 80; root /var/www/app/client/public; # match frontend client location =/ { proxy_pass http://client_app; } # match assets location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2|woff|ttf)$ {} } }
what missing?
named volumes can considered on local development. when in production when using swarm, it's better use multi-staging builds inserting front-end static folder in nginx. because using volumes anti-pattern updates (your changes in front-end not reflect when docker pull
).
i suggest use bind mounts when doing coding in local real-time changes between files in host , container like:
nginx: restart: image: nginx:alpine volumes: - ./nginx/conf.d:/etc/nginx/conf.d - ./django/static:/usr/src/app/static - ./django/media:/usr/src/app/media
Comments
Post a Comment