From 898f70552e8fa936df88bd4bc405f8f39e5c32f7 Mon Sep 17 00:00:00 2001 From: "Areli, Fuss (af732p)" Date: Wed, 12 Sep 2018 16:28:11 +0300 Subject: Add docker and replace application server DCAE TOSCA APP add docker creation and replace application server Change-Id: I5d79994cb6b5b8bf18399ff65cbcfc84e6ec3958 Issue-ID: SDC-1756 Signed-off-by: Areli, Fuss (af732p) --- app/version.py | 2 +- app/web/gunicorn.conf | 9 +++++++ app/web/uwsgi.ini | 16 ------------- docker/Dockerfile | 34 ++++++++++++++++++++------ docker/Dockerfile.Base | 33 ++++++++----------------- nginx/nginx.conf | 44 +++++++++++++++++++++------------- pom.xml | 65 +++++++++++++++++++++++++++----------------------- 7 files changed, 110 insertions(+), 93 deletions(-) create mode 100644 app/web/gunicorn.conf delete mode 100644 app/web/uwsgi.ini diff --git a/app/version.py b/app/version.py index 1fb3765..bbd9e13 100644 --- a/app/version.py +++ b/app/version.py @@ -1 +1 @@ -__version__ = '1806.0.022118-SNAPSHOT' \ No newline at end of file +__version__ = '1.3.0' \ No newline at end of file diff --git a/app/web/gunicorn.conf b/app/web/gunicorn.conf new file mode 100644 index 0000000..1d12129 --- /dev/null +++ b/app/web/gunicorn.conf @@ -0,0 +1,9 @@ +#[gunicorn] +#user = '' +backlog = '5000' +bind = "unix:/run/gunicorn/tosca_server.sock" +chdir = '/srv' +errorlog = '/tmp/tosca_server_app-error.log' +loglevel = 'info' +pidfile = '/tmp/dcae-tosca-master.pid' +workers = 3 diff --git a/app/web/uwsgi.ini b/app/web/uwsgi.ini deleted file mode 100644 index c4cca12..0000000 --- a/app/web/uwsgi.ini +++ /dev/null @@ -1,16 +0,0 @@ -[uwsgi] -module = tosca_server:application -#plugin = python -chdir = /srv -master = True -processes = 2 -pidfile = /tmp/project-master.pid -vacuum = true -max-requests = 5000 -enable-threads = True -logto = /var/log/uwsgi/%n.log - -uid = dcae -socket = /run/uwsgi/tosca.sock -chown-socket = dcae:nginx -chmod-socket = 664 diff --git a/docker/Dockerfile b/docker/Dockerfile index fbfa7df..fcbf836 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,34 @@ -FROM onap/dcae-tosca-base:1.0.4 - -RUN apk add --no-cache \ +FROM python:3.5-alpine + +RUN apk add --update --no-cache \ + autoconf \ + gcc \ + libc-dev \ + linux-headers \ + nginx \ curl \ + && pip install --upgrade setuptools \ + && pip install gunicorn + +RUN apk del \ + autoconf \ + gcc \ + libc-dev \ + linux-headers \ && : -COPY ./app /srv/ +RUN mkdir -p /run/nginx /run/gunicorn && \ + touch /run/nginx/nginx.pid && \ + chown -R nginx:nginx /var/log/nginx /run/nginx /run/gunicorn && \ + chmod 0775 /var/log/nginx && \ + chmod 0770 /var/lib/nginx/tmp /run/gunicorn && \ + chmod 0664 /run/nginx/nginx.pid + +COPY app /srv/ -COPY ./docker/docker-entrypoint.sh /srv/ +COPY docker/docker-entrypoint.sh /srv/ -COPY ./nginx/nginx.conf /etc/nginx/nginx.conf +COPY nginx/nginx.conf /etc/nginx/nginx.conf RUN chmod +x /srv/tosca_server.py && \ chmod +x /srv/docker-entrypoint.sh @@ -17,4 +37,4 @@ RUN pip3 install -r /srv/requirements.txt EXPOSE 8085 -ENTRYPOINT ["/srv/docker-entrypoint.sh", "/usr/local/bin/uwsgi", "--ini", "/srv/web/uwsgi.ini"] +ENTRYPOINT ["/srv/docker-entrypoint.sh", "/usr/local/bin/gunicorn", "-c", "/srv/web/gunicorn.conf" , "tosca_server:application"] diff --git a/docker/Dockerfile.Base b/docker/Dockerfile.Base index 0f3b85d..ec58e92 100644 --- a/docker/Dockerfile.Base +++ b/docker/Dockerfile.Base @@ -1,34 +1,15 @@ FROM python:3.5-alpine -ENV http_proxy http://one.proxy.att.com:8080 -ENV https_proxy http://one.proxy.att.com:8080 -ENV GROUPID=1000 \ - USERNAME=dcae \ - USERID=1001 \ - USER_HOME=/home/dcae - -RUN apk add --no-cache \ +RUN apk add --update --no-cache \ autoconf \ gcc \ libc-dev \ linux-headers \ nginx \ - && : - -RUN pip install --upgrade setuptools && \ - pip install uwsgi==2.0.15 - -RUN mkdir -p \ - /var/log/uwsgi \ - /run/uwsgi \ - /srv - -RUN addgroup -g ${GROUPID} -S ${USERNAME} - -RUN adduser -S -G ${USERNAME} -u ${USERID} -s /bin/bash -h ${USER_HOME} ${USERNAME} - -RUN chown ${USERNAME}:nginx /run/uwsgi + curl \ + && pip install --upgrade setuptools \ + && pip install gunicorn RUN apk del \ autoconf \ @@ -37,3 +18,9 @@ RUN apk del \ linux-headers \ && : +RUN mkdir -p /run/nginx /run/gunicorn && \ + touch /run/nginx/nginx.pid && \ + chown -R nginx:nginx /var/log/nginx /run/nginx /run/gunicorn && \ + chmod 0775 /var/log/nginx && \ + chmod 0770 /var/lib/nginx/tmp /run/gunicorn && \ + chmod 0664 /run/nginx/nginx.pid diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 363e205..4ab113a 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,30 +1,42 @@ -#user nginx; -worker_processes 1; -error_log logs/error.log; -error_log logs/error.log notice; -error_log logs/error.log info; +error_log /var/log/nginx/error.log debug; -pid nginx.pid; +http { + limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; -events { - worker_connections 4096; -} + client_body_temp_path /tmp/nginx 1 2; + proxy_temp_path /tmp/nginx-proxy; + fastcgi_temp_path /tmp/nginx-fastcgi; + uwsgi_temp_path /tmp/nginx-uwsgi; + scgi_temp_path /tmp/nginx-scgi; -http { + upstream tosca_server { + server unix:/run/gunicorn/tosca_server.sock fail_timeout=0; + } + server { - listen 8085; - server_name localhost; - charset utf-8r; + listen 8085 ; + charset utf-8; + client_max_body_size 75M; # adjust to taste + + access_log /var/log/nginx/nginx-access.log; location / { - include uwsgi_params; - uwsgi_pass unix:/run/uwsgi/tosca.sock; - + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://tosca_server; + + limit_req zone=one; } } +} #http +events { + worker_connections 4096; ## Default: 1024 } diff --git a/pom.xml b/pom.xml index 116d7df..15852ec 100644 --- a/pom.xml +++ b/pom.xml @@ -2,46 +2,44 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - - org.onap.oparent - oparent - 1.0.0-SNAPSHOT - - org.onap.dcae.dcae-tosca-app + org.onap.dcae.dcae-tosca-app dcae-tosca-app pom - 1.0.0-SNAPSHOT + 1.3.0-SNAPSHOT dcae-d tosca-lab - - /content/sites/site/org/onap/dcae/${project.artifactId}/${project.version} - - ${maven.build.timestamp} - yyyy.MM.dd.HH.mm - - ${project.version}-${maven.build.timestamp} - ${project.version}-latest - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest ${project.version} true - docker + + false + + - + + /content/sites/site/org/onap/dcae/${project.artifactId}/${project.version} + + ${maven.build.timestamp} yyyyMMdd'T'HHmm + + + 0.23.0 + nexus3.onap.org:10001 + docker + docker + onap ${project.version}-${maven.build.timestamp} ${project.version}-latest ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - false - + + @@ -95,14 +93,23 @@ io.fabric8 docker-maven-plugin - 0.19.1 + ${fabric8.version} true 1.23 - nexus3.onap.org:10003 + + ${docker.registry} + + + ${docker.username} + ${docker.password} + + + + - onap/dcae-tosca-app + ${docker.namespace}/dcae-tosca-app dcae-tosca-app true @@ -116,6 +123,7 @@ + clean-images @@ -129,7 +137,7 @@ generate-images - package + install build @@ -138,12 +146,8 @@ push-images deploy - build - push + push - - onap/dcae-tosca-app - @@ -158,3 +162,4 @@ + -- cgit 1.2.3-korg