Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Commit 987d841

Browse files
authored
Merge pull request #60 from bosch-io/bs-matil/docker-images-backend
chores(dockerfiles): New lightweight and improved docker images
2 parents dc81966 + a9d5feb commit 987d841

File tree

16 files changed

+537
-0
lines changed

16 files changed

+537
-0
lines changed

v2/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Docker Images for SW360 Project
2+
3+
**This is work in progress**
4+
5+
The goal of the content in this folder is to develop a new and more lightweight deployment, where the SW360 backend is separated from the frontends.
6+
This allows the containers to have a fast startup time and be small.
7+
8+
The long term goal is to merge this with the top level deployment.
9+
10+
This folder is not used by the `../sw360chores.pl` script, but it uses parts of the top level folder `../configuration`.
11+
12+
## Installation
13+
To build all images just run `docker-compose build` in the corresponding directories
14+
15+
alternativly you can run docker build . within any of the folders to build the image manually
16+
17+
### Proxy options
18+
19+
If you need to build the image behind an HTTP proxy you can set the proxy with
20+
21+
```
22+
docker-compose build \
23+
--build-arg http_proxy=http://127.0.0.1:3128 \
24+
--build-arg https_proxy=http://127.0.0.1:3128
25+
26+
or in case of docker native build
27+
28+
docker build \
29+
--build-arg http_proxy=http://127.0.0.1:3128 \
30+
--build-arg https_proxy=http://127.0.0.1:3128 .
31+
```
32+
33+
## Images
34+
35+
### backend
36+
37+
This image will build all componentes in the backend module of sw360 and deploy them into an tomcat (9). If the container is started and the couch db connection was correct the thrift API will be available on port 8080.
38+
39+
### couchdb
40+
41+
A simple couchdb container which has some specific configuration options for sw360 regards the integration with lucene
42+
43+
### couchdb-lucene
44+
45+
A container for the couchdb-lucene project
46+
47+
### maven-thrift
48+
49+
A maven container which has added thrift support. This container is also used to build all sw360 application containers.
50+
51+
## Testing with the "old" image with the liferay frontend
52+
```
53+
$ ( cd /PATH/TO/SW360; mvn package -DskipTests )
54+
$ find /PATH/TO/SW360/frontend -name '*.war' -exec cp -v {} ../_deploy \;
55+
$ docker-compose -f docker-images-backend/docker-compose.yaml -f docker-images-frontend/docker-compose.yaml up
56+
```
57+
After that SW360 can be accessed on `https://localhost:8443`.

