Commit 346546d6 authored by Robert Volkmann's avatar Robert Volkmann

feat(docker): Replaced standalone Dockerfile with docker-compose.

Changes:
.dockerignore:
* Added some unrelated files for docker.

docker-compose.yml:
* Moved to root project folder.
* Removed obsolete prefix fossology.

default-docker-test.sh:
* Removed the creation of a network with fixed subnet.
parent 923982ae
install/docker-compose*
!install/docker-compose.docker-entrypoint.sh
fossology310-source.spdx
################################################################################
# omit rebuilding after changing some unrelated files.
.editorconfig
.github
.gitignore
.travis.yml
*.md
LICENSE
NOTICES*
docker-compose.yml
Vagrantfile
# omit rebuilding after changing the docker tests.
src/testing/docker
################################################################################
# from gitignore:
/.idea
......
# FOSSology Dockerfile
# Copyright Siemens AG 2016, fabio.huser@siemens.com
# Copyright TNG Technology Consulting GmbH 2016-2017, maximilian.huber@tngtech.com
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
......@@ -8,33 +9,48 @@
#
# Description: Docker container image recipe
FROM debian:8.8
FROM debian:jessie
MAINTAINER Fossology <fossology@fossology.org>
LABEL maintainer="Fossology <fossology@fossology.org>"
WORKDIR /fossology
COPY . .
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 DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends lsb-release sudo \
&& rm -rf /var/lib/apt/lists/*
COPY ./utils/fo-installdeps ./utils/fo-installdeps
COPY ./utils/utils.sh ./utils/utils.sh
COPY ./src/delagent/mod_deps ./src/delagent/
COPY ./src/mimetype/mod_deps ./src/mimetype/
COPY ./src/pkgagent/mod_deps ./src/pkgagent/
COPY ./src/scheduler/mod_deps ./src/scheduler/
COPY ./src/ununpack/mod_deps ./src/ununpack/
COPY ./src/wget_agent/mod_deps ./src/wget_agent/
COPY ./install/scripts/php-conf-fix.sh ./install/scripts/php-conf-fix.sh
COPY ./utils/install_composer.sh ./utils/install_composer.sh
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive /fossology/utils/fo-installdeps --everything -y \
&& rm -rf /var/lib/apt/lists/* \
&& /fossology/install/scripts/php-conf-fix.sh --overwrite \
&& /fossology/utils/install_composer.sh
RUN /fossology/install/scripts/install-spdx-tools.sh
RUN /fossology/install/scripts/install-ninka.sh
COPY . .
RUN make install
RUN make install && make clean
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
# the database is filled in the entrypoint
RUN /usr/local/lib/fossology/fo-postinstall --agent --common --scheduler-only --web-only --no-running-database
RUN /fossology/install/scripts/php-conf-fix.sh --overwrite
# configure apache
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 \
&& mkdir -p /var/log/apache2/ \
&& ln -sf /proc/self/fd/1 /var/log/apache2/access.log \
&& ln -sf /proc/self/fd/1 /var/log/apache2/error.log
EXPOSE 8081
EXPOSE 80
RUN chmod +x /fossology/docker-entrypoint.sh
ENTRYPOINT ["/fossology/docker-entrypoint.sh"]
......@@ -11,10 +11,10 @@
# Docker setup with separate Database instance
version: '3'
services:
fossology-scheduler:
scheduler:
build:
context: ..
dockerfile: install/docker-compose.Dockerfile
context: .
dockerfile: Dockerfile
args:
- http_proxy
- https_proxy
......@@ -22,20 +22,20 @@ services:
image: fossology
restart: unless-stopped
environment:
- FOSSOLOGY_DB_HOST=fossology-db
- FOSSOLOGY_DB_HOST=db
- FOSSOLOGY_DB_NAME=fossology
- FOSSOLOGY_DB_USER=fossy
- FOSSOLOGY_DB_PASSWORD=fossy
user: fossy
command: scheduler
depends_on:
- fossology-db
- db
volumes:
- repository:/srv/fossology/repository/
fossology-web:
web:
build:
context: ..
dockerfile: install/docker-compose.Dockerfile
context: .
dockerfile: Dockerfile
args:
- http_proxy
- https_proxy
......@@ -43,20 +43,20 @@ services:
image: fossology
restart: unless-stopped
environment:
- FOSSOLOGY_DB_HOST=fossology-db
- FOSSOLOGY_DB_HOST=db
- FOSSOLOGY_DB_NAME=fossology
- FOSSOLOGY_DB_USER=fossy
- FOSSOLOGY_DB_PASSWORD=fossy
- FOSSOLOGY_SCHEDULER_HOST=fossology-scheduler
- FOSSOLOGY_SCHEDULER_HOST=scheduler
command: web
ports:
- 8081:80
depends_on:
- fossology-db
- fossology-scheduler
- db
- scheduler
volumes:
- repository:/srv/fossology/repository/
fossology-db:
db:
image: postgres
restart: unless-stopped
environment:
......
#!/bin/bash
# FOSSology docker-entrypoint script
# Copyright Siemens AG 2016, fabio.huser@siemens.com
# Copyright TNG Technology Consulting GmbH 2016, maximilian.huber@tngtech.com
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
......@@ -9,23 +10,12 @@
#
# Description: startup helper script for the FOSSology Docker container
db_host="localhost"
db_name="fossology"
db_user="fossy"
db_password="fossy"
set -o errexit -o nounset -o pipefail
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
db_host="${FOSSOLOGY_DB_HOST:-localhost}"
db_name="${FOSSOLOGY_DB_NAME:-fossology}"
db_user="${FOSSOLOGY_DB_USER:-fossy}"
db_password="${FOSSOLOGY_DB_PASSWORD:-fossy}"
# Write configuration
cat <<EOM > /usr/local/etc/fossology/Db.conf
......@@ -35,31 +25,52 @@ user=$db_user;
password=$db_password;
EOM
sed -i 's/address = .*/address = '"${FOSSOLOGY_SCHEDULER_HOST:-localhost}"'/' \
/usr/local/etc/fossology/fossology.conf
# Startup DB if needed or wait for external DB
if [ "$db_host" = 'localhost' ]; then
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 '*****************************************************'
sleep 5
/etc/init.d/postgresql start
else
testForPostgres(){
test_for_postgres() {
PGPASSWORD=$db_password psql -h "$db_host" "$db_name" "$db_user" -c '\l' >/dev/null
return $?
}
until testForPostgres; do
until test_for_postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
fi
# Setup environment
/usr/local/lib/fossology/fo-postinstall
if [[ $# -eq 0 || ($# -eq 1 && "$1" == "scheduler") ]]; then
/usr/local/lib/fossology/fo-postinstall --database --licenseref
fi
# Start Fossology
echo
echo 'Fossology initialisation complete; Starting up...'
echo
/etc/init.d/fossology start
/usr/sbin/apache2ctl -D FOREGROUND
\ No newline at end of file
if [[ $# -eq 0 ]]; then
/etc/init.d/fossology start
/usr/local/share/fossology/scheduler/agent/fo_scheduler \
--log /dev/stdout \
--verbose=3 \
--reset &
/usr/sbin/apache2ctl -D FOREGROUND
elif [[ $# -eq 1 && "$1" == "scheduler" ]]; then
exec /usr/local/share/fossology/scheduler/agent/fo_scheduler \
--log /dev/stdout \
--verbose=3 \
--reset
elif [[ $# -eq 1 && "$1" == "web" ]]; then
exec /usr/sbin/apache2ctl -e info -D FOREGROUND
else
exec "$@"
fi
# FOSSology Dockerfile
# Copyright Siemens AG 2016, fabio.huser@siemens.com
# Copyright TNG Technology Consulting GmbH 2016-2017, maximilian.huber@tngtech.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:jessie
LABEL maintainer="Fossology <fossology@fossology.org>"
WORKDIR /fossology
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends lsb-release sudo \
&& rm -rf /var/lib/apt/lists/*
COPY ./utils/fo-installdeps ./utils/fo-installdeps
COPY ./utils/utils.sh ./utils/utils.sh
COPY ./src/delagent/mod_deps ./src/delagent/
COPY ./src/mimetype/mod_deps ./src/mimetype/
COPY ./src/pkgagent/mod_deps ./src/pkgagent/
COPY ./src/scheduler/mod_deps ./src/scheduler/
COPY ./src/ununpack/mod_deps ./src/ununpack/
COPY ./src/wget_agent/mod_deps ./src/wget_agent/
COPY ./install/scripts/php-conf-fix.sh ./install/scripts/php-conf-fix.sh
COPY ./utils/install_composer.sh ./utils/install_composer.sh
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive /fossology/utils/fo-installdeps --everything -y \
&& rm -rf /var/lib/apt/lists/* \
&& /fossology/install/scripts/php-conf-fix.sh --overwrite \
&& /fossology/utils/install_composer.sh
COPY . .
RUN make install && make clean
# the database is filled in the entrypoint
RUN /usr/local/lib/fossology/fo-postinstall --agent --common --scheduler-only --web-only --no-running-database
# configure apache
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 \
&& mkdir -p /var/log/apache2/ \
&& ln -sf /proc/self/fd/1 /var/log/apache2/access.log \
&& ln -sf /proc/self/fd/1 /var/log/apache2/error.log
EXPOSE 80
RUN chmod +x /fossology/install/docker-compose.docker-entrypoint.sh
ENTRYPOINT ["/fossology/install/docker-compose.docker-entrypoint.sh"]
#!/bin/bash
# FOSSology docker-entrypoint script
# Copyright Siemens AG 2016, fabio.huser@siemens.com
# Copyright TNG Technology Consulting GmbH 2016, maximilian.huber@tngtech.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
set -o errexit -o nounset -o pipefail
db_host="${FOSSOLOGY_DB_HOST:-localhost}"
db_name="${FOSSOLOGY_DB_NAME:-fossology}"
db_user="${FOSSOLOGY_DB_USER:-fossy}"
db_password="${FOSSOLOGY_DB_PASSWORD:-fossy}"
# Write configuration
cat <<EOM > /usr/local/etc/fossology/Db.conf
dbname=$db_name;
host=$db_host;
user=$db_user;
password=$db_password;
EOM
sed -i 's/address = .*/address = '"${FOSSOLOGY_SCHEDULER_HOST:-localhost}"'/' \
/usr/local/etc/fossology/fossology.conf
# Startup DB if needed or wait for external DB
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 '*****************************************************'
sleep 5
/etc/init.d/postgresql start
else
test_for_postgres() {
PGPASSWORD=$db_password psql -h "$db_host" "$db_name" "$db_user" -c '\l' >/dev/null
return $?
}
until test_for_postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
fi
# Setup environment
if [[ $# -eq 0 || ($# -eq 1 && "$1" == "scheduler") ]]; then
/usr/local/lib/fossology/fo-postinstall --database --licenseref
fi
# Start Fossology
echo
echo 'Fossology initialisation complete; Starting up...'
echo
if [[ $# -eq 0 ]]; then
/etc/init.d/fossology start
/usr/local/share/fossology/scheduler/agent/fo_scheduler \
--log /dev/stdout \
--verbose=3 \
--reset &
/usr/sbin/apache2ctl -D FOREGROUND
elif [[ $# -eq 1 && "$1" == "scheduler" ]]; then
exec /usr/local/share/fossology/scheduler/agent/fo_scheduler \
--log /dev/stdout \
--verbose=3 \
--reset
elif [[ $# -eq 1 && "$1" == "web" ]]; then
exec /usr/sbin/apache2ctl -e info -D FOREGROUND
else
exec "$@"
fi
#!/usr/bin/env bash
set -ex
#### build image
docker build -t fossology/fossology-test .
#### create network
docker network create --subnet=172.18.0.0/16 fossology-testnet
set -o errexit -o nounset -o xtrace
#### create container and set IP
docker create --name fossology-test --net fossology-testnet --ip 172.18.0.22 fossology/fossology-test
#### build image
docker-compose build --force-rm web
#### start container
docker start fossology-test
readonly CONTAINER_ID="$(docker run --rm -p 127.0.0.1::80 -d fossology)"
#### is container running
docker ps | grep -q fossology-test
#### is container running?
docker inspect -f "{{.State.Running}}" "${CONTAINER_ID}" | grep -q true
#### fossology needs up to 15 seconds to startup
sleep 15
readonly HOST="$(docker port "${CONTAINER_ID}" 80)"
#### is fossology reachable? --> check title
curl -L -s http://172.18.0.22/repo/ | grep -q "<title>Getting Started with FOSSology</title>"
curl --silent --location "http://${HOST}/repo/" | grep -q "<title>Getting Started with FOSSology</title>"
#### test whether the scheduler is running
docker exec -it fossology-test /usr/local/share/fossology/scheduler/agent/fo_cli -S
docker exec -it "${CONTAINER_ID}" /usr/local/share/fossology/scheduler/agent/fo_cli -S
docker stop "${CONTAINER_ID}"
#!/usr/bin/env bash
set -ex
cd install
set -o errexit -o nounset -o xtrace
docker-compose build --force-rm
docker-compose up -d
......@@ -8,8 +7,12 @@ docker-compose up -d
#### fossology needs up to 15 seconds to startup
sleep 15
readonly HOST="$(docker-compose port web 80)"
#### is fossology reachable? --> check title
curl -L -s http://127.0.0.1:8081/repo/ | grep -q "<title>Getting Started with FOSSology</title>"
curl --silent --location "http://${HOST}/repo/" | grep -q "<title>Getting Started with FOSSology</title>"
#### test whether the scheduler is running
docker exec -it install_fossology-scheduler_1 /usr/local/share/fossology/scheduler/agent/fo_cli -S
docker-compose exec scheduler /usr/local/share/fossology/scheduler/agent/fo_cli -S
docker-compose down
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment