├── 2.7 ├── Dockerfile ├── application.py ├── build.sh ├── entrypoint.py ├── hostingstart.html ├── init_container.sh └── sshd_config ├── 3.6 ├── Dockerfile ├── application.py ├── build.sh ├── entrypoint.py ├── hostingstart.html ├── init_container.sh └── sshd_config ├── 3.7 ├── Dockerfile ├── application.py ├── build.sh ├── entrypoint.py ├── hostingstart.html ├── init.py ├── init_container.sh └── sshd_config ├── LICENSE ├── README.md ├── buildall.sh ├── pull_request_template.md └── testapps ├── django ├── db.sqlite3 ├── manage.py ├── mysite │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── settings.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ └── wsgi.cpython-36.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── requirements.txt └── flask ├── application.py └── requirements.txt /2.7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/oryx/python:2.7-20190712.5 2 | LABEL maintainer="appsvc-images@microsoft.com" 3 | 4 | # Web Site Home 5 | ENV HOME_SITE "/home/site/wwwroot" 6 | 7 | #Install system dependencies 8 | RUN apt-get update \ 9 | && apt-get install -y --no-install-recommends \ 10 | openssh-server \ 11 | vim \ 12 | curl \ 13 | wget \ 14 | # build-essential \ 15 | tcptraceroute \ 16 | && pip install --upgrade pip \ 17 | && pip install gunicorn \ 18 | && pip install virtualenv \ 19 | && pip install flask \ 20 | && pip install scandir 21 | 22 | WORKDIR ${HOME_SITE} 23 | 24 | EXPOSE 8000 25 | ENV PORT 8000 26 | ENV SSH_PORT 2222 27 | 28 | # setup SSH 29 | RUN mkdir -p /home/LogFiles \ 30 | && echo "root:Docker!" | chpasswd \ 31 | && echo "cd /home" >> /etc/bash.bashrc 32 | 33 | COPY sshd_config /etc/ssh/ 34 | RUN mkdir -p /opt/startup 35 | COPY init_container.sh /opt/startup/init_container.sh 36 | 37 | # setup default site 38 | RUN mkdir /opt/defaultsite 39 | COPY hostingstart.html /opt/defaultsite 40 | COPY application.py /opt/defaultsite 41 | 42 | # configure startup 43 | RUN chmod -R 777 /opt/startup 44 | COPY entrypoint.py /usr/local/bin 45 | 46 | ENTRYPOINT ["/opt/startup/init_container.sh"] 47 | -------------------------------------------------------------------------------- /2.7/application.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | app = Flask(__name__, static_folder='/opt/defaultsite') 3 | 4 | @app.route('/') 5 | def root(): 6 | return app.send_static_file('hostingstart.html') 7 | -------------------------------------------------------------------------------- /2.7/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x -e 3 | 4 | buildnumber=${4-$(date -u +"%y%m%d%H%M")} 5 | 6 | docker build --no-cache -t "$1"/python:2.7_"$buildnumber" . -------------------------------------------------------------------------------- /2.7/entrypoint.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | import scandir 4 | 5 | HOME_SITE="/home/site/wwwroot" 6 | DEFAULT_SITE="/opt/defaultsite" 7 | STARTUP_COMMAND_FILE="/opt/startup/startupCommand" 8 | APPSVC_VIRTUAL_ENV="antenv" 9 | 10 | # Temp patch. Remove when Kudu script is available. 11 | os.environ["PYTHONPATH"] = HOME_SITE + "/antenv2.7/lib/python2.7/site-packages" 12 | 13 | def subprocess_cmd(command): 14 | print ('executing:') 15 | print (command) 16 | 17 | process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True) 18 | proc_stdout = process.communicate()[0].strip() 19 | print (proc_stdout.decode("utf-8")) 20 | 21 | ## Check for custom startup command 22 | def custom_check(): 23 | with open(STARTUP_COMMAND_FILE, 'r') as myfile: 24 | startupScript = myfile.read().rstrip() 25 | if not startupScript: 26 | return None 27 | else: 28 | if ".." not in startupScript: 29 | startupFilePath = HOME_SITE + '/' + startupScript 30 | print('startup script: ' + startupFilePath) 31 | try: 32 | startupFile = open(startupFilePath, 'r') 33 | print ('identified startup script as a file on disk') 34 | startArgs = startupFile.read() 35 | print(startArgs) 36 | if not startArgs: 37 | return None 38 | else: 39 | return startArgs 40 | 41 | except: 42 | # appCommandLine is not a file, assume it is the script to be started bu gunicorn 43 | print('startup script is not a file, use it as gunicorn arg') 44 | return startupScript 45 | else: 46 | print('invalid data in startup script, ignoring it.') 47 | return None 48 | 49 | return startupScript 50 | 51 | ## Django check: If 'wsgi.py' is provided, identify as Django. 52 | ## Django check: If 'wsgi.py' is provided, identify as Django. 53 | def check_django(): 54 | print("Checking for django app in site's content folder:") 55 | 56 | try: 57 | siteRoot = scandir.scandir(HOME_SITE) 58 | for entry in siteRoot: 59 | if not entry.name.startswith(APPSVC_VIRTUAL_ENV) and entry.is_dir(): 60 | print("Detected directory: '" + entry.name + "'") 61 | subFolder = scandir.scandir(HOME_SITE + '/'+ entry.name) 62 | for subEntry in subFolder: 63 | if subEntry.name == 'wsgi.py' and subEntry.is_file(): 64 | print("Found wsgi.py in directory '" + entry.name + "', django app detection success") 65 | return entry.name + '.wsgi' 66 | finally: 67 | print("django test returned ") 68 | 69 | ## Flask check: If 'application.py' is provided or a .py module is present, identify as Flask. 70 | def check_flask(): 71 | print("Checking for flask app in site's content folder:") 72 | 73 | try: 74 | siteRoot = scandir.scandir(HOME_SITE) 75 | for entry in siteRoot: 76 | if entry.is_file() and (entry.name == "application.py" or entry.name == "app.py"): 77 | print("found app '" + entry.name + "' in root folder, flask app detection success") 78 | return entry.name[:-3] + ":app" 79 | 80 | return None 81 | finally: 82 | print("flask test returned") 83 | 84 | 85 | def start_server(): 86 | cmd = custom_check() 87 | if cmd is not None: 88 | print('custom startup found: ' + cmd); 89 | subprocess_cmd('. antenv2.7/bin/activate') 90 | if 'python' in cmd: 91 | subprocess_cmd(cmd) 92 | 93 | elif 'gunicorn' in cmd: 94 | subprocess_cmd(cmd) 95 | 96 | else: 97 | subprocess_cmd( 98 | 'gunicorn --bind=0.0.0.0 --timeout 600 ' + cmd 99 | ) 100 | 101 | cmd = check_django() 102 | if cmd is not None: 103 | print(cmd) 104 | subprocess_cmd('. antenv2.7/bin/activate') 105 | subprocess_cmd( 106 | 'gunicorn --bind=0.0.0.0 --timeout 600 ' + cmd 107 | ) 108 | 109 | cmd = check_flask() 110 | if cmd is not None: 111 | print(cmd) 112 | subprocess_cmd('. antenv2.7/bin/activate') 113 | subprocess_cmd( 114 | 'gunicorn --bind=0.0.0.0 --timeout 600 ' + cmd 115 | ) 116 | else: 117 | print('starting default app') 118 | subprocess_cmd( 119 | 'gunicorn --bind=0.0.0.0 --timeout 600 --chdir /opt/defaultsite application:app' 120 | ) 121 | 122 | subprocess_cmd('python --version') 123 | subprocess_cmd('pip --version') 124 | start_server() 125 | -------------------------------------------------------------------------------- /2.7/hostingstart.html: -------------------------------------------------------------------------------- 1 | Microsoft Azure App Service - Welcome