v2/docker-images-backend/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Docker Backend Images for SW360 Project
2+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright Bosch Software Innovations GmbH, 2017.
2+
# Part of the SW360 Portal Project.
3+
#
4+
# All rights reserved. This program and the accompanying materials
5+
# are made available under the terms of the Eclipse Public License v1.0
6+
# which accompanies this distribution, and is available at
7+
# http://www.eclipse.org/legal/epl-v10.html
8+
9+
ARG REPOSITORY
10+
11+
FROM ${REPOSITORY}sw360/maven-thrift
12+
13+
RUN apk update && apk add git zip
14+
RUN git clone https://github.com/eclipse/sw360.git
15+
16+
#Workaround for MVN_PROXY
17+
ARG MVN_FLAGS="-Dhttp.proxyHost=$(basename $http_proxy | cut -d':' -f1) -Dhttp.proxyPort=$(basename $http_proxy | cut -d':' -f2) -Dhttps.proxyHost=$(basename $http_proxy | cut -d':' -f1) -Dhttps.proxyPort=$(basename $http_proxy | cut -d':' -f2) -Dhttp.nonProxyHosts=localhost"
18+
RUN cd sw360 && \
19+
mvn $(eval echo "${MVN_FLAGS}" ) install -P deploy -Ddeploy.dir=/sw360chores -DskipTests \
20+
-pl '!rest,!rest/rest-common,!rest/authorization-server,!rest/resource-server,!frontend,!frontend/layouttpl,!frontend/sw360-portlet,!frontend/sw360-theme,!libraries/importers/component-importer,!libraries/importers/license-importer'
21+
22+
WORKDIR /sw360chores
23+
24+
COPY create-slim-war-files.sh create-slim-war-files.sh
25+
RUN bash create-slim-war-files.sh
26+
27+
FROM tomcat:9
28+
RUN apt-get update && apt-get install -y gettext patch && rm -rf /var/lib/apt/lists/*
29+
30+
# TOMCAT SETTINGS
31+
COPY catalina.properties.patch /usr/local/tomcat/conf/catalina.properties.patch
32+
RUN cd /usr/local/tomcat/conf/ && patch -b < catalina.properties.patch
33+
RUN sed -i -e 's/<Engine/<Engine startStopThreads="0" /g' -e 's/<Host/<Host startStopThreads="0" /g' /usr/local/tomcat/conf/server.xml
34+
RUN rm -rf /usr/local/tomcat/webapps/*
35+
COPY --from=0 /sw360chores/slim-wars/*.war /usr/local/tomcat/webapps/
36+
COPY --from=0 /sw360chores/libs/*.jar /usr/local/tomcat/shared/
37+
38+
# COUCH DB SETTINGS
39+
ENV COUCHDB_URL="http://172.17.0.1:5984"
40+
ENV COUCHDB_USER=""
41+
ENV COUCHDB_PASSWORD=""
42+
ENV COUCHDB_DBNAME_SW360="sw360db"
43+
ENV COUCHDB_DBNAME_USERDB="sw360users"
44+
ENV COUCHDB_DBNAME_ATTACHMENTS="sw360attachments"
45+
ENV COUCHDB_DBNAME_FOSSOLOGYKEYS="sw360fossologykeys"
46+
ENV COUCHDB_DBNAME_VULNERABILITY_MANAGEMENT="sw360vm"
47+
COPY couchdb.template.properties /etc/sw360/couchdb.properties.template
48+
COPY entrypoint.sh entrypoint.sh
49+
CMD ["bash","entrypoint.sh"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# thrift based backend
2+
This container contains the thrift http api
3+
4+
## Files
5+
### catalina.properties.patch
6+
patch which mainly contains a list of dependenies which was manully created by combining all *.war files of the backend.
7+
8+
### create-slim-war-files.sh
9+
A script that unpacks all wars and repackes them without lib folders. All libs are collected in one shared lib folder.
10+
11+
### couchdb.template.properties
12+
a couchdb.properties file where all values will be replaced with envorinment variables on startup of the container
13+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright Bosch Software Innovations GmbH, 2019.
2+
# Part of the SW360 Portal Project.
3+
#
4+
# All rights reserved. This program and the accompanying materials
5+
# are made available under the terms of the Eclipse Public License v1.0
6+
# which accompanies this distribution, and is available at
7+
# http://www.eclipse.org/legal/epl-v10.html
8+
9+
--- catalina.properties 2019-02-27 21:38:55.297749700 +0100
10+
+++ catalina.properties 2019-02-27 21:35:55.043246200 +0100
11+
@@ -87,7 +87,7 @@
12+
# ${catalina.base} path or the ${catalina.home} path contains a comma.
13+
# Because double quotes are used for quoting, the double quote character
14+
# may not appear in a path.
15+
-shared.loader=
16+
+shared.loader=shared/*.jar
17+
18+
# Default list of JAR files that should not be scanned using the JarScanner
19+
# functionality. This is typically used to scan JARs for configuration
20+
@@ -191,7 +191,79 @@
21+
xml-apis.jar,\
22+
xmlParserAPIs-*.jar,\
23+
xmlParserAPIs.jar,\
24+
-xom-*.jar
25+
+xom-*.jar,\
26+
+activation-*.jar, \
27+
+annotations-*.jar, \
28+
+antlr-*.jar, \
29+
+antlr-*.jar, \
30+
+antlr-runtime-*.jar, \
31+
+arq-*.jar, \
32+
+asm-*.jar, \
33+
+cglib-*.jar, \
34+
+commons-beanutils-*.jar, \
35+
+commons-codec-*.jar, \
36+
+commons-collections-*.jar, \
37+
+commons-collections*.jar, \
38+
+commons-csv-*.jar, \
39+
+commons-digester*.jar, \
40+
+commons-io-*.jar, \
41+
+commons-lang-*.jar, \
42+
+commons-lang3-*.jar, \
43+
+commons-logging-*.jar, \
44+
+compiler*.jar, \
45+
+curvesapi-*.jar, \
46+
+ektorplucene-*.jar, \
47+
+findbugs-annotations-*.jar, \
48+
+gson-*.jar, \
49+
+guava-*.jar, \
50+
+htmlparser-*.jar, \
51+
+httpclient-*.jar, \
52+
+httpclient-cache-*.jar, \
53+
+httpcore-*.jar, \
54+
+icu4j-*.jar, \
55+
+iri-*.jar, \
56+
+jackson-annotations-*.jar, \
57+
+jackson-core-*.jar, \
58+
+jackson-databind-*.jar, \
59+
+JavaEWAH-*.jar, \
60+
+java-rdfa-*.jar, \
61+
+jcl-over-slf4j-*.jar, \
62+
+jena-*.jar, \
63+
+joda-time-*.jar, \
64+
+jsch-*.jar, \
65+
++json-simple-*.jar, \
66+
+jsoup-*.jar, \
67+
+libthrift-*.jar, \
68+
+log4j-*.jar, \
69+
+lucene-core-*.jar, \
70+
+mail-*.jar, \
71+
+opencsv-*.jar, \
72+
+org.eclipse.jgit-*.jar, \
73+
+org.ektorp-*.jar, \
74+
+poi-*.jar, \
75+
+poi-*.jar, \
76+
+poi-ooxml-*.jar, \
77+
+poi-ooxml-schemas-*.jar, \
78+
+saxon-*.jar, \
79+
+saxon-dom-*.jar, \
80+
+slf4j-api-*.jar, \
81+
+slf4j-log4j12-*.jar, \
82+
+spdx-tools-*.jar, \
83+
+spring-aop-*.RELEASE.jar, \
84+
+spring-beans-*.RELEASE.jar, \
85+
+spring-context-*.RELEASE.jar, \
86+
+spring-core-*.RELEASE.jar, \
87+
+spring-expression-*.RELEASE.jar, \
88+
+spring-web-*.RELEASE.jar, \
89+
+spring-webmvc-*.RELEASE.jar, \
90+
+ST4-*.jar, \
91+
+stax-api-*.jar, \
92+
+stringtemplate-*.jar, \
93+
+velocity-engine-core-*.jar, \
94+
+velocity-tools-generic-*.jar, \
95+
+wstx-asl-*.jar, \
96+
+xercesImpl-*.jar, \
97+
+xmlbeans-*.jar
98+
99+
# Default list of JAR files that should be scanned that overrides the default
100+
# jarsToSkip list above. This is typically used to include a specific JAR that
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright Bosch Software Innovations GmbH, 2019.
2+
# Part of the SW360 Portal Project.
3+
#
4+
# All rights reserved. This program and the accompanying materials
5+
# are made available under the terms of the Eclipse Public License v1.0
6+
# which accompanies this distribution, and is available at
7+
# http://www.eclipse.org/legal/epl-v10.html
8+
9+
couchdb.url = $COUCHDB_URL
10+
couchdb.user = $COUCHDB_USER
11+
couchdb.password = $COUCHDB_PASSWORD
12+
couchdb.database = $COUCHDB_DBNAME_SW360
13+
couchdb.usersdb = $COUCHDB_DBNAME_USERDB
14+
couchdb.attachments = $COUCHDB_DBNAME_ATTACHMENTS
15+
couchdb.fossologyKeys = $COUCHDB_DBNAME_FOSSOLOGYKEYS
16+
couchdb.vulnerability_management = $COUCHDB_DBNAME_VULNERABILITY_MANAGEMENT
17+
18+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Copyright Bosch Software Innovations GmbH, 2019.
4+
# Part of the SW360 Portal Project.
5+
#
6+
# All rights reserved. This program and the accompanying materials
7+
# are made available under the terms of the Eclipse Public License v1.0
8+
# which accompanies this distribution, and is available at
9+
# http://www.eclipse.org/legal/epl-v10.html
10+
11+
set -e
12+
13+
rm -rf libs
14+
mkdir libs
15+
rm -rf slim-wars
16+
mkdir slim-wars
17+
for i in $(ls *.war)
18+
do
19+
i=${i%.war}
20+
echo repacking $i ...
21+
rm -rf $i
22+
mkdir $i
23+
cd $i
24+
unzip -q ../$i.war
25+
find WEB-INF/lib ! \( -name "*${i}*" -o -name "*commonIO-*" -o -name "*datahandler-*" -o -name "*src-vulnerabilities-*" -o -name "*src-attachments-*" -o -name "*exporters-*" -o -name "*licenses-*" -o -name "*-common-*" -o -name "*build-configuration-*" \) -type f -exec mv {} ../libs/ \;
26+
zip -q -r ../slim-wars/$i.war .
27+
cd ..
28+
rm -rf $i
29+
echo done
30+
done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Copyright Bosch Software Innovations GmbH, 2019.
3+
# Part of the SW360 Portal Project.
4+
#
5+
# All rights reserved. This program and the accompanying materials
6+
# are made available under the terms of the Eclipse Public License v1.0
7+
# which accompanies this distribution, and is available at
8+
# http://www.eclipse.org/legal/epl-v10.html
9+
10+
envsubst < /etc/sw360/couchdb.properties.template > /etc/sw360/couchdb.properties
11+
12+
exec catalina.sh run
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright Bosch Software Innovations GmbH, 2016.
2+
# Part of the SW360 Portal Project.
3+
#
4+
# All rights reserved. This program and the accompanying materials
5+
# are made available under the terms of the Eclipse Public License v1.0
6+
# which accompanies this distribution, and is available at
7+
# http://www.eclipse.org/legal/epl-v10.html
8+
9+
10+
FROM maven:3-jdk-8-alpine
11+
ENV BRANCH="v2.1.0"
12+
RUN apk update && apk add git
13+
RUN git clone --branch $BRANCH --depth 1 https://github.com/rnewson/couchdb-lucene
14+
15+
#Workaround for MVN_PROXY
16+
ARG MVN_FLAGS="-Dhttp.proxyHost=$(basename $http_proxy | cut -d':' -f1) -Dhttp.proxyPort=$(basename $http_proxy | cut -d':' -f2) -Dhttps.proxyHost=$(basename $http_proxy | cut -d':' -f1) -Dhttps.proxyPort=$(basename $http_proxy | cut -d':' -f2) -Dhttp.nonProxyHosts=localhost"
17+
RUN cd couchdb-lucene && mvn $(eval echo "${MVN_FLAGS}" )
18+
19+
20+
FROM java:openjdk-8-jre-alpine
21+
22+
ARG TARGET="couchdb-lucene-2.1.0-dist.zip"
23+
24+
25+
WORKDIR /
26+
COPY --from=0 /couchdb-lucene/target/${TARGET} /
27+
RUN set -ex \
28+
&& apk add --update unzip \
29+
&& unzip /${TARGET} \
30+
&& apk del unzip \
31+
&& mv /couchdb-lucene-2.1.0 /couchdb-lucene
32+
33+
EXPOSE 5985
34+
COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh
35+
RUN chmod +x /usr/local/bin/entrypoint.sh
36+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
37+
CMD ["/couchdb-lucene/bin/run"]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
# Copyright Bosch Software Innovations GmbH, 2016.
4+
# Part of the SW360 Portal Project.
5+
#
6+
# All rights reserved. This program and the accompanying materials
7+
# are made available under the terms of the Eclipse Public License v1.0
8+
# which accompanies this distribution, and is available at
9+
# http://www.eclipse.org/legal/epl-v10.html
10+
11+
set -e
12+
13+
if [ ! "$COUCHDB_HOST" ]; then
14+
echo "the environmental variable \$COUCHDB_HOST must be set"
15+
exit 1
16+
fi
17+
18+
if [ ! "$COUCHDB_USER" ]; then
19+
echo "the environmental variable \$COUCHDB_USER must be set"
20+
exit 1
21+
fi
22+
23+
if [ ! "$COUCHDB_PASSWORD" ]; then
24+
echo "the environmental variable \$COUCHDB_PASSWORD must be set"
25+
exit 1
26+
fi
27+
28+
COUCHDB_HOST="${COUCHDB_USER}:${COUCHDB_PASSWORD}@${COUCHDB_HOST:-couchdb}";
29+
30+
sed -i -r 's/^url.*=.*/url = http:\/\/'"$COUCHDB_HOST:${COUCHDB_PORT:-5984}"'/' "/couchdb-lucene/conf/couchdb-lucene.ini";
31+
sed -i -r 's/^host.*=.*/host = 0.0.0.0/' "/couchdb-lucene/conf/couchdb-lucene.ini";
32+
exec /couchdb-lucene/bin/run;
33+
exec "$@"

0 commit comments

Comments
 (0)