initial commit of Dockerfile for web service
This commit is contained in:
parent
dce2daf462
commit
81589860fe
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
apache2_examples
|
||||
*-SAMPLE*
|
||||
__pycache*
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# HBNet Web Service Dockerfile
|
||||
FROM debian:11
|
||||
MAINTAINER Eric Craw "kf7eel@qsl.net"
|
||||
WORKDIR /opt/hbnet_web
|
||||
|
||||
RUN useradd -ms /bin/bash hbnet_web
|
||||
|
||||
COPY . .
|
||||
|
||||
#Install Python3.9 and dependencies
|
||||
RUN apt-get -y update; apt-get -y upgrade; apt-get -y install --no-install-recommends python3.9-dev python3-pip python3.9 build-essential net-tools nginx; apt-get clean; rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Remove unnecessary NGINX stuff
|
||||
RUN rm -f /etc/nginx/fastcgi.conf /etc/nginx/fastcgi_params && \
|
||||
rm -f /etc/nginx/snippets/fastcgi-php.conf /etc/nginx/snippets/snakeoil.conf
|
||||
|
||||
# Install Supervisor
|
||||
RUN python3.9 -m pip install --no-cache-dir supervisor
|
||||
|
||||
# Install NGINX config
|
||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY docker/hbnet.conf /etc/nginx/sites-enabled/hbnet.conf
|
||||
COPY docker/nginx_default /etc/nginx/sites-enabled/default
|
||||
RUN chown -R www-data:www-data /var/log/nginx
|
||||
COPY docker/wsgi.py /opt/hbnet_web
|
||||
COPY docker/wsgi.ini /opt/hbnet_web
|
||||
|
||||
RUN chown -R hbnet_web:hbnet_web /opt/hbnet_web/
|
||||
|
||||
COPY docker/supervisord.conf /etc
|
||||
|
||||
# Switch user and install dependencies
|
||||
USER hbnet_web
|
||||
|
||||
|
||||
#Upgrade PIP
|
||||
RUN python3.9 -m pip install --upgrade pip
|
||||
|
||||
#Install from requirements.txt
|
||||
RUN python3.9 -m pip install --no-cache-dir -r requirements.txt
|
||||
#RUN python3.9 -m pip install --no-cache-dir supervisor
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
#ENTRYPOINT ["/home/hbnet_web/.local/bin/supervisord"]
|
||||
|
||||
USER root
|
||||
|
||||
CMD ["/usr/local/bin/supervisord", "-n"]
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
server_name _;
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
uwsgi_pass unix:/tmp/hbnet_web_service.sock;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
#user www-data;
|
||||
#user hbnet_web
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
|
||||
|
||||
#mail {
|
||||
# # See sample authentication script at:
|
||||
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
|
||||
#
|
||||
# # auth_http localhost/auth.php;
|
||||
# # pop3_capabilities "TOP" "USER";
|
||||
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
|
||||
#
|
||||
# server {
|
||||
# listen localhost:110;
|
||||
# protocol pop3;
|
||||
# proxy on;
|
||||
# }
|
||||
#
|
||||
# server {
|
||||
# listen localhost:143;
|
||||
# protocol imap;
|
||||
# proxy on;
|
||||
# }
|
||||
#}
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
##
|
||||
# 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.
|
||||
# https://www.nginx.com/resources/wiki/start/
|
||||
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
|
||||
# https://wiki.debian.org/Nginx/DirectoryStructure
|
||||
#
|
||||
# In most cases, administrators will remove this file from sites-enabled/ and
|
||||
# leave it as reference inside of sites-available where it will continue to be
|
||||
# updated by the nginx packaging team.
|
||||
#
|
||||
# This file will automatically load configuration files provided by other
|
||||
# applications, such as Drupal or Wordpress. These applications will be made
|
||||
# available underneath a path with that package name, such as /drupal8.
|
||||
#
|
||||
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
|
||||
##
|
||||
|
||||
# Default server configuration
|
||||
#
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
# SSL configuration
|
||||
#
|
||||
# listen 443 ssl default_server;
|
||||
# listen [::]:443 ssl default_server;
|
||||
#
|
||||
# Note: You should disable gzip for SSL traffic.
|
||||
# See: https://bugs.debian.org/773332
|
||||
#
|
||||
# Read up on ssl_ciphers to ensure a secure configuration.
|
||||
# See: https://bugs.debian.org/765782
|
||||
#
|
||||
# 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 default;
|
||||
|
||||
location / {
|
||||
# First attempt to serve request as file, then
|
||||
# as directory, then fall back to displaying a 404.
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
# pass PHP scripts to FastCGI server
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# include snippets/fastcgi-php.conf;
|
||||
#
|
||||
# # With php-fpm (or other unix sockets):
|
||||
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
|
||||
# # With php-cgi (or other tcp sockets):
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
#}
|
||||
|
||||
# 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;
|
||||
# }
|
||||
#}
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:uwsgi]
|
||||
user=hbnet_web
|
||||
command=/home/hbnet_web/.local/bin/uwsgi --ini /opt/hbnet_web/wsgi.ini --die-on-term
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[program:nginx]
|
||||
#user=www-data
|
||||
command=/usr/sbin/nginx -g "daemon off;"
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
[uwsgi]
|
||||
module = wsgi:app
|
||||
|
||||
master = true
|
||||
processes = 2
|
||||
|
||||
uid=hbnet_web
|
||||
chdir=/opt/hbnet_web
|
||||
pythonpath=/home/hbnet_web/.local
|
||||
pythonpath=/home/hbnet_web/.local/lib/python3.9/site-packages/
|
||||
|
||||
|
||||
socket = /tmp/hbnet_web_service.sock
|
||||
chmod-socket = 666
|
||||
vacuum = true
|
||||
|
||||
die-on-term = true
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
from app import hbnet_web_service
|
||||
|
||||
app = hbnet_web_service()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
Loading…
Reference in New Issue