Hey, Python developers!


Your app service is up and running.

Time to take the next step and deploy your code.

Have your code ready?
Use deployment center to get code published from your client or setup continuous deployment.

Don't have your code yet?
Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.

2 | -------------------------------------------------------------------------------- /2.7/init_container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat >/etc/motd < 10 | \/ \/ \/ 11 | 12 | A P P S E R V I C E O N L I N U X 13 | 14 | Documentation: http://aka.ms/webapp-linux 15 | 16 | EOL 17 | cat /etc/motd 18 | 19 | sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config 20 | service ssh start 21 | 22 | # Get environment variables to show up in SSH session 23 | eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) 24 | 25 | echo "$@" > /opt/startup/startupCommand 26 | chmod 755 /opt/startup/startupCommand 27 | 28 | oryxArgs="-appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv2.7 -defaultApp /opt/defaultsite -bindPort $PORT" 29 | if [ $# -eq 0 ]; then 30 | echo 'App Command Line not configured, will attempt auto-detect' 31 | else 32 | echo "Site's appCommandLine: $@" 33 | if [ $# -eq 1 ]; then 34 | echo "Checking of $1 is a file" 35 | if [ -f $1 ]; then 36 | echo 'App command line is a file on disk' 37 | fileContents=$(head -1 $1) 38 | #if the file ends with, check if this is a script (first two chars of the file) 39 | if [ ${1: -3} == ".sh" ]; then 40 | echo 'App command line is a shell script, will execute this script as startup script' 41 | chmod +x $1 42 | oryxArgs+=" -userStartupCommand $1" 43 | else 44 | echo "$1 file exists on disk, reading its contents to run as startup arguments" 45 | echo "Contents of startupScript: $fileContents" 46 | oryxArgs+=" -userStartupCommand '$fileContents'" 47 | fi 48 | else 49 | echo 'App command line is not a file on disk, using it as the startup command.' 50 | oryxArgs+=" -userStartupCommand '$1'" 51 | fi 52 | else 53 | oryxArgs+=" -userStartupCommand '$@'" 54 | fi 55 | fi 56 | 57 | echo "Launching oryx with: $oryxArgs" 58 | #invoke oryx to generate startup script 59 | eval "oryx $oryxArgs" 60 | chmod +x /opt/startup/startup.sh 61 | #launch startup script 62 | /opt/startup/startup.sh 63 | 64 | -------------------------------------------------------------------------------- /2.7/sshd_config: -------------------------------------------------------------------------------- 1 | # This is ssh server systemwide configuration file. 2 | # 3 | # /etc/sshd_config 4 | 5 | Port SSH_PORT 6 | ListenAddress 0.0.0.0 7 | LoginGraceTime 180 8 | X11Forwarding yes 9 | Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr 10 | MACs hmac-sha1,hmac-sha1-96 11 | StrictModes yes 12 | SyslogFacility DAEMON 13 | PasswordAuthentication yes 14 | PermitEmptyPasswords no 15 | PermitRootLogin yes 16 | Subsystem sftp internal-sftp 17 | -------------------------------------------------------------------------------- /3.6/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/oryx/python:3.6-20190712.5 2 | LABEL maintainer="appsvc-images@microsoft.com" 3 | 4 | # Web Site Home 5 | ENV HOME_SITE "/home/site/wwwroot" 6 | 7 | #Install system dependencies 8 | RUN apt-get update \ 9 | && apt-get install -y --no-install-recommends \ 10 | openssh-server \ 11 | vim \ 12 | curl \ 13 | wget \ 14 | tcptraceroute \ 15 | && pip install --upgrade pip \ 16 | && pip install subprocess32 \ 17 | && pip install gunicorn \ 18 | && pip install virtualenv \ 19 | && pip install flask 20 | 21 | WORKDIR ${HOME_SITE} 22 | 23 | EXPOSE 8000 24 | ENV PORT 8000 25 | ENV SSH_PORT 2222 26 | 27 | # setup SSH 28 | RUN mkdir -p /home/LogFiles \ 29 | && echo "root:Docker!" | chpasswd \ 30 | && echo "cd /home" >> /etc/bash.bashrc 31 | 32 | COPY sshd_config /etc/ssh/ 33 | RUN mkdir -p /opt/startup 34 | COPY init_container.sh /opt/startup/init_container.sh 35 | 36 | # setup default site 37 | RUN mkdir /opt/defaultsite 38 | COPY hostingstart.html /opt/defaultsite 39 | COPY application.py /opt/defaultsite 40 | 41 | # configure startup 42 | RUN chmod -R 777 /opt/startup 43 | COPY entrypoint.py /usr/local/bin 44 | 45 | ENTRYPOINT ["/opt/startup/init_container.sh"] 46 | -------------------------------------------------------------------------------- /3.6/application.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | app = Flask(__name__, static_folder='/opt/defaultsite') 3 | 4 | @app.route('/') 5 | def root(): 6 | return app.send_static_file('hostingstart.html') 7 | -------------------------------------------------------------------------------- /3.6/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x -e 3 | 4 | buildnumber=${4-$(date -u +"%y%m%d%H%M")} 5 | 6 | docker build --no-cache -t "$1"/python:3.6_"$buildnumber" . 7 | -------------------------------------------------------------------------------- /3.6/entrypoint.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | 4 | HOME_SITE="/home/site/wwwroot" 5 | DEFAULT_SITE="/opt/defaultsite" 6 | STARTUP_COMMAND_FILE="/opt/startup/startupCommand" 7 | APPSVC_VIRTUAL_ENV="antenv" 8 | 9 | # Temp patch. Remove when Kudu script is available. 10 | os.environ["PYTHONPATH"] = HOME_SITE + "/antenv3.6/lib/python3.6/site-packages" 11 | 12 | def subprocess_cmd(command): 13 | print ('executing:') 14 | print (command) 15 | 16 | process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True) 17 | proc_stdout = process.communicate()[0].strip() 18 | print (proc_stdout.decode("utf-8")) 19 | 20 | ## Check for custom startup command 21 | def custom_check(): 22 | with open(STARTUP_COMMAND_FILE, 'r') as myfile: 23 | startupScript = myfile.read().rstrip() 24 | if not startupScript: 25 | return None 26 | else: 27 | if ".." not in startupScript: 28 | startupFilePath = HOME_SITE + '/' + startupScript 29 | print('startup script: ' + startupFilePath) 30 | try: 31 | startupFile = open(startupFilePath, 'r') 32 | print ('identified startup script as a file on disk') 33 | startArgs = startupFile.read() 34 | print(startArgs) 35 | if not startArgs: 36 | return None 37 | else: 38 | return startArgs 39 | 40 | except: 41 | # appCommandLine is not a file, assume it is the script to be started bu gunicorn 42 | print('startup script is not a file, use it as gunicorn arg') 43 | return startupScript 44 | else: 45 | print('invalid data in startup script, ignoring it.') 46 | return None 47 | 48 | return startupScript 49 | 50 | ## Django check: If 'wsgi.py' is provided, identify as Django. 51 | def check_django(): 52 | with os.scandir(HOME_SITE) as siteRoot: 53 | for entry in siteRoot: 54 | if not entry.name.startswith(APPSVC_VIRTUAL_ENV) and entry.is_dir(): 55 | with os.scandir(HOME_SITE + '/'+ entry.name) as subFolder: 56 | for subEntry in subFolder: 57 | if subEntry.name == 'wsgi.py' and subEntry.is_file(): 58 | print ("found django app") 59 | return entry.name + '.wsgi' 60 | return None 61 | 62 | ## Flask check: If 'application.py' is provided or a .py module is present, identify as Flask. 63 | def check_flask(): 64 | with os.scandir(HOME_SITE) as siteRoot: 65 | for entry in siteRoot: 66 | if entry.is_file(): 67 | if (entry.name == 'application.py'): 68 | print("found flask app") 69 | return "application:app" 70 | else: 71 | if (entry.name == 'app.py'): 72 | print("found flask app") 73 | return "app:app" 74 | return None 75 | 76 | def start_server(): 77 | 78 | cmd = custom_check() 79 | if cmd is not None: 80 | print('custom startup found: ' + cmd); 81 | subprocess_cmd('. antenv3.6/bin/activate') 82 | if 'python' in cmd: 83 | subprocess_cmd(cmd) 84 | 85 | elif 'gunicorn' in cmd: 86 | subprocess_cmd(cmd) 87 | 88 | else: 89 | subprocess_cmd( 90 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn ' + cmd 91 | ) 92 | return 93 | 94 | cmd = check_django() 95 | if cmd is not None: 96 | subprocess_cmd('. antenv3.6/bin/activate') 97 | subprocess_cmd( 98 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn ' + cmd 99 | ) 100 | return 101 | 102 | cmd = check_flask() 103 | if cmd is not None: 104 | subprocess_cmd('. antenv3.6/bin/activate') 105 | subprocess_cmd( 106 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn ' + cmd 107 | ) 108 | return 109 | 110 | else: 111 | print('starting default app') 112 | subprocess_cmd( 113 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --chdir /opt/defaultsite" gunicorn application:app' 114 | ) 115 | return 116 | 117 | subprocess_cmd('python --version') 118 | subprocess_cmd('pip --version') 119 | start_server() 120 | -------------------------------------------------------------------------------- /3.6/hostingstart.html: -------------------------------------------------------------------------------- 1 | Microsoft Azure App Service - Welcome

