diff options
-rw-r--r-- | app/version.py | 2 | ||||
-rw-r--r-- | app/web/gunicorn.conf | 9 | ||||
-rw-r--r-- | app/web/uwsgi.ini | 16 | ||||
-rw-r--r-- | docker/Dockerfile | 34 | ||||
-rw-r--r-- | docker/Dockerfile.Base | 33 | ||||
-rw-r--r-- | nginx/nginx.conf | 44 | ||||
-rw-r--r-- | pom.xml | 65 |
7 files changed, 110 insertions, 93 deletions
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 } @@ -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"> <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.oparent</groupId> - <artifactId>oparent</artifactId> - <version>1.0.0-SNAPSHOT</version> - </parent> - <groupId>org.onap.dcae.dcae-tosca-app </groupId> + <groupId>org.onap.dcae.dcae-tosca-app</groupId> <artifactId>dcae-tosca-app</artifactId> <packaging>pom</packaging> - <version>1.0.0-SNAPSHOT</version> + <version>1.3.0-SNAPSHOT</version> <name>dcae-d tosca-lab</name> <properties> - <!--nexus--> - <sitePath>/content/sites/site/org/onap/dcae/${project.artifactId}/${project.version}</sitePath> - <!--maven--> - <timestamp>${maven.build.timestamp}</timestamp> - <maven.build.timestamp.format>yyyy.MM.dd.HH.mm</maven.build.timestamp.format> - <!--docker--> - <docker.tag>${project.version}-${maven.build.timestamp}</docker.tag> - <docker.latest.tag>${project.version}-latest</docker.latest.tag> - <docker.staging.tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest</docker.staging.tag> <sonar.branch>${project.version}</sonar.branch> <sonar.skip>true</sonar.skip> </properties> - <profiles> <profile> <id>docker</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <properties> - <!-- Docker tags --> + <!--nexus--> + <sitePath>/content/sites/site/org/onap/dcae/${project.artifactId}/${project.version}</sitePath> + <!--maven--> + <timestamp>${maven.build.timestamp}</timestamp> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> + + <!--docker--> + <fabric8.version>0.23.0</fabric8.version> + <docker.registry>nexus3.onap.org:10001</docker.registry> + <docker.username>docker</docker.username> + <docker.password>docker</docker.password> + <docker.namespace>onap</docker.namespace> <docker.tag>${project.version}-${maven.build.timestamp}</docker.tag> <docker.latest.tag>${project.version}-latest</docker.latest.tag> <docker.staging.tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest</docker.staging.tag> </properties> - <activation> - <activeByDefault>false</activeByDefault> - </activation> + + <build> <plugins> <plugin> @@ -95,14 +93,23 @@ <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> - <version>0.19.1</version> + <version>${fabric8.version}</version> <configuration> <verbose>true</verbose> <apiVersion>1.23</apiVersion> - <registry>nexus3.onap.org:10003</registry> + + <registry>${docker.registry}</registry> + <authConfig> + <pull> + <username>${docker.username}</username> + <password>${docker.password}</password> + </pull> + </authConfig> + <images> + <image> - <name>onap/dcae-tosca-app</name> + <name>${docker.namespace}/dcae-tosca-app</name> <alias>dcae-tosca-app</alias> <build> <cleanup>true</cleanup> @@ -116,6 +123,7 @@ </image> </images> </configuration> + <executions> <execution> <id>clean-images</id> @@ -129,7 +137,7 @@ </execution> <execution> <id>generate-images</id> - <phase>package</phase> + <phase>install</phase> <goals> <goal>build</goal> </goals> @@ -138,12 +146,8 @@ <id>push-images</id> <phase>deploy</phase> <goals> - <goal>build</goal> - <goal>push</goal> + <goal>push</goal> </goals> - <configuration> - <image>onap/dcae-tosca-app</image> - </configuration> </execution> </executions> </plugin> @@ -158,3 +162,4 @@ </profile> </profiles> </project> + |