Spaces:
Running
Running
Nicky Nicolson
commited on
Commit
·
404c8c2
1
Parent(s):
9e9dd52
mod mgmt nginx
Browse files- Dockerfile +28 -2
- _env_config/stg_dev/utl_dkr_preRun.sh +41 -0
- nginx/etc.nginx.confd_default.conf +94 -0
- nginx/etc.nginx.sites-available.default +91 -0
- nginx/etc.nginx_nginx.conf +24 -0
Dockerfile
CHANGED
@@ -8,6 +8,32 @@ RUN bundle exec jekyll build
|
|
8 |
|
9 |
#Copy _sites from build to Nginx Container to serve site
|
10 |
FROM nginx:latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
COPY --from=builder /usr/src/app/_site /usr/share/nginx/html
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
#Copy _sites from build to Nginx Container to serve site
|
10 |
FROM nginx:latest
|
11 |
+
|
12 |
+
RUN mkdir -p /var/cache/nginx \
|
13 |
+
/var/log/nginx \
|
14 |
+
/var/lib/nginx \
|
15 |
+
/usr/share/nginx/html
|
16 |
+
|
17 |
+
RUN touch /var/run/nginx.pid
|
18 |
+
|
19 |
+
RUN groupadd user
|
20 |
+
RUN useradd -d /home/user -ms /bin/bash -g user -G user -p user user
|
21 |
+
RUN chown -R user:user /var/cache/nginx \
|
22 |
+
/var/log/nginx \
|
23 |
+
/var/lib/nginx \
|
24 |
+
/var/run/nginx.pid \
|
25 |
+
/usr/share/nginx/html
|
26 |
+
|
27 |
+
#--- update nginx config; establish routes/proxy pass; remove user directive
|
28 |
+
COPY ./nginx/etc.nginx.confd_default.conf /etc/nginx/conf.d/default.conf
|
29 |
+
COPY ./nginx/etc.nginx_nginx.conf /etc/nginx/nginx.conf
|
30 |
+
|
31 |
+
|
32 |
COPY --from=builder /usr/src/app/_site /usr/share/nginx/html
|
33 |
+
|
34 |
+
COPY --chown=user ./_env_config/stg_dev/utl_dkr_preRun.sh ./scripts/docker/
|
35 |
+
|
36 |
+
EXPOSE 7860
|
37 |
+
ENTRYPOINT [ "./scripts/docker/utl_dkr_preRun.sh" ]
|
38 |
+
|
39 |
+
# CMD ["nginx", "-g", "daemon off;"]
|
_env_config/stg_dev/utl_dkr_preRun.sh
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
#--- Note: this file is designed to run locally as well as within docker to prep the environment
|
4 |
+
#--- Entry: this script is assumed to run from the /app root folder
|
5 |
+
#--- Usage: ./_env_config/local_dev/utl_dkr_preRun.sh
|
6 |
+
|
7 |
+
#--- for volume initialization; ensure folders are in place; assume: we are in the /app folder
|
8 |
+
|
9 |
+
|
10 |
+
<<blockComment
|
11 |
+
-
|
12 |
+
blockComment
|
13 |
+
echo -e "INFO(utl_dkr_preRun):\t Initializing ..."
|
14 |
+
|
15 |
+
# strpth_pwd=$(pwd)
|
16 |
+
# strpth_scriptLoc=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
17 |
+
# strpth_scrHome="${strpth_scriptLoc}/../"
|
18 |
+
# strpth_appHome="${strpth_scrHome}../"
|
19 |
+
# strpth_scrModels="${strpth_scrHome}models/"
|
20 |
+
|
21 |
+
# #echo "strpth_appHome = ${strpth_appHome}"
|
22 |
+
|
23 |
+
#--- for nginx; external 7860; internal 7860
|
24 |
+
echo "INFO: starting nginx ..."
|
25 |
+
# service nginx start
|
26 |
+
exec nginx -g "daemon off;"
|
27 |
+
|
28 |
+
|
29 |
+
# #--- for fastapi; external 49132; internal 39132
|
30 |
+
# echo "INFO: starting fastapi ..."
|
31 |
+
# uvicorn --app-dir=./fastapi entry_fastapi:app --reload --workers 1 --host 0.0.0.0 --port 39132 & #--- specify a non-root app dir
|
32 |
+
|
33 |
+
|
34 |
+
# #--- for streamlit; external 49131; internal 39131
|
35 |
+
# echo "INFO: starting streamlit ..."
|
36 |
+
# streamlit run ./streamlit/entry_streamlit.py --server.port=39131 --server.maxUploadSize=2000 #--- & run in the background
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
<<blockErrorLog
|
41 |
+
blockErrorLog
|
nginx/etc.nginx.confd_default.conf
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
server {
|
2 |
+
#listen 80;
|
3 |
+
listen 7860;
|
4 |
+
server_name localhost;
|
5 |
+
|
6 |
+
#access_log /var/log/nginx/host.access.log main;
|
7 |
+
|
8 |
+
#--- Note: we have a basic web server with entry points and routes
|
9 |
+
|
10 |
+
|
11 |
+
# #--- streamlit
|
12 |
+
# location / {
|
13 |
+
# proxy_pass http://127.0.0.1:39131/; #--- default streamlit landing page
|
14 |
+
# proxy_http_version 1.1;
|
15 |
+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
16 |
+
# proxy_set_header Host $host;
|
17 |
+
# proxy_set_header Upgrade $http_upgrade;
|
18 |
+
# proxy_set_header Connection "upgrade";
|
19 |
+
# proxy_read_timeout 86400;
|
20 |
+
# }
|
21 |
+
# location ~ ^/(streamlit|web)/ {
|
22 |
+
# rewrite ^/streamlit/(.*) /$1 last;
|
23 |
+
# rewrite ^/web/(.*) /$1 last;
|
24 |
+
# return 403;
|
25 |
+
# }
|
26 |
+
|
27 |
+
|
28 |
+
# #--- fastapi
|
29 |
+
# #--- WARN: the below combined OR directive does not work
|
30 |
+
# #location ~ ^/(api|fastapi|api2|fastapi2)/
|
31 |
+
# location /api/ {
|
32 |
+
# proxy_pass http://127.0.0.1:39132/; #--- default fastapi landing page
|
33 |
+
# proxy_buffering off;
|
34 |
+
# proxy_set_header X-Real-IP $remote_addr;
|
35 |
+
# proxy_set_header X-Forwarded-Host $host;
|
36 |
+
# proxy_set_header X-Forwarded-Port $server_port;
|
37 |
+
# }
|
38 |
+
# location ~ ^/(fastapi|api2|fastapi2)/ {
|
39 |
+
# rewrite ^/fastapi/(.*) /api/$1 last;
|
40 |
+
# rewrite ^/api2/(.*) /api/$1 last;
|
41 |
+
# rewrite ^/fastapi2/(.*) /api/$1 last;
|
42 |
+
# return 403;
|
43 |
+
# }
|
44 |
+
|
45 |
+
# #--- gradio
|
46 |
+
# location /gradio/ {
|
47 |
+
# proxy_pass http://127.0.0.1:39133/; #--- default gradio landing page
|
48 |
+
# proxy_buffering off;
|
49 |
+
# proxy_set_header X-Real-IP $remote_addr;
|
50 |
+
# proxy_set_header X-Forwarded-Host $host;
|
51 |
+
# proxy_set_header X-Forwarded-Port $server_port;
|
52 |
+
# }
|
53 |
+
|
54 |
+
#location /admin/nginx/ {
|
55 |
+
# #rewrite ^(/download/.*)/media/(\w+)\.?.*$ $1/mp3/$2.mp3 last;
|
56 |
+
# #return 403;
|
57 |
+
#
|
58 |
+
# root /usr/share/nginx/html;
|
59 |
+
# index index.html index.htm;
|
60 |
+
#}
|
61 |
+
|
62 |
+
#error_page 404 /404.html;
|
63 |
+
|
64 |
+
# redirect server error pages to the static page /50x.html
|
65 |
+
#
|
66 |
+
error_page 500 502 503 504 /50x.html;
|
67 |
+
location = /50x.html {
|
68 |
+
root /usr/share/nginx/html;
|
69 |
+
}
|
70 |
+
|
71 |
+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
72 |
+
#
|
73 |
+
#location ~ \.php$ {
|
74 |
+
# proxy_pass http://127.0.0.1;
|
75 |
+
#}
|
76 |
+
|
77 |
+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
78 |
+
#
|
79 |
+
#location ~ \.php$ {
|
80 |
+
# root html;
|
81 |
+
# fastcgi_pass 127.0.0.1:9000;
|
82 |
+
# fastcgi_index index.php;
|
83 |
+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
84 |
+
# include fastcgi_params;
|
85 |
+
#}
|
86 |
+
|
87 |
+
# deny access to .htaccess files, if Apache's document root
|
88 |
+
# concurs with nginx's one
|
89 |
+
#
|
90 |
+
#location ~ /\.ht {
|
91 |
+
# deny all;
|
92 |
+
#}
|
93 |
+
}
|
94 |
+
|
nginx/etc.nginx.sites-available.default
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
##
|
2 |
+
# You should look at the following URL's in order to grasp a solid understanding
|
3 |
+
# of Nginx configuration files in order to fully unleash the power of Nginx.
|
4 |
+
# https://www.nginx.com/resources/wiki/start/
|
5 |
+
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
|
6 |
+
# https://wiki.debian.org/Nginx/DirectoryStructure
|
7 |
+
#
|
8 |
+
# In most cases, administrators will remove this file from sites-enabled/ and
|
9 |
+
# leave it as reference inside of sites-available where it will continue to be
|
10 |
+
# updated by the nginx packaging team.
|
11 |
+
#
|
12 |
+
# This file will automatically load configuration files provided by other
|
13 |
+
# applications, such as Drupal or Wordpress. These applications will be made
|
14 |
+
# available underneath a path with that package name, such as /drupal8.
|
15 |
+
#
|
16 |
+
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
|
17 |
+
##
|
18 |
+
|
19 |
+
# Default server configuration
|
20 |
+
#
|
21 |
+
server {
|
22 |
+
listen 80 default_server;
|
23 |
+
#listen [::]:80 default_server; #--- IM: disable ipv6 dependency
|
24 |
+
|
25 |
+
# SSL configuration
|
26 |
+
#
|
27 |
+
# listen 443 ssl default_server;
|
28 |
+
# listen [::]:443 ssl default_server;
|
29 |
+
#
|
30 |
+
# Note: You should disable gzip for SSL traffic.
|
31 |
+
# See: https://bugs.debian.org/773332
|
32 |
+
#
|
33 |
+
# Read up on ssl_ciphers to ensure a secure configuration.
|
34 |
+
# See: https://bugs.debian.org/765782
|
35 |
+
#
|
36 |
+
# Self signed certs generated by the ssl-cert package
|
37 |
+
# Don't use them in a production server!
|
38 |
+
#
|
39 |
+
# include snippets/snakeoil.conf;
|
40 |
+
|
41 |
+
root /var/www/html;
|
42 |
+
|
43 |
+
# Add index.php to the list if you are using PHP
|
44 |
+
index index.html index.htm index.nginx-debian.html;
|
45 |
+
|
46 |
+
server_name _;
|
47 |
+
|
48 |
+
location / {
|
49 |
+
# First attempt to serve request as file, then
|
50 |
+
# as directory, then fall back to displaying a 404.
|
51 |
+
try_files $uri $uri/ =404;
|
52 |
+
}
|
53 |
+
|
54 |
+
# pass PHP scripts to FastCGI server
|
55 |
+
#
|
56 |
+
#location ~ \.php$ {
|
57 |
+
# include snippets/fastcgi-php.conf;
|
58 |
+
#
|
59 |
+
# # With php-fpm (or other unix sockets):
|
60 |
+
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
|
61 |
+
# # With php-cgi (or other tcp sockets):
|
62 |
+
# fastcgi_pass 127.0.0.1:9000;
|
63 |
+
#}
|
64 |
+
|
65 |
+
# deny access to .htaccess files, if Apache's document root
|
66 |
+
# concurs with nginx's one
|
67 |
+
#
|
68 |
+
#location ~ /\.ht {
|
69 |
+
# deny all;
|
70 |
+
#}
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
# Virtual Host configuration for example.com
|
75 |
+
#
|
76 |
+
# You can move that to a different file under sites-available/ and symlink that
|
77 |
+
# to sites-enabled/ to enable it.
|
78 |
+
#
|
79 |
+
#server {
|
80 |
+
# listen 80;
|
81 |
+
# listen [::]:80;
|
82 |
+
#
|
83 |
+
# server_name example.com;
|
84 |
+
#
|
85 |
+
# root /var/www/example.com;
|
86 |
+
# index index.html;
|
87 |
+
#
|
88 |
+
# location / {
|
89 |
+
# try_files $uri $uri/ =404;
|
90 |
+
# }
|
91 |
+
#}
|
nginx/etc.nginx_nginx.conf
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# nginx.conf
|
2 |
+
pid /var/run/nginx.pid;
|
3 |
+
|
4 |
+
worker_processes auto;
|
5 |
+
|
6 |
+
events {
|
7 |
+
worker_connections 1024;
|
8 |
+
}
|
9 |
+
|
10 |
+
http {
|
11 |
+
include /etc/nginx/mime.types;
|
12 |
+
default_type application/octet-stream;
|
13 |
+
|
14 |
+
server {
|
15 |
+
listen 7860;
|
16 |
+
server_name localhost;
|
17 |
+
root /usr/share/nginx/html;
|
18 |
+
index index.html;
|
19 |
+
|
20 |
+
location / {
|
21 |
+
try_files $uri $uri/ =404;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|