Hey, Python developers!


Your app service is up and running.

Time to take the next step and deploy your code.

Have your code ready?
Use deployment center to get code published from your client or setup continuous deployment.

Don't have your code yet?
Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.

2 | -------------------------------------------------------------------------------- /3.6/init_container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat >/etc/motd < 10 | \/ \/ \/ 11 | 12 | A P P S E R V I C E O N L I N U X 13 | 14 | Documentation: http://aka.ms/webapp-linux 15 | 16 | EOL 17 | cat /etc/motd 18 | 19 | sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config 20 | service ssh start 21 | 22 | # Get environment variables to show up in SSH session 23 | eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) 24 | 25 | echo "$@" > /opt/startup/startupCommand 26 | chmod 755 /opt/startup/startupCommand 27 | 28 | oryxArgs="-appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv3.6 -defaultApp /opt/defaultsite -bindPort $PORT" 29 | if [ $# -eq 0 ]; then 30 | echo 'App Command Line not configured, will attempt auto-detect' 31 | else 32 | echo "Site's appCommandLine: $@" 33 | if [ $# -eq 1 ]; then 34 | echo "Checking of $1 is a file" 35 | if [ -f $1 ]; then 36 | echo 'App command line is a file on disk' 37 | fileContents=$(head -1 $1) 38 | #if the file ends with .sh 39 | if [ ${1: -3} == ".sh" ]; then 40 | echo 'App command line is a shell script, will execute this script as startup script' 41 | chmod +x $1 42 | oryxArgs+=" -userStartupCommand $1" 43 | else 44 | echo "$1 file exists on disk, reading its contents to run as startup arguments" 45 | echo "Contents of startupScript: $fileContents" 46 | oryxArgs+=" -userStartupCommand '$fileContents'" 47 | fi 48 | else 49 | echo 'App command line is not a file on disk, using it as the startup command.' 50 | oryxArgs+=" -userStartupCommand '$1'" 51 | fi 52 | else 53 | oryxArgs+=" -userStartupCommand '$@'" 54 | fi 55 | fi 56 | 57 | echo "Launching oryx with: $oryxArgs" 58 | #invoke oryx to generate startup script 59 | eval "oryx $oryxArgs" 60 | chmod +x /opt/startup/startup.sh 61 | #launch startup script 62 | /opt/startup/startup.sh 63 | -------------------------------------------------------------------------------- /3.6/sshd_config: -------------------------------------------------------------------------------- 1 | # This is ssh server systemwide configuration file. 2 | # 3 | # /etc/sshd_config 4 | 5 | Port SSH_PORT 6 | ListenAddress 0.0.0.0 7 | LoginGraceTime 180 8 | X11Forwarding yes 9 | Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr 10 | MACs hmac-sha1,hmac-sha1-96 11 | StrictModes yes 12 | SyslogFacility DAEMON 13 | PasswordAuthentication yes 14 | PermitEmptyPasswords no 15 | PermitRootLogin yes 16 | Subsystem sftp internal-sftp 17 | -------------------------------------------------------------------------------- /3.7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/oryx/python:3.7-20190712.5 2 | LABEL maintainer="appsvc-images@microsoft.com" 3 | 4 | # Web Site Home 5 | ENV HOME_SITE "/home/site/wwwroot" 6 | 7 | #Install system dependencies 8 | RUN apt-get update \ 9 | && apt-get install -y --no-install-recommends \ 10 | openssh-server \ 11 | vim \ 12 | curl \ 13 | wget \ 14 | tcptraceroute \ 15 | && pip install --upgrade pip \ 16 | && pip install subprocess32 \ 17 | && pip install gunicorn \ 18 | && pip install virtualenv \ 19 | && pip install flask 20 | 21 | WORKDIR ${HOME_SITE} 22 | 23 | EXPOSE 8000 24 | ENV PORT 8000 25 | ENV SSH_PORT 2222 26 | 27 | # setup SSH 28 | RUN mkdir -p /home/LogFiles \ 29 | && echo "root:Docker!" | chpasswd \ 30 | && echo "cd /home" >> /etc/bash.bashrc 31 | 32 | COPY sshd_config /etc/ssh/ 33 | RUN mkdir -p /opt/startup 34 | COPY init_container.sh /opt/startup/init_container.sh 35 | 36 | # setup default site 37 | RUN mkdir /opt/defaultsite 38 | COPY hostingstart.html /opt/defaultsite 39 | COPY application.py /opt/defaultsite 40 | 41 | # configure startup 42 | RUN chmod -R 777 /opt/startup 43 | COPY entrypoint.py /usr/local/bin 44 | 45 | ENTRYPOINT ["/opt/startup/init_container.sh"] 46 | -------------------------------------------------------------------------------- /3.7/application.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | app = Flask(__name__, static_folder='/opt/defaultsite') 3 | 4 | @app.route('/') 5 | def root(): 6 | return app.send_static_file('hostingstart.html') 7 | -------------------------------------------------------------------------------- /3.7/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x -e 3 | 4 | buildnumber=${4-$(date -u +"%y%m%d%H%M")} 5 | 6 | docker build --no-cache -t "$1"/python:3.7_"$buildnumber" . 7 | docker tag "$1"/python:3.7_"$buildnumber" "$1"/python:latest 8 | -------------------------------------------------------------------------------- /3.7/entrypoint.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | 4 | HOME_SITE="/home/site/wwwroot" 5 | DEFAULT_SITE="/opt/defaultsite" 6 | STARTUP_COMMAND_FILE="/opt/startup/startupCommand" 7 | APPSVC_VIRTUAL_ENV="antenv" 8 | 9 | # Temp patch. Remove when Kudu script is available. 10 | os.environ["PYTHONPATH"] = HOME_SITE + "/antenv/lib/python3.7/site-packages" 11 | 12 | def subprocess_cmd(command): 13 | print ('executing:') 14 | print (command) 15 | 16 | process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True) 17 | proc_stdout = process.communicate()[0].strip() 18 | print (proc_stdout.decode("utf-8")) 19 | 20 | ## Check for custom startup command 21 | def custom_check(): 22 | with open(STARTUP_COMMAND_FILE, 'r') as myfile: 23 | startupScript = myfile.read().rstrip() 24 | if not startupScript: 25 | return None 26 | else: 27 | if ".." not in startupScript: 28 | startupFilePath = HOME_SITE + '/' + startupScript 29 | print('startup script: ' + startupFilePath) 30 | try: 31 | startupFile = open(startupFilePath, 'r') 32 | print ('identified startup script as a file on disk') 33 | startArgs = startupFile.read() 34 | print(startArgs) 35 | if not startArgs: 36 | return None 37 | else: 38 | return startArgs 39 | 40 | except: 41 | # appCommandLine is not a file, assume it is the script to be started bu gunicorn 42 | print('startup script is not a file, use it as gunicorn arg') 43 | return startupScript 44 | else: 45 | print('invalid data in startup script, ignoring it.') 46 | return None 47 | 48 | return startupScript 49 | 50 | ## Django check: If 'wsgi.py' is provided, identify as Django. 51 | def check_django(): 52 | with os.scandir(HOME_SITE) as siteRoot: 53 | for entry in siteRoot: 54 | if not entry.name.startswith(APPSVC_VIRTUAL_ENV) and entry.is_dir(): 55 | with os.scandir(HOME_SITE + '/'+ entry.name) as subFolder: 56 | for subEntry in subFolder: 57 | if subEntry.name == 'wsgi.py' and subEntry.is_file(): 58 | print ("found django app") 59 | return entry.name + '.wsgi' 60 | return None 61 | 62 | ## Flask check: If 'application.py' is provided or a .py module is present, identify as Flask. 63 | def check_flask(): 64 | with os.scandir(HOME_SITE) as siteRoot: 65 | for entry in siteRoot: 66 | if entry.is_file(): 67 | if (entry.name == 'application.py'): 68 | print("found flask app") 69 | return "application:app" 70 | else: 71 | if (entry.name == 'app.py'): 72 | print("found flask app") 73 | return "app:app" 74 | 75 | return None 76 | 77 | def start_server(): 78 | 79 | cmd = custom_check() 80 | if cmd is not None: 81 | print('custom startup found: ' + cmd); 82 | subprocess_cmd('. antenv/bin/activate') 83 | if 'python' in cmd: 84 | subprocess_cmd(cmd) 85 | 86 | elif 'gunicorn' in cmd: 87 | subprocess_cmd(cmd) 88 | 89 | else: 90 | subprocess_cmd( 91 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn ' + cmd 92 | ) 93 | return 94 | 95 | cmd = check_django() 96 | if cmd is not None: 97 | subprocess_cmd('. antenv/bin/activate') 98 | subprocess_cmd( 99 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn ' + cmd 100 | ) 101 | return 102 | 103 | cmd = check_flask() 104 | if cmd is not None: 105 | subprocess_cmd('. antenv/bin/activate') 106 | subprocess_cmd( 107 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn ' + cmd 108 | ) 109 | return 110 | 111 | else: 112 | print('starting default app') 113 | subprocess_cmd( 114 | 'GUNICORN_CMD_ARGS="--bind=0.0.0.0 --chdir /opt/defaultsite" gunicorn application:app' 115 | ) 116 | return 117 | 118 | subprocess_cmd('python --version') 119 | subprocess_cmd('pip --version') 120 | start_server() 121 | -------------------------------------------------------------------------------- /3.7/hostingstart.html: -------------------------------------------------------------------------------- 1 | Microsoft Azure App Service - Welcome

