diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4bcd78b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# FOSSology Dockerfile +# Copyright Siemens AG 2016, fabio.huser@siemens.com +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. +# +# Description: Docker container image recipe + +FROM debian:stable + +MAINTAINER Fossology + +WORKDIR /fossology +ADD . . + +RUN apt-get update && \ + apt-get install -y lsb-release sudo postgresql php5-curl libpq-dev libdbd-sqlite3-perl libspreadsheet-writeexcel-perl && \ + /fossology/utils/fo-installdeps -e -y && \ + rm -rf /var/lib/apt/lists/* + +RUN curl -sS https://getcomposer.org/installer | php && \ + mv composer.phar /usr/local/bin/composer + +RUN /fossology/install/scripts/install-spdx-tools.sh + +RUN /fossology/install/scripts/install-ninka.sh + +RUN make install + +RUN cp /fossology/install/src-install-apache-example.conf /etc/apache2/conf-available/fossology.conf && \ + ln -s /etc/apache2/conf-available/fossology.conf /etc/apache2/conf-enabled/fossology.conf + +RUN /fossology/install/scripts/php-conf-fix.sh --overwrite + +EXPOSE 80 + +RUN chmod +x /fossology/docker-entrypoint.sh +ENTRYPOINT ["/fossology/docker-entrypoint.sh"] diff --git a/README.md b/README.md index d1314445..0d8a882f 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,78 @@ # FOSSology [![Travis-CI Build Status](https://travis-ci.org/fossology/fossology.png)](https://travis-ci.org/fossology/fossology/) [![Stories in Ready](https://badge.waffle.io/fossology/fossology.svg?label=ready&title=Ready)](http://waffle.io/fossology/fossology) [![Coverage Status](https://coveralls.io/repos/github/fossology/fossology/badge.svg?branch=master)](https://coveralls.io/github/fossology/fossology?branch=master) ## About FOSSology is a open source license compliance software system and toolkit. As a toolkit you can run license, copyright and export control scans from the command line. As a system, a database and web ui are provided to give you a compliance workflow. In one click you can generate an SPDX file, or a ReadMe with all the copyrights notices from your software. FOSSology deduplication means that you can scan an entire distro, rescan a new version, and only the changed files will get rescanned. This is a big time saver for large projects. [Check out Who Uses FOSSology!](http://www.fossology.org/projects/fossology/wiki/WhoUsesFOSSology) FOSSology does not give legal advice. http://fossology.org/ ## Installation FOSSology is available for multiple versions of Linux. There are installation packages for Debian, RHEL/CentOS, Ubuntu, and Fedora, and a source tarball available from the fossology.org site. See http://fossology.org/releases For installation instructions see http://www.fossology.org/projects/fossology/wiki +## Docker +FOSSology comes with a Dockerfile allowing the containerized execution +both as single instance or in combination with an external PostgreSQL database. +**Note:** It is strongly recommended to use an external database for production +use, since the the standalone image does not take care of data persistency. + +A pre-built Docker image is available from [Docker Hub](https://hub.docker.com/r/fossology/fossology/) and can be run using following command: +``` sh +docker run -p 8081:80 fossology/fossology +``` + +Execution with external database container can be done using Docker Compose. +The Docker Compose file is located under the `/install` folder can can be run using following command: +``` sh +cd install +docker-compose up +``` + +The Docker image allows configuration of it's database connection over a set of environment variables. + +- **FOSSOLOGY_DB_HOST:** Hostname of the PostgreSQL database server. + An integrated PostgreSQL instance is used if not defined or set to `localhost`. +- **FOSSOLOGY_DB_NAME:** Name of the PostgreSQL database. Defaults to `fossology`. +- **FOSSOLOGY_DB_USER:** User to be used for PostgreSQL connection. Defaults to `fossy`. +- **FOSSOLOGY_DB_PASSWORD:** Password to be used for PostgreSQL connection. Defaults to `fossy`. + ## Documentation We are currently migrating our documentation to github. At this stage you can find general documentation at: http://www.fossology.org/projects/fossology/wiki/User_Documentation and developer docs here on [github](https://github.com/fossology/fossology/wiki) ## Support Mailing lists, FAQs, Release Notes, and other useful info is available by clicking the documentation tab on the project website. We encourage all users to join the mailing list and participate in discussions. There is also a #fossology IRC channel on the freenode IRC network if you'd like to talk to other FOSSology users and developers. See [Contact Us](http://www.fossology.org/projects/fossology/wiki/Contact_Us) ## Contributing We really like contributions in several forms, see [CONTRIBUTING.md](CONTRIBUTING.md) ## License FOSSology is licensed under [GPL-2.0](https://tldrlegal.com/license/gnu-general-public-license-v2) ## Screenshots ![Concluding a license](/examples/Concludeb.jpg) ![Browsing](/examples/Browseb.jpg) ![LicenseBrowser](/examples/LicenseBrowserb.jpg) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..d4fa10d7 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# FOSSology docker-entrypoint script +# Copyright Siemens AG 2016, fabio.huser@siemens.com +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. +# +# Description: startup helper script for the FOSSology Docker container + +db_host="localhost" +db_name="fossology" +db_user="fossy" +db_password="fossy" + +if [ "$FOSSOLOGY_DB_HOST" ]; then + db_host="$FOSSOLOGY_DB_HOST" +fi +if [ "$FOSSOLOGY_DB_NAME" ]; then + db_name="$FOSSOLOGY_DB_NAME" +fi +if [ "$FOSSOLOGY_DB_USER" ]; then + db_user="$FOSSOLOGY_DB_USER" +fi +if [ "$FOSSOLOGY_DB_PASSWORD" ]; then + db_password="$FOSSOLOGY_DB_PASSWORD" +fi + +testForPostgres(){ + PGPASSWORD=$db_password psql -h "$db_host" "$db_name" "$db_user" -c '\l' >/dev/null + return $? +} +until testForPostgres; do + >&2 echo "Postgres is unavailable - sleeping" + sleep 1 +done + +# Write configuration +cat < /usr/local/etc/fossology/Db.conf +dbname=$db_name; +host=$db_host; +user=$db_user; +password=$db_password; +EOM + +# Startup DB if needed +if [ "$db_host" = 'localhost' ]; then + echo '*****************************************************' + echo 'WARNING: No database host was set and therefore the' + echo 'internal database without persistency will be used.' + echo 'THIS IS NOT RECOMENDED FOR PRODUCTIVE USE!' + echo '*****************************************************' + /etc/init.d/postgresql start +fi + +# Setup environment +/usr/local/lib/fossology/fo-postinstall + +# Start Fossology +echo +echo 'Fossology initialisation complete; Starting up...' +echo +/etc/init.d/fossology start +/usr/sbin/apache2ctl -D FOREGROUND diff --git a/install/db/dbcreate.in b/install/db/dbcreate.in index 6efe349a..69b1af2c 100644 --- a/install/db/dbcreate.in +++ b/install/db/dbcreate.in @@ -1,41 +1,46 @@ #!/bin/bash # FOSSology dbcreate script # Copyright (C) 2008-2012 Hewlett-Packard Development Company, L.P. # # This script checks to see if the the fossology db exists and if not # then creates it. +if [ "$FOSSOLOGY_DB_HOST" ]; then + echo "NOTE: using external DB on host $FOSSOLOGY_DB_HOST" + exit 0 +fi + echo "*** Setting up the FOSSology database ***" # At some point this is where we could dynamically set the db password # first check that postgres is running su postgres -c 'echo \\q|psql' if [ $? != 0 ]; then echo "ERROR: postgresql isn't running" exit 1 fi # then check to see if the db already exists su postgres -c "psql --tuples-only --command \"select * from pg_database where datname = 'fossology';\""|grep fossology >/dev/null 2>&1 if [ $? = 0 ]; then echo "NOTE: fossology database already exists, not creating" echo "*** Checking for plpgsql support ***" su postgres -c 'createlang -l fossology' |grep -q plpgsql if [ $? = 0 ]; then echo "NOTE: plpgsql already exists in fossology database, good" else echo "NOTE: plpgsql doesn't exist, adding" su postgres -c 'createlang plpgsql fossology' if [ $? != 0 ]; then echo "ERROR: failed to add plpgsql to fossology database" fi fi else echo "*** Initializing database ***" su postgres -c "psql < {$LIBEXECDIR}/fossologyinit.sql" if [ $? != 0 ] ; then echo "ERROR: Database failed during configuration.\n" exit 1 fi fi diff --git a/install/docker-compose.yml b/install/docker-compose.yml new file mode 100644 index 00000000..3b250ac2 --- /dev/null +++ b/install/docker-compose.yml @@ -0,0 +1,29 @@ +# FOSSology Docker Compose file +# Copyright Siemens AG 2016, fabio.huser@siemens.com +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. +# +# Description: Recipe for setting up a multi container FOSSology +# Docker setup with separate Database instance + +web: + build: .. + environment: + - FOSSOLOGY_DB_HOST=db + - FOSSOLOGY_DB_NAME=fossology + - FOSSOLOGY_DB_USER=fossy + - FOSSOLOGY_DB_PASSWORD=fossy + ports: + - 8081:80 + links: + - db +db: + image: postgres + environment: + - POSTGRES_DB=fossology + - POSTGRES_USER=fossy + - POSTGRES_PASSWORD=fossy + - POSTGRES_INITDB_ARGS='-E SQL_ASCII' diff --git a/utils/fo-installdeps b/utils/fo-installdeps index 2f4418a0..89707ee9 100755 --- a/utils/fo-installdeps +++ b/utils/fo-installdeps @@ -1,301 +1,306 @@ # FOSSology fo-installdeps script # Copyright (C) 2008-2014 Hewlett-Packard Development Company, L.P. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # version 2 as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # This script helps you install build and runtime dependencies on a system. # It is NOT indented to replace package dependencies, it's just a tool to # make testing the "upstream" build and install process. If you determine # this script isn't installing something you think it should, consult # the packaging metadata for the system in question as that is the # canonical location for such info, then fix it there first and also # update this file and the INSTALL document. ## Options parsing and setup # parse options OPTS=`getopt -o rbeohy --long runtime,buildtime,everything,offline,help -n 'fo-installdeps' -- "$@"` if [ $? != 0 ]; then echo "ERROR: Bad option specified." OPTS="--help" fi eval set -- "$OPTS" # if no options then do everything if [ "$OPTS" = " --" ]; then EVERYTHING=1 fi # # Don't show the -y option. Should only be used for install testing, as using # it without being careful can destroy your system. # YesOpt= #Default should be installation with internet connection OFFLINE=0 while true; do case "$1" in -r|--runtime) RUNTIME=1; shift;; -b|--buildtime) BUILDTIME=1; shift;; -e|--everything) EVERYTHING=1; shift;; -o|--offline) OFFLINE=1; shift;; - -y) + -y) YesOpt=" -y "; shift;; -h|--help) echo "Usage: fo-installdeps [options]"; echo " -r or --runtime : install runtime dependencies" echo " -b or --buildtime : install buildtime dependencies" echo " -e or --everything : install all dependencies (default)" echo " -o or --offline : do not run composer installation" echo " -y : Automatic yes to prompts" echo " -h or --help : this help text" exit;; --) shift; break;; *) echo "ERROR: option $1 not recognised"; exit 1;; esac done # This must run as root. if [ `id -u` != "0" ] ; then echo "ERROR: fo-installdeps must run as root." echo "Aborting." exit 1 fi if [ $EVERYTHING ]; then echo "*** Installing both runtime and buildtime dependencies ***" RUNTIME=1 BUILDTIME=1 fi # figure out what distro we're on DISTRO=`lsb_release -is` CODENAME=`lsb_release -cs` if [ "$?" != "0" ]; then echo "ERROR: this program requires the lsb_release command. On Debian based" echo " systems this is probably in the lsb-release package, on" echo " Fedora/RedHat systems it is probably the redhat-lsb package." exit 1 fi ######################################################################## echo "install core dependencies" if [ $BUILDTIME ]; then echo "*** Installing $DISTRO buildtime dependencies ***"; case "$DISTRO" in Debian|Ubuntu|LinuxMint) echo "DB: Installing build essential....." apt-get $YesOpt install \ libmxml-dev curl libxml2-dev libcunit1-dev \ build-essential libtext-template-perl subversion rpm librpm-dev libmagic-dev libglib2.0 libboost-regex-dev libboost-program-options-dev POSTGRE=`dpkg --get-selections|grep postgresql-server-dev` if [ -z "$POSTGRE" ]; then ## if postgresql-server-dev is installed case "$CODENAME" in lenny|hardy) apt-get $YesOpt install $YesOpt postgresql-server-dev-8.3;; squeeze) apt-get $YesOpt install $YesOpt postgresql-server-dev-8.4;; wheezy) apt-get $YesOpt install $YesOpt postgresql-server-dev-9.1;; sid) apt-get $YesOpt install $YesOpt postgresql-server-dev-8.4;; lucid|natty) apt-get $YesOpt install postgresql-server-dev-8.4;; isadora) apt-get $YesOpt install postgresql-server-dev-8.4;; precise|oneiric|quantal|raring|saucy) apt-get $YesOpt install postgresql-server-dev-9.1;; trusty|jessie) apt-get $YesOpt install postgresql-server-dev-9.3;; *) echo "ERROR: Unknown or Unsupported $DISTRO release, please report to the mailing list"; exit 1;; esac fi ;; Fedora) # F8=Werwolf F9=Sulphur F10=Cambridge F11=Leonidas F12=Constantine dev=Rawhide if [ $YesOpt ]; then YesOpt='-y' - fi + fi yum $YesOpt groupinstall "Development Tools" yum $YesOpt install \ perl-Text-Template subversion \ postgresql-devel file-devel \ libxml2 \ - boost-devel + boost-devel ;; Mandriva) # 2008.1 tested urpmi \ postgresql-devel \ libxml2 \ perl-Text-Template subversion gcc make perl ;; RedHatEnterprise*|CentOS) # 4=Nahant* 5=Tikanga* if [ $YesOpt ]; then YesOpt='-y' - fi + fi yum $YesOpt install \ postgresql-devel \ gcc make file libxml2 \ perl-Text-Template subversion \ boost-devel ;; *) echo "ERROR: distro not recognised, please fix and send a patch"; exit 1;; esac fi ######################################################################## if [ $RUNTIME ]; then echo "*** Installing $DISTRO runtime dependencies ***"; echo "*** For optional email notifications a Mail Transport Agent Must be ***"; echo "*** installed. Consult with your system administrator. Or try ***"; echo "*** apt-get install mail-transport-agent, pick one and install it***"; case "$DISTRO" in Debian|Ubuntu|LinuxMint) echo "doing runtime" apt-get $YesOpt install apache2 libapache2-mod-php5 apt-get $YesOpt install php5 php5-pgsql php-pear php5-cli \ libxml2 \ - binutils php-gettext + binutils php-gettext \ + cabextract cpio sleuthkit genisoimage \ + poppler-utils upx-ucl \ + unrar-free unzip p7zip-full p7zip wget \ + subversion git \ + dpkg-dev POSTGRE=`dpkg --get-selections|grep postgresql-8.4` if [ -z "$POSTGRE" ]; then ## if postgresql-server-dev is installed case "$CODENAME" in squeeze) apt-get $YesOpt install postgresql-8.4;; wheezy) apt-get $YesOpt install postgresql-9.1;; sid) apt-get $YesOpt install postgresql-8.4;; lucid|natty) apt-get $YesOpt install postgresql-8.4;; isadora) apt-get $YesOpt install postgresql-8.4;; precise|oneiric|quantal|raring|saucy) apt-get $YesOpt install postgresql-9.1;; trusty|jessie) apt-get $YesOpt install postgresql-9.3;; *) echo "ERROR: Unknown or Unsupported $DISTRO release, please report to the mailing list"; exit 1;; esac fi ;; Mandriva) [ $AGENT ] || urpmi postgresql-server httpd urpmi php php-pear php-pgsql postgresql \ libxml2 \ cabextract genisoimage upx sleuthkit binutils bzip2 cpio \ mkisofs p7zip poppler-utils rpm tar unzip gzip echo "NOTE: unrar is available in PLF, please install it via urpmi if" echo " the repository is configured or from http://plf.zarb.org/packages.php" ;; Fedora) if [ $YesOpt ]; then YesOpt='-y' - fi + fi yum $YesOpt install postgresql-server httpd yum $YesOpt install \ postgresql \ php php-pear php-pgsql php-process php-xml php-mbstring\ smtpdaemon \ libxml2 \ - binutils + binutils # enable, possible init, and start postgresql /sbin/chkconfig postgresql on if [ ! -f /var/lib/pgsql/data/PG_VERSION ]; then /sbin/service postgresql initdb fi /sbin/service postgresql start # F8=Werwolf F9=Sulphur F10=Cambridge F11=Leonidas F12=Constantine dev=Rawhide case "$CODENAME" in Werwolf|Sulphur) echo "NOTE: sleuthkit and unrar is not available in Fedora release $CODENAME,"; echo " please install from upstream sources.";; Cambridge|Rawhide|Leonidas|Constantine) yum $YesOpt install sleuthkit echo "NOTE: unrar is not available in Fedora release $CODENAME," echo " please install from upstream sources." ;; *) echo "ERROR: Unknown Fedora release, please report a bug. Attempting to install anyway"; yum install sleuthkit echo "NOTE: unrar is not available in Fedora release $CODENAME," echo " please install from upstream sources." ;; esac ;; RedHatEnterprise*|CentOS) # 4=Nahant* 5=Tikanga* if [ $YesOpt ]; then YesOpt='-y' - fi + fi yum $YesOpt install postgresql-server httpd yum $YesOpt install \ postgresql \ php php-pear php-pgsql php-process\ smtpdaemon \ file libxml2 \ - binutils + binutils echo "NOTE: cabextract, sleuthkit, upx, and unrar are not" echo " available in RHEL please install from upstream sources.";; *) echo "ERROR: distro not recognised, please fix and send a patch"; exit 1;; esac - + which composer if [ $? -eq 0 ]; then if [ $OFFLINE -eq 0 ]; then composer selfupdate else echo "WARNING: composer is not updated due to the offline switch" fi else if [ $OFFLINE -eq 0 ]; then curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer else echo "WARNING: composer is not installed, and the installer does not install it due to the offline switch" echo "Please run the equivalent of 'curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer'" fi fi fi ######################################################################## # install dependencies of modules via running $mods_enabled_dir/$mod_name/mod_deps install_mod_deps() { mods_dir=$1 for mod_deps in `find -L $mods_dir -name mod_deps`; do if [ -f $mod_deps ]; then echo "run $mod_deps to install dependencies" /bin/sh $mod_deps $options fi done } options="" if [ $BUILDTIME ]; then options='-b ' fi if [ $RUNTIME ]; then options="$options -r" fi if [ ! -z "$YesOpt" ]; then options="$options -y" fi -BASEDIR=$(dirname $0) +BASEDIR=$(dirname $0) mods_dir=$BASEDIR"/../src/" ## get the directory where fo-installdeps resides -install_mod_deps $mods_dir - +install_mod_deps $mods_dir + ########################################################################