Code Monkey home page Code Monkey logo

sw360chores's Introduction

SW360 chores


This repo is currently outdated

There is an official docker deployment in SW360 Page


This repository contains code which sets up a Docker based deployment and development infrastructure for SW360. It simplifies and abstracts the configuration. It also contains tools for backing up and restoring of container states as well as for exporting and importing docker images.

Prerequisites

You need

  • the perl interpreter to run ./sw360chores.pl
  • git which is used in some prepare scripts
  • a current version of docker (min 1.30) [https://docs.docker.com/]
  • docker-compose (min 1.21) [https://docs.docker.com/compose/install/]
  • some disk space at /var:
  • Internet connection at container build time to download docker images as well as Maven dependencies and internet connection at runtime to allow cve-search to crawl various external sources for security vulnerability entries.

Overview

A full setup together with a dockerized FOSSology on another host could look like this: Overview of the topology

Usage

This project should be controlled via the script sw360chores.pl.

Simple and quick startup

To build all images and start them simply use

./sw360chores.pl --build -- up

To get a fully configured SW360 running, you need to compile the wars and place them into ./_deploy. This can be done from within the SW360 project root with a single command via

$ mvn install -P deploy -Dbase.deploy.dir=/ABSOLUTE/PATH/TO/sw360chores/_deploy -DskipTests

After that you should follow the next steps in the SW360 wiki.

Complete script usage description

To get the complete description of how to use the script use

./sw360chores.pl --help

Configuration

All configuration is done in the folder ./configuration/, and the structure looks like:

configuration
├── certs
├── configuration.pl
├── COUCHDB_PASSWORD
├── COUCHDB_USER
├── nginx
│   ├── nginx.fifo
│   ├── nginx.key
│   ├── nginx.pem
│   └── regenerateCerts.sh
├── POSTGRES_PASSWORD
├── proxy.env.template
└── sw360
    ├── sw360.env
    ├── fossology
    │   ├── fossology.id_rsa
    │   └── fossology.id_rsa.pub
    ├── ldapimporter.properties
    ├── portal-ext.properties
    └── sw360.properties

Note: The content of ./configuration/ is only runtime configuration which is partially used on build time (e.g. proxy.env and configuration.pl), but should not be persisted in the generated images.

The file ./configuration/certificates

This file should contain the TLS certificates of services the server wants to talk to. This should contain e.g. the companies root certificate.

It should contain the certificates concatenated in one file, separated by a newline.

The file ./configuration/configuration.pl

This contains some configuration for the sw360chores.pl. Most of the flags can also be overwritten via CLI-flags.

The file ./configuration/COUCHDB_USER

This file just contains the user for CouchDB and it is set up as an environment variable for docker compose.

The file ./configuration/COUCHDB_PASSWORD

This file just contains the password for CouchDB and it is added as secret to the containers.

To deactivate the authentication on CouchDB and start it in admin party mode, just call

$ echo > configuration/COUCHDB_PASSWORD

This might be necessary for running the SW360 tests against the exposed database.

The folder ./configuration/nginx/

This folder contains all files necessary for the https termination via nginx. As default this contains an unsafe key-pair.

There is also the file ./configuration/nginx/regenerateCerts.sh, which is used for regenerating the unsafe key-pair.

The file ./configuration/POSTGRES_PASSWORD

This file just contains the password for postgres and it is added as secret to the containers.

The file ./configuration/proxy.env.template

This is a template file for configuring proxy settings. To enable support for a proxy, copy this file to a file named proxy.env (in the same folder). In proxy.env one can add proxy settings, which are passed to all docker-compose calls and into the containers, which need to connect to the internet.

Note: The file proxy.env is excluded from source control; so it is not shown as outgoing changes.

The folder ./configuration/sw360/

The file ./configuration/sw360/sw360.env can be used to tweak some runtime environment variables.

The files ldapimporter.properties, portal-ext.properties and sw360.properties are placed at /etc/sw360/ in the container and can be used to configure the corresponding parts. In these files are variables replaced with environment variables.

The folder `./configuration/sw360/fossology/**

This folder contains the rsa-key-pair used for the SSH connection to the FOSSology server necessary for the upload to FOSSology functionality.

Note: which server to use is configured in ./configuration/sw360/sw360.env.

Migration from old ./configuration.yml to the new ./configuration/ folder

Starting with the old configuration, it should be easy to move all configuration to the corresponding files in ./configuration/.

Advanced usage:

Logging

For implementing a centralized logging we recomend the gliderlabs/logspout container, which collects and routes the logs of all container in a very configurable way.

Further documentation can be found in the corresponding README.md.

Backup and restore content of docker volumes

The ./sw360chores.pl command has the optional parameters --backup and --restore which allow to write the content of all related volumes to tar files, which are placed in the folder defined as BACKUP_FOLDER in ./configuration.env.

Backup of postgres sql data

To generate a dump:

$ docker exec -t sw360postgres pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

Using sw360chores together with docker swarm

To deploy the configured deployment to a swarm, one should use the commands

$ ./sw360chores.pl --swarm --build --prod [...]
$ docker stack deploy --compose-file <(./sw360chores.pl --prod --swarm -- config) sw360

Note: This feature is currently supported but might be dropped soon in the future. If you plan to depend on that, please communicate that back to the project.

Vagrant for testing / demonstration

One can build the docker setup within a Virtualbox controlled by Vagrant via

$ vagrant up && vagrant reload

It will then consume the content from ./_deploy.

The log from docker than can be watched via

$ vagrant ssh -c "/sw360chores/sw360chores.pl -- logs -f"

More description can be found in the file ./Vagrantfile.

About the folder structure

The folder ./configuration/

This folder was explained above.

The folder ./docker-images/

This folder contains the Dockerfiles and scripts to build the images.

The folder ./deployment/

This folder contains the docker-compose files, which describe how the images should be configured.

The folder ./miscellaneous/

This folder contains the important file test_users_with_passwords_12345.csv, which contains example users which can be used in an development or test setup. All created users have the password 12345.

Further this contains the following subfolders

  • couchdbPackager/, which creates a couchDB rpm package for RHEL/CentOS 7
  • cveSearchBox/, which contains a simple Vagrantfile which starts a standalone cve-search server
  • scripts/, which contain some useful scripts.

None of the things in this folder are directly used by the packaging or deployment part.

Folders starting with _

All folders starting with _ are transient.

sw360chores's People

Contributors

alexbrdn avatar andreaslarfors avatar atsushinemoto avatar bodetc avatar bs-matil avatar greimela-si avatar heliocastro avatar heydenreich avatar imaykay avatar lepokle avatar maxhbr avatar mcjaeger avatar oheger-bosch avatar zesoup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sw360chores's Issues

Readme not correct

it seem like executing the single line as given in the current readme.md:

$ mvn install -P deploy -Ddeploy.dir=/ABSOLUTE/PATH/TO/sw360chores/_deploy -DskipTests

is not working, because maven vields the following message:

[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce) @ sw360 ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must set at least the property 'base.deploy.dir'!

rather the command could be (works for me):

mvn package -P deploy -Dbase.deploy.dir=/ABSOLUTE/PATH/TO/sw360chores/_deploy -Dliferay.deploy.dir=/ABSOLUTE/PATH/TO/sw360chores/_deploy/deploy -Dbackend.deploy.dir=/ABSOLUTE/PATH/TO/sw360chores/_deploy/tomcat-9.0.17/webapps -Drest.deploy.dir=/ABSOLUTE/PATH/TO/sw360chores/_deploy/tomcat-9.0.17/webapps -DskipTests

Adjust vagrant script so that it provisions complete SW360 docker setup

Goal: We should allow windows users to easily setup a sw360 test instance to develop against, e.g. the sw360 rest api

  1. should be self contained. Pull latest version of sw360chores from github
  2. creates all images from sw360chores
  3. should build sw360portal
  4. should deploy sw360portal wars into tomcat container

Cannot create resource output directory: /couchdb-lucene/target/classes -> [Help 1]

Attempting to build on osx results in build error for couchdb-lucene

./sw360chores.pl --build -- up
  variables:
    $projectName  = sw360
    $build        = 1
    $save         =
    $pushTo       =
    $cleanup      =
    $prod         = 0
    $swarm        = 0
    $cveSearch    = 0
    $watchtower   = 0
    $cpWebappsDir = <undefined>
    $cpDeployDir  = <undefined>
    $backupDir    =
    $restoreDir   =
    $debug        = 1
  environmental variables:
  arguments:
    @ARGV         = up
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:15 min
[INFO] Finished at: 2019-10-15T20:21:10Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project couchdb-lucene: Cannot create resource output directory: /couchdb-lucene/target/classes -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
failed to prepare couchdb-lucene at ./sw360chores.pl line 380.

Hardcoded Commit of cve-search no longer works. NVD XML retirement.

cve-search-server/Dockerfile contains a hardcoded commit hash for the cve-search project:
ENV BRANCH=4c165eff1af0e4c7bdf103c341203717ae677f64

The population of the cve database fails because NVD have retired the XML feed of CVE records.
https://nvd.nist.gov/General/News/XML-Vulnerability-Feed-Retirement-Phase-3

Version 2.3 of cve-search (Sep 18, 2019) https://github.com/cve-search/cve-search/releases/tag/v2.3 adds support for the new JSON format from NVD.

Spreadsheet export fails because of missing fonts

org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for
servlet projects Servlet threw exception
    java.lang.NullPointerException
         at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)```

couchdb-lucene-1.0.2 of sw360dependencies URL match

When deploying using the sw360dependencies.tar.gz build by the prepare script, the couchdb-lucene web app is created with suffix -1.0.2.war which is also in the resulting URL of this web app.

The problem is that sw360 / the couchdb config does not expect the number and thus ... workaround is to manually renamed the couchdb-lucene-x.y.z.war to couchdb-lucene.war

Components page is temporarily unavailable

Followed procedure: https://gist.github.com/roycyt/b6ddd241caf734732d1780d5de27a6ec

using latest stable release: sw360-8.1.0-M1

In the fresh install of sw360 via docker chores

We have the sw360-8.1.0-M1

image

I have imported users as well

image

and tried to login with different users as well (admin, user etc)

Error log:

Components_ErrorLog.txt

Highlights of error


 ERROR [http-nio-8080-exec-15][ComponentPortlet:1451] Problem retrieving all the Vendor names
 org.apache.thrift.transport.TTransportException: HTTP Response code: 404

ERROR [http-nio-8080-exec-15][UserCacheHolder:75] Unable to fetch user...
 java.util.concurrent.ExecutionException: org.apache.thrift.transport.TTransportException: HTTP Response code: 404


ERROR [http-nio-8080-exec-15][ComponentPortlet:1475] Could not get component total count in backend
org.apache.thrift.transport.TTransportException: HTTP Response code: 404


ERROR [http-nio-8080-exec-15][PortletRequestDispatcherImpl:303] Unable to dispatch request: java.lang.InstantiationException: bean totalRows not found within scope
ERROR [http-nio-8080-exec-15][PortletServlet:119] javax.portlet.PortletException: javax.servlet.ServletException: java.lang.InstantiationException: bean totalRows not found within scope
javax.portlet.PortletException: javax.servlet.ServletException: java.lang.InstantiationException: bean totalRows not found within scope


ERROR [http-nio-8080-exec-15][render_portlet_jsp:131] null
 java.lang.InstantiationException: bean totalRows not found within scope

Also refer https://sw360chat.slack.com/archives/C68C2RYS3/p1586447237060000

Help needed with running SW360 - 502 Bad Gateway

I got the latest sources from sw360chores and followed the instructions of V2 to build everything.
That works fine, however when I run startUp.sh and go to https://localhost:8443 I get an Bad Gateway error with the following Nginx error.
image

I'm running this on a VirtualBox and all docker containers are running
image

Did I miss something? Any help will very much appreciated.

Provision the empty containers with the content from the liferay configuration (e.g. settings and lar stuff)

according to [1] one has to have

  • a sql dump of the postgres and
  • the content of $CATALINA_HOME/data

to restore an liferay instance. We could use content, from a freshly provisioned instance, to create some files which can be used while building the images, to get an already provisioned liferay.

These two parts thus could be added as default content to sw360postgres and sw360empty respectively.

[1] https://web.liferay.com/de/web/user.26526/blog/-/blogs/backup-restore-a-liferay-environment

Add versions and releases

We need to add releases to this repository.

Maybe we should also add a disclaimer like

Release Pattern

This project does not follow semantic versioning - version numbers are kept matching to the minimum compatible product version

Configure admin user via docker bringup

After bringing up a deployment of sw360 via the following:

./sw360chores.pl --build -- up

Is it possible to configure or is there a default an admin account created I login with, instead of having to create (or sign up) an account post set up via the web UI?

Deployment to Tomcat does not work reliably

The tomcatdeploy.sh script monitors a directory for new or updated web applications to be deployed. When a change in this directory is detected, the file affected is moved into the actual deployment folder of Tomcat (lines 40 and following).

When trying to setup sw360chores, I had the situation that the directory to monitor did not exist yet. This caused the monitoring mechanism to fail, and no deployment was done.

A fix would be to make sure that directory always exists, creating it if necessary.

Running SW360 with Fossology and CVE search

Hello all,

I want to run SW360 together with Fossology and CVE search is this possible with the existing docker image?
Where should the Fossology configuration be done? - I assume in the configuration.yml but in the wiki entry the /backend/src/src-fossology/src/main/resources/fossology.properties file is referenced. Furthermore, my SW360 portal tabs (Components, Licences, ECC, etc.) are empty - should they all be empty as long as no connection with Fossology is established?

What I have already done:

  • Fossology running in an own docker container
  • the perl script for the sw360chores started which runs also docker containers with the described components.
  • followed the Liferay deploy wiki entry
  • started following the Fossology deploy wiki entry

Thanks in advance!

docker setup does not seem to run with macosx

it seems like on macosx (10.13.6), docker setup is not running:

lando:sw360chores-master sam$ docker -v
Docker version 18.06.1-ce, build e68fc7a
lando:sw360chores-master sam$ ./sw360chores.pl --build -- up
... the file liferay-portal-tomcat-6.2-ce-ga5-20151119152357409.zip already exists: skip
rm: /Users/sam/Downloads/sw360chores-master/_tmp/tmp.Dw9kEAC/sw360/webapps/docs: No such file or directory
rm: /Users/sam/Downloads/sw360chores-master/_tmp/tmp.Dw9kEAC/sw360/webapps/examples: No such file or directory
rm: /Users/sam/Downloads/sw360chores-master/_tmp/tmp.Dw9kEAC/sw360/webapps/host-manager: No such file or directory
rm: /Users/sam/Downloads/sw360chores-master/_tmp/tmp.Dw9kEAC/sw360/webapps/manager: No such file or directory
sed: 1: "/Users/sam/Downloads/sw ...": bad flag in substitute command: 's'
failed to prepare sw360empty at ./sw360chores.pl line 311.
lando:sw360chores-master sam$ 

which maybe a platform issue because of different paths in the prepare scripts.

Test the integration with SW360Rest

From @bs-jokri on October 9, 2017 11:1

From @maxhbr on June 19, 2017 11:4

using the current sw360/sw360rest@6ce17c1 one can integrate its docker-compose setup into sw360chores via the following changes:

1. name the images created by sw360rest

diff --git a/docker-compose.yml b/docker-compose.yml
index 65d8271..a0b6f1b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -15,6 +15,7 @@ services:
 
   sw360-authorization-server:
     build: subprojects/authorization-server
+    image: sw360restauthorization
     ports:
       - 8090:8090
     environment:
@@ -22,6 +23,7 @@ services:
 
   sw360-resource-server:
     build: subprojects/resource-server
+    image: sw360restresource
     ports:
       - 8091:8091
     links:

(should be moved to upstream)

2. build the named images (in sw360rest):

$ ./gradlew build preparedocker
$ docker-compose build

3. include the new images to the sw360chores docker-compose setup

diff --git a/deployment/configuration.env b/deployment/configuration.env
index b757d81..37e6c7e 100644
--- a/deployment/configuration.env
+++ b/deployment/configuration.env
@@ -7,6 +7,7 @@
 # http://www.eclipse.org/legal/epl-v10.html
 
 DEV_MODE=true
+REST=true
 # CVE_SEARCH=false
 # HTTPS_COUCHDB=false
 # BACKUP_FOLDER=./_backup
diff --git a/deployment/docker-compose.rest.yml b/deployment/docker-compose.rest.yml
new file mode 100644
index 0000000..d3b799b
--- /dev/null
+++ b/deployment/docker-compose.rest.yml
@@ -0,0 +1,30 @@
+# Copyright Bosch Software Innovations GmbH, 2017.
+# Part of the SW360 Portal Project.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+
+
+# This file adds a cve-search server to the sw360 environment.
+# Use it together with the main docker-compose.yml as described
+# in README.md
+
+version: '2'
+services:
+  sw360-authorization-server:
+    image: sw360restauthorization
+    ports:
+      - 8090:8090
+    environment:
+      - SW360_AUTHORIZATION_SERVER_ARGS=-Dspring.profiles.active=dev
+
+  sw360-resource-server:
+    image: sw360restresource
+    ports:
+      - 8091:8091
+    networks:
+      - sw360front
+    environment:
+      - SW360_THRIFT_SERVER_URL=http://sw360:8080
diff --git a/deployment/docker-compose.sh b/deployment/docker-compose.sh
index 3fcac89..5b718f4 100755
--- a/deployment/docker-compose.sh
+++ b/deployment/docker-compose.sh
@@ -92,6 +92,7 @@ addSudoIfNeeded() {
 cmdDocker="$(addSudoIfNeeded) env $(grep -v '^#' proxy.env | xargs) docker"
 cmdDockerCompose="${cmdDocker}-compose -f $DIR/docker-compose.yml"
 [ "$DEV_MODE" == "true" ] && cmdDockerCompose="$cmdDockerCompose -f $DIR/docker-compose.dev.yml"
+[ "$REST" == "true" ] && cmdDockerCompose="$cmdDockerCompose -f $DIR/docker-compose.rest.yml"
 [ "$CVE_SEARCH" == "true" ] && {
     cmdDockerCompose="$cmdDockerCompose -f $DIR/docker-compose.cve-search-server.yml"
     [ "$DEV_MODE" == "true" ] && cmdDockerCompose="$cmdDockerCompose -f $DIR/docker-compose.dev.cve-search-server.yml"

(based on https://github.com/bsinno/sw360-chores/tree/integration/2017_05_31)

Copied from original issue: bsinno/sw360#442

Copied from original issue: sw360/sw360portal#649

Helm deployment

Hello,
i would like to try the docker deployment, I will test the pl script but do you consider creating a helm deployment for a kubernetes usage ?

Improvements of proxy support during Docker image builds

I am in a corporate network with a quite rigid proxy that requires authentication. Therefore, I use a local proxy like cntlm to have a rather transparent internet connection. In such an environment, the build of the Docker images does not work, even if the proxy settings (pointing to localhost in this case) are specified in the proxy.env configuration file; the containers cannot connect to the proxy.

A solution that worked for me was enabling the network mode 'host' when building images; it would therefore be nice if the main script could support a parameter to enable this mode and pass the corresponding arguments through to the Docker builds.

missing space in docker-entrypoint.sh

docker-images/sw360empty/docker-entrypoint.sh

if [ ! "$POSTGRES_HOST" ] || [ ! "$POSTGRES_USER" ] || ( [ ! -f "$POSTGRES_PASSWORD_FILE" ] && [ ! "$POSTGRES_PASSWORD"] ); then
    echo "postgres configuration incomplete"
    exit 1
fi

should be [ ! "$POSTGRES_PASSWORD" ] otherwise issues with script

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.