Hey, Python developers!


Your app service is up and running.

Time to take the next step and deploy your code.

Have your code ready?
Use deployment center to get code published from your client or setup continuous deployment.

Don't have your code yet?
Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.

2 | -------------------------------------------------------------------------------- /3.7/init.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | 4 | HOME_SITE="/home/site/wwwroot" 5 | DEFAULT_SITE="/opt/defaultsite" 6 | STARTUP_COMMAND_FILE="/opt/startup/startupCommand" 7 | APPSVC_VIRTUAL_ENV="antenv" 8 | 9 | def subprocess_cmd(command): 10 | print ('executing:') 11 | print (command) 12 | 13 | process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True) 14 | proc_stdout = process.communicate()[0].strip() 15 | print (proc_stdout.decode("utf-8")) 16 | 17 | def getStartupArgs(): 18 | with open(STARTUP_COMMAND_FILE, 'r') as myfile: 19 | startupScript = myfile.read().rstrip() 20 | if not startupScript: 21 | print('App startup command not specified, will use defaults..') 22 | return None 23 | else: 24 | if ".." not in startupScript: 25 | startupFilePath = HOME_SITE + '/' + startupScript 26 | print('checking for startup script file: ' + startupFilePath) 27 | try: 28 | startupFile = open(startupFilePath, 'r') 29 | print ('identified startup script as a file on disk') 30 | startArgs = startupFile.read() 31 | print(startArgs) 32 | if not startArgs: 33 | return None 34 | else: 35 | return startArgs 36 | 37 | except: 38 | # appCommandLine is not a file, assume it is the script to be started bu gunicorn 39 | print('startup script is not a file, use it as gunicorn arg') 40 | return startupScript 41 | 42 | def find_and_launch_entrypoint(): 43 | if os.path.isdir(HOME_SITE + '/antenv'): 44 | print('Executing entrypoint.py script:') 45 | subprocess_cmd('python -u /usr/local/bin/entrypoint.py') 46 | else: 47 | oryxCmd = "oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultApp /opt/defaultsite " 48 | cmd = getStartupArgs() 49 | if cmd is not None: 50 | oryxCmd += ' -userStartupCommand ' + '\'' + cmd + '\'' 51 | 52 | print('Generating startup command with oryxCmd ' + oryxCmd) 53 | subprocess_cmd(oryxCmd) 54 | print('Launching oryx-Startup script ') 55 | subprocess_cmd('chmod +x /opt/startup/startup.sh') 56 | subprocess_cmd('/opt/startup/startup.sh') 57 | 58 | subprocess_cmd('python --version') 59 | find_and_launch_entrypoint() -------------------------------------------------------------------------------- /3.7/init_container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat >/etc/motd < 10 | \/ \/ \/ 11 | 12 | A P P S E R V I C E O N L I N U X 13 | 14 | Documentation: http://aka.ms/webapp-linux 15 | 16 | EOL 17 | cat /etc/motd 18 | 19 | sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config 20 | service ssh start 21 | 22 | # Get environment variables to show up in SSH session 23 | eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) 24 | 25 | echo "$@" > /opt/startup/startupCommand 26 | chmod 755 /opt/startup/startupCommand 27 | 28 | #oryx startup script generator 29 | oryxArgs="-appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -bindPort $PORT" 30 | if [ $# -eq 0 ]; then 31 | echo 'App Command Line not configured, will attempt auto-detect' 32 | else 33 | echo "Site's appCommandLine: $@" 34 | if [ $# -eq 1 ]; then 35 | echo "Checking of $1 is a file" 36 | if [ -f $1 ]; then 37 | echo 'App command line is a file on disk' 38 | fileContents=$(head -1 $1) 39 | #if the file ends with .sh 40 | if [ ${1: -3} == ".sh" ]; then 41 | echo 'App command line is a shell script, will execute this script as startup script' 42 | chmod +x $1 43 | oryxArgs+=" -userStartupCommand $1" 44 | else 45 | echo "$1 file exists on disk, reading its contents to run as startup arguments" 46 | echo "Contents of startupScript: $fileContents" 47 | oryxArgs+=" -userStartupCommand '$fileContents'" 48 | fi 49 | else 50 | echo 'App command line is not a file on disk, using it as the startup command.' 51 | oryxArgs+=" -userStartupCommand '$1'" 52 | fi 53 | else 54 | oryxArgs+=" -userStartupCommand '$@'" 55 | fi 56 | fi 57 | 58 | echo "Launching oryx with: $oryxArgs" 59 | #invoke oryx to generate startup script 60 | eval "oryx $oryxArgs" 61 | chmod +x /opt/startup/startup.sh 62 | #launch startup script 63 | /opt/startup/startup.sh 64 | 65 | 66 | -------------------------------------------------------------------------------- /3.7/sshd_config: -------------------------------------------------------------------------------- 1 | # This is ssh server systemwide configuration file. 2 | # 3 | # /etc/sshd_config 4 | 5 | Port SSH_PORT 6 | ListenAddress 0.0.0.0 7 | LoginGraceTime 180 8 | X11Forwarding yes 9 | Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr 10 | MACs hmac-sha1,hmac-sha1-96 11 | StrictModes yes 12 | SyslogFacility DAEMON 13 | PasswordAuthentication yes 14 | PermitEmptyPasswords no 15 | PermitRootLogin yes 16 | Subsystem sftp internal-sftp 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Image for Python 2 | ## Overview 3 | This Python Docker image is built for [Azure Web App on Linux](https://docs.microsoft.com/en-us/azure/app-service-web/app-service-linux-intro). 4 | 5 | ## Components 6 | This Docker image contains the following components: 7 | 8 | 1. Python **3.6.1** 9 | 2. Requests 10 | 3. Nginx **1.10.0** 11 | 4. uWSGI **2.0.15** 12 | 5. Psycopg2 **2.7.1** 13 | 6. Pip **9.0.1** 14 | 7. SSH 15 | 8. Azure SDK 16 | 9. Flask 17 | 10. Django **1.11.5** 18 | 19 | Ubuntu 16.04 is used as the base image. 20 | 21 | The stack of components: 22 | ``` 23 | Browser <-> nginx <-> /tmp/uwsgi.sock <-> uWSGI <-> Your Python app <-> Psycopg2 <-> remote PostgreSQL database 24 | ``` 25 | 26 | ## Features 27 | This docker image enables you to: 28 | - run your Python app on **Azure Web App on Linux**; 29 | - connect you Python app to a remote PostgreSQL database; 30 | - ssh to the docker container via the URL like below; 31 | ``` 32 | https://.scm.azurewebsites.net/webssh/host 33 | ``` 34 | 35 | ## Predefined Nginx Locations 36 | This docker image defines the following nginx locations for your static files. 37 | - /images 38 | - /css 39 | - /js 40 | - /static 41 | 42 | For more information, see [nginx default site conf](./3.6.1/nginx-default-site). 43 | 44 | ## uWSGI INI 45 | This docker image contains a default uWSGI ini file which is placed under /etc/uwsgi and invoked like below: 46 | ``` 47 | uwsgi --uid www-data --gid www-data --ini=$UWSGI_INI_DIR/uwsgi.ini 48 | ``` 49 | 50 | You can customeize this ini file, and upload to /etc/uwsgi to overwrite. 51 | 52 | This docker image also contains a uWSGI ini file for Django, which names uwsgi_django.ini. You can customeize it and upload to /etc/uwsgi to overwrite uwsgi.ini. 53 | 54 | ## Startup Log 55 | The startup log file (**entrypoint.log**) is placed under the folder /home/LogFiles. 56 | 57 | ## How to Deploy Django Project 58 | 1. login the instance via the url like below: 59 | ``` 60 | https://.scm.azurewebsites.net/webssh/host 61 | ``` 62 | 2. CD your location (For example /home/site/wwwroot), Run the command below to start a new project (For example project name is hello), Then cd project location, update settings.py as need. 63 | ``` 64 | python /usr/local/bin/django-admin.py startproject hello 65 | ``` 66 | 3. If your django project is exist, you can just upload it, for example to the location /home/site/wwwroot. 67 | 4. update /etc/uwsgi/uwsgi.ini per the requirements of your project. You can find a sample 68 | /tmp/uwsgi_django.ini. Reference: [How to use Django with uWSGI](https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/uwsgi/) 69 | 5. Run the command below to start uWSGI service 70 | ``` 71 | uwsgi --uid www-data --gid www-data –ini=/etc/uwsgi/uwsgi.ini 72 | ``` 73 | -------------------------------------------------------------------------------- /buildall.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -x -e 3 | 4 | buildnumber=${4-$(date -u +"%y%m%d%H%M")} 5 | 6 | docker build --no-cache -t "$1"/python:2.7_"$buildnumber" --file 2.7/Dockerfile 2.7 7 | docker build --no-cache -t "$1"/python:3.6_"$buildnumber" --file 3.6/Dockerfile 3.6 8 | docker build --no-cache -t "$1"/python:3.7_"$buildnumber" --file 3.7/Dockerfile 3.7 9 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | --------------------------- 4 | * [ ] Are these changes auto-generated from [python-template](https://github.com/Azure-App-Service/python-template) 5 | * [ ] Have you made the same changes to [python-template](https://github.com/Azure-App-Service/python-template) 6 | -------------------------------------------------------------------------------- /testapps/django/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-App-Service/python/cfbe139a1103c0613cc02c37d0ac2a980696b846/testapps/django/db.sqlite3 -------------------------------------------------------------------------------- /testapps/django/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /testapps/django/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-App-Service/python/cfbe139a1103c0613cc02c37d0ac2a980696b846/testapps/django/mysite/__init__.py -------------------------------------------------------------------------------- /testapps/django/mysite/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-App-Service/python/cfbe139a1103c0613cc02c37d0ac2a980696b846/testapps/django/mysite/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /testapps/django/mysite/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-App-Service/python/cfbe139a1103c0613cc02c37d0ac2a980696b846/testapps/django/mysite/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /testapps/django/mysite/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-App-Service/python/cfbe139a1103c0613cc02c37d0ac2a980696b846/testapps/django/mysite/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /testapps/django/mysite/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-App-Service/python/cfbe139a1103c0613cc02c37d0ac2a980696b846/testapps/django/mysite/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /testapps/django/mysite/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for mysite project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '$kke6#ra&vwz4fyjg44i&_ywb7qz_zxg*ljlw%+gb2rlhz@$bl' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | ] 41 | 42 | MIDDLEWARE = [ 43 | 'django.middleware.security.SecurityMiddleware', 44 | 'django.contrib.sessions.middleware.SessionMiddleware', 45 | 'django.middleware.common.CommonMiddleware', 46 | 'django.middleware.csrf.CsrfViewMiddleware', 47 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 48 | 'django.contrib.messages.middleware.MessageMiddleware', 49 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 50 | ] 51 | 52 | ROOT_URLCONF = 'mysite.urls' 53 | 54 | TEMPLATES = [ 55 | { 56 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 57 | 'DIRS': [], 58 | 'APP_DIRS': True, 59 | 'OPTIONS': { 60 | 'context_processors': [ 61 | 'django.template.context_processors.debug', 62 | 'django.template.context_processors.request', 63 | 'django.contrib.auth.context_processors.auth', 64 | 'django.contrib.messages.context_processors.messages', 65 | ], 66 | }, 67 | }, 68 | ] 69 | 70 | WSGI_APPLICATION = 'mysite.wsgi.application' 71 | 72 | 73 | # Database 74 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 75 | 76 | DATABASES = { 77 | 'default': { 78 | 'ENGINE': 'django.db.backends.sqlite3', 79 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 80 | } 81 | } 82 | 83 | 84 | # Password validation 85 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 86 | 87 | AUTH_PASSWORD_VALIDATORS = [ 88 | { 89 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 90 | }, 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 99 | }, 100 | ] 101 | 102 | 103 | # Internationalization 104 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 105 | 106 | LANGUAGE_CODE = 'en-us' 107 | 108 | TIME_ZONE = 'UTC' 109 | 110 | USE_I18N = True 111 | 112 | USE_L10N = True 113 | 114 | USE_TZ = True 115 | 116 | 117 | # Static files (CSS, JavaScript, Images) 118 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 119 | 120 | STATIC_URL = '/static/' 121 | -------------------------------------------------------------------------------- /testapps/django/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | ] 22 | -------------------------------------------------------------------------------- /testapps/django/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /testapps/django/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==2.0.7 2 | pytz==2018.5 3 | -------------------------------------------------------------------------------- /testapps/flask/application.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route("/") 6 | 7 | def hello(): 8 | return "Hello from Flask!!" 9 | 10 | -------------------------------------------------------------------------------- /testapps/flask/requirements.txt: -------------------------------------------------------------------------------- 1 | click==6.7 2 | Flask==1.0.2 3 | itsdangerous==0.24 4 | Jinja2==2.10 5 | MarkupSafe==1.0 6 | pkg-resources==0.0.0 7 | Werkzeug==0.14.1 8 | --------------------------------------------------------------------------------