From: garciadeblas Date: Thu, 27 Sep 2018 16:03:45 +0000 (+0200) Subject: Deb package generation for LW-UI, including CICD Dockerfile X-Git-Tag: v5.0.0~22^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f5c330711bb7b31351f3739855e3f90be13f8506;p=osm%2FLW-UI.git Deb package generation for LW-UI, including CICD Dockerfile Change-Id: I0e39da2648ada82dfd907f4747db71d8b401dbf5 Signed-off-by: garciadeblas --- diff --git a/Dockerfile b/Dockerfile index e9d3030..f028c0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,11 @@ -FROM ubuntu:16.04 +# This Dockerfile is intented for devops and deb package generation +# +# Use Dockerfile.local for running osm/NBI in a docker container from source +# Use Dockerfile.fromdeb for running osm/NBI in a docker container from last stable package -WORKDIR /usr/src/app -COPY . /usr/src/app -RUN apt-get update -RUN apt-get install -y npm git python-pip nginx supervisor -RUN npm install -g bower -RUN ln -s /usr/bin/nodejs /usr/bin/node -RUN bower install --allow-root -RUN pip install -r requirements.txt -RUN pip install uwsgi +FROM ubuntu:16.04 -RUN echo "daemon off;" >> /etc/nginx/nginx.conf -COPY nginx-app.conf /etc/nginx/sites-available/default -COPY supervisor-app.conf /etc/supervisor/conf.d/ +RUN apt-get update && apt-get -y install git make libcurl4-gnutls-dev \ + libgnutls-dev debhelper apt-utils -# delete the copy of the database inside the container (if exists) -RUN rm -f db.sqlite3 - -ENV DJANGO_ENV=prod -RUN python manage.py makemigrations authosm -RUN python manage.py migrate -RUN python manage.py collectstatic --noinput - - -EXPOSE 80 - -CMD ["supervisord", "-n"] \ No newline at end of file diff --git a/build-debpkg.sh b/build-debpkg.sh new file mode 100755 index 0000000..b91cff9 --- /dev/null +++ b/build-debpkg.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Copyright 2018 Telefonica +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +PKG_DIRECTORIES="authosm instancehandler lib projecthandler sdnctrlhandler sf_t3d static template userhandler vimhandler" +PKG_FILES="bower.json django.ini LICENSE manage.py nginx-app.conf README.md requirements.txt supervisor-app.conf" +MDG_NAME=lightui +DEB_INSTALL=debian/osm-${MDG_NAME}.install +export DEBEMAIL="gerardo.garciadeblas@telefonica.com" +export DEBFULLNAME="Gerardo Garcia" + +PKG_VERSION=$(git describe --match "v*" --tags --abbrev=0) +PKG_VERSION_PREFIX=$(echo $PKG_VERSION | sed -e 's/v//g') +PKG_VERSION_POST=$(git rev-list $PKG_VERSION..HEAD | wc -l) +if [ "$PKG_VERSION_POST" -eq 0 ]; then + PKG_DIR="osm-${MDG_NAME}-${PKG_VERSION_PREFIX}" +else + PKG_DIR="osm-${MDG_NAME}-$PKG_VERSION_PREFIX.post${PKG_VERSION_POST}" +fi + +rm -rf $PKG_DIR +rm -f *.orig.tar.xz +rm -f *.deb +rm -f $DEB_INSTALL +mkdir -p $PKG_DIR + +for dir in $PKG_DIRECTORIES; do + ln -s $PWD/$dir $PKG_DIR/. + echo "$dir/* usr/share/osm-$MDG_NAME/$dir" >> $DEB_INSTALL +done +for f in $PKG_FILES; do + cp $f $PKG_DIR/. + echo "$f usr/share/osm-$MDG_NAME" >> $DEB_INSTALL +done +cp -R debian $PKG_DIR/. + +cd $PKG_DIR +dh_make -y --indep --createorig --a -c apache +dpkg-buildpackage -uc -us -tc -rfakeroot +cd - + diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..91167e7 --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: osm-lightui +Section: devel +Priority: optional +Maintainer: Gerardo Garcia +Build-Depends: debhelper (>=9) +Standards-Version: 3.9.6 +Homepage: http://osm.etsi.org + +Package: osm-lightui +Architecture: all +Depends: ${misc:Depends} +Description: Open Source MANO Light UI package ... diff --git a/devops-stages/stage-archive.sh b/devops-stages/stage-archive.sh index 9809bb9..3c47b96 100755 --- a/devops-stages/stage-archive.sh +++ b/devops-stages/stage-archive.sh @@ -1,2 +1,27 @@ #!/bin/sh +# Copyright 2018 Telefonica +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +MDG=LW-UI + +rm -rf pool +rm -rf dists +mkdir -p pool/$MDG +mv *.deb pool/$MDG/ + +mkdir -p dists/unstable/$MDG/binary-amd64/ +apt-ftparchive packages pool/$MDG > dists/unstable/$MDG/binary-amd64/Packages +gzip -9fk dists/unstable/$MDG/binary-amd64/Packages echo "ARCHIVE DONE" + diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh index 80fb644..43233cf 100755 --- a/devops-stages/stage-build.sh +++ b/devops-stages/stage-build.sh @@ -1,3 +1,3 @@ #!/bin/sh -#make clean all +./build-debpkg.sh echo "BUILD DONE" diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..c86c250 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,29 @@ +FROM ubuntu:16.04 + +WORKDIR /usr/share/osm-lightui +COPY . /usr/share/osm-lightui + +RUN apt-get update +RUN apt-get install -y npm git python-pip nginx supervisor +RUN npm install -g bower +RUN ln -s /usr/bin/nodejs /usr/bin/node +RUN bower install --allow-root +RUN pip install -r requirements.txt +RUN pip install uwsgi + +RUN echo "daemon off;" >> /etc/nginx/nginx.conf +COPY nginx-app.conf /etc/nginx/sites-available/default +COPY supervisor-app.conf /etc/supervisor/conf.d/ + +# delete the copy of the database inside the container (if exists) +RUN rm -f db.sqlite3 + +ENV DJANGO_ENV=prod +RUN python manage.py makemigrations authosm +RUN python manage.py migrate +RUN python manage.py collectstatic --noinput + + +EXPOSE 80 + +CMD ["supervisord", "-n"] diff --git a/nginx-app.conf b/nginx-app.conf index c5bbd68..75f4878 100644 --- a/nginx-app.conf +++ b/nginx-app.conf @@ -11,7 +11,7 @@ server { client_max_body_size 75M; location /static/ { - alias /usr/src/app/static/; + alias /usr/share/osm-lightui/static/; } location / { @@ -55,4 +55,4 @@ server { # log_not_found off; # access_log off; # } -} \ No newline at end of file +} diff --git a/supervisor-app.conf b/supervisor-app.conf index 0aa033e..1dabdea 100644 --- a/supervisor-app.conf +++ b/supervisor-app.conf @@ -1,6 +1,6 @@ [program:app-uwsgi] -command = /usr/local/bin/uwsgi --ini /usr/src/app/django.ini +command = /usr/local/bin/uwsgi --ini /usr/share/osm-lightui/django.ini environment=DJANGO_ENV="prod" [program:nginx-app] -command = /usr/sbin/nginx \ No newline at end of file +command = /usr/sbin/nginx