我有我在 /etc/nginx/sites-available/ 位置復制的默認 nginx 檔案,當我對默認檔案進行某些更改時,更改沒有反映在 pod 下的該檔案中。
我已經提到復制 /etc/nginx/sites-available/ 下的默認檔案的復制命令,想知道這個默認檔案是否由 nginx 自動生成,因此無法反映我的更改。有沒有辦法更改默認檔案?
我嘗試直接更改 pod 內的默認檔案,但是一旦 pod 重新啟動,更改就會丟失。
默認檔案
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
#Sample testing to the file
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:8000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
檔案
FROM node:12.10.0
ENV APP_ROOT /usr/src/webapp/
ENV DOC_ROOT /var/www/html/
ENV DEV_ENV development
ENV DEV_BASE_HREF https://app.com/app-development/
RUN mkdir -p $APP_ROOT $DOC_ROOT
RUN chmod 777 $DOC_ROOT
COPY . $APP_ROOT
RUN chmod 777 init.sh
RUN apt-get update \
&& apt-get install nginx -y
RUN npm cache clean --force \
&& npm rebuild node-sass \
&& npm install -g @angular/[email protected] --unsafe
RUN rm -rf /etc/nginx/sites-available/default
COPY default /etc/nginx/sites-available/default
RUN ls /etc/nginx/sites-available && cat /etc/nginx/sites-available/default
RUN npm cache clear --force && npm install --no-shrinkwrap --update-binary
RUN node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --env=prod -extract-css false --base-href $DEV_BASE_HREF --output-path=./dist
EXPOSE 80
ENTRYPOINT ["/bin/bash", "init.sh"]
CMD ["dev"]
uj5u.com熱心網友回復:
不確定為什么在單個 Dockerfile 中同時使用 Nginx 和 Node
理想情況下,您應該在容器內運行單個行程。
COPY ./nginx/default.conf /etc/nginx/nginx.conf
您可以像上面一樣覆寫 Dockerfile 中的檔案。
COPY default /etc/nginx/sites-available/default
確保您的檔案被洗掉,否則您可以運行洗掉命令
RUN ls /etc/nginx/sites-available && cat /etc/nginx/sites-available/default
驗證您的檔案實際上已放入docker
RUN npm cache clean --force \
&& npm rebuild node-sass \
&& npm install -g @angular/[email protected] --unsafe
RUN rm /etc/nginx/sites-available/default
COPY default /etc/nginx/sites-available/
RUN ls /etc/nginx/sites-available && cat /etc/nginx/sites-available/default
RUN npm cache clear --force && npm install --no-shrinkwrap --update-binary
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/372001.html
標籤:码头工人 nginx Kubernetes
下一篇:用容器的內容覆寫卷內容
