Commit 59101b58 authored by Buskermolen, Joost's avatar Buskermolen, Joost
Browse files

Modified to be suitable for Kubernetes

parent 522b0c90
......@@ -6,3 +6,4 @@ wsm.rest.sock
logs
.project
.pydevproject
.vscode
\ No newline at end of file
FROM ubuntu:16.04
MAINTAINER Luís de Sousa <luis.desousa@wur.nl>
FROM ubuntu:18.04
LABEL MAINTAINER Luís de Sousa <luis.desousa@wur.nl>
RUN apt update
RUN apt -y install python-pip python-dev nginx
RUN apt update && apt -y install python-pip python-dev nginx curl
RUN mkdir -p /var/www/wsm.rest
COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
WORKDIR /var/www/wsm.rest
COPY . .
RUN chmod +x configs/startup.sh
RUN pip install -r requirements.txt
ENTRYPOINT [ "configs/startup.sh" ]
# Expose port 80
EXPOSE 80
STOPSIGNAL SIGQUIT
HEALTHCHECK CMD curl --fail http://localhost:80 || exit 1
CMD ["nginx", "-g", "daemon off;"]
################### Usage #####################
# Build it
# docker build -t ldesousa/wsm.rest .
# Run command
# docker run -dit -v /var/www/wsm.rest:/var/www/wsm.rest -v /data/monoliths:/data/monoliths --name wsm.rest -p 8081:80 ldesousa/wsm.rest
# Set the correct database connection in common/secret.py
# Set the correct database connection in using environment variables or an env-file:
# Attach to the container and run the startup script
# docker attach wsm.rest
# sh /var/www/wsm.rest/configs/startup.sh
# Ctrl+P Ctrl+Q
# Run command with envfile
# docker run -dit --env-file /path/to/envfile -v /data/monoliths:/data/monoliths --name wsm.rest -p 8081:80 ldesousa/wsm.rest
# Declaring variables inline:
# docker run -dit -e DB_HOST=scomp1270.wurnet.nl -e DB_NAME=isric -e DB_USER=haas005 -e DB_PASSWORD=wur -e DB_PORT=5479 -v /data/monoliths:/data/monoliths --name wsm.rest -p 8081:80 ldesousa/wsm.rest
\ No newline at end of file
"""Password of database"""
"""This is just an example, change to the correct values and rename the file to
secret.py"""
DB={"host":"scomp1270.wurnet.nl","database":"isric", "user":"haas005", "password":"isis3543","port":"5479"}
\ No newline at end of file
"""Secrets will be read from environment variables, and have some example default values set."""
from os import environ
# Get environment variables and set default if none specified:
DB_HOST = environ.get("DB_HOST", "scomp1270.wurnet.nl")
DB_NAME = environ.get("DB_NAME", "isric")
DB_USER = environ.get("DB_USER", "haas005")
DB_PASSWORD = environ.get("DB_PASSWORD", "isis3543")
DB_PORT = environ.get("DB_PORT", "5479")
DB={"host":DB_HOST,"database":DB_NAME, "user":DB_USER, "password":DB_PASSWORD,"port":DB_PORT}
\ No newline at end of file
......@@ -2,6 +2,7 @@
cd /var/www/wsm.rest
mkdir logs
echo "Launching Gunicorn..."
nohup /usr/local/bin/gunicorn wsgi:app --workers 3 --bind unix:wsm.rest.sock -m 007 </dev/null >logs/gunicorn.log 2>&1 &
......@@ -9,9 +10,6 @@ echo "Setting up nginx config."
rm -f /etc/nginx/sites-enabled/default
cp /var/www/wsm.rest/configs/wsm.rest.nginx /etc/nginx/sites-enabled/wsm.rest
echo "Launching nginx..."
nohup nginx </dev/null >logs/nginx.log 2>&1 &
# Wait a little for Gunicorn to set up
sleep 2
......@@ -19,3 +17,4 @@ echo "Fixing access to socket."
chown www-data:www-data /var/www/wsm.rest/wsm.rest.sock
echo "All done. Good to go!"
exec "$@"
\ No newline at end of file
server {
listen 80;
server_name server_domain_or_IP;
server_name localhost;
access_log /dev/stdout;
error_log /dev/stderr;
location / {
include proxy_params;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment