diff --git a/docker-compose.build.yml b/docker-compose.build.yml index 3de06dd4..d6ef903d 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -1,12 +1,17 @@ version: '3' services: swoole: build: context: ./docker/swoole/ container_name: kolab-swoole image: apheleia/swoole:4.8.x tests: build: context: ./docker/tests/ container_name: kolab-tests image: kolab-tests + roundcube: + build: + context: ./docker/roundcube/ + container_name: kolab-roundcube + image: kolab-roundcube diff --git a/docker/roundcube/Dockerfile b/docker/roundcube/Dockerfile new file mode 100644 index 00000000..c080dbb5 --- /dev/null +++ b/docker/roundcube/Dockerfile @@ -0,0 +1,44 @@ +FROM fedora:35 + +ARG ROUNDCUBE_VERSION=v4.11.1 +ENV HOME=/opt/app-root/src + +LABEL io.k8s.description="Roundcube" \ + io.k8s.display-name="Roundcube ${ROUNDCUBE_VERSION}" \ + io.openshift.expose-services="80:http" \ + io.openshift.tags="builder,php,roundcube" + +RUN dnf -y update +RUN dnf -y install \ + composer \ + diffutils \ + file \ + git \ + make \ + npm \ + openssl-devel \ + patch \ + php-cli \ + php-common \ + php-devel \ + php-ldap \ + php-opcache \ + php-pecl-apcu \ + php-mysqlnd \ + httpd + +RUN id default || (groupadd -g 1001 default && useradd -d /opt/app-root/ -u 1001 -g 1001 default) + +USER 1001 + +WORKDIR ${HOME} + +ADD buildrouncubemail.sh +RUN ./buildrouncubemail.sh +#RUN rm buildrouncubemail.sh + +COPY /rootfs / + +EXPOSE 80 + +CMD [ "/usr/local/bin/usage" ] diff --git a/docker/roundcube/buildroundcubemail.sh b/docker/roundcube/buildroundcubemail.sh new file mode 100755 index 00000000..1aa58bff --- /dev/null +++ b/docker/roundcube/buildroundcubemail.sh @@ -0,0 +1,277 @@ +#!/bin/bash + +set -e + +VERSION=1.5.2 +GIT_REF=1.5.2 +NAME=roundcubemail-$VERSION +SKINS=(kolab plesk) + +if [ -x "/usr/local/bin/lessc" ]; then + LESSC=/usr/local/bin/lessc +else + LESSC=~/node_modules/less/bin/lessc +fi + + +ROOT_DIR=$(pwd) + +rm -Rf /tmp/$NAME +mkdir /tmp/$NAME +cd /tmp/$NAME + +cat << EOF > ./composer.json +{ + "name": "roundcube/roundcubemail", + "description": "The Roundcube Webmail suite", + "license": "GPL-3.0+", + "config": { + "platform": { + "php": "7.2.24" + } + }, + "repositories": [ + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_activesync", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_addressbook", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_auth", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_config", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_files", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_folders", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_notes", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_tags", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/kolab_chat", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/odfviewer", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/pdfviewer", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/tasklist", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/calendar", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/libcalendaring", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "$PWD/roundcubemail-plugins-kolab-latest/plugins/libkolab", + "options": { + "symlink": false + } + }, + { + "type": "composer", + "url": "https://plugins.roundcube.net" + } + ], + "require": { + "php": ">=5.4.0 <8", + "pear/pear-core-minimal": "~1.10.1", + "pear/auth_sasl": "~1.1.0", + "pear/net_idna2": "~0.2.0", + "pear/mail_mime": "~1.10.0", + "pear/http_request2": "~2.3.0", + "pear/net_smtp": "~1.8.1", + "pear/crypt_gpg": "~1.6.3", + "pear/net_sieve": "~1.4.3", + "roundcube/plugin-installer": "~0.2.0", + "masterminds/html5": "~2.5.0", + "endroid/qr-code": "~1.6.5", + "kolab/calendar": "~3.5.9", + "kolab/kolab_activesync": "~3.5.6", + "kolab/kolab_addressbook": "~3.5.6", + "kolab/kolab_auth": "~3.5.6", + "kolab/kolab_chat": "~3.5.2", + "kolab/kolab_config": "~3.4.0", + "kolab/kolab_files": "~3.5.2", + "kolab/kolab_folders": "~3.5.2", + "kolab/kolab_notes": "~3.5.5", + "kolab/kolab_tags": "~3.5.2", + "kolab/net_ldap3": "~1.1.1", + "kolab/odfviewer": "~3.4.0", + "kolab/pdfviewer": "~3.4.0", + "kolab/tasklist": "~3.5.9", + "johndoh/contextmenu": "~3.2.1", + "zf1/zend-json": "~1.12.11", + "zf1/zend-log": "~1.12.11", + "zf1/zend-controller": "~1.12.11", + "sabre/dav" : "~2.1.6", + "smarty/smarty" : "~3.1.7" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^5.7.21" + }, + "suggest": { + "mkopinsky/zxcvbn-php": "^4.4.2 required for Zxcvbn password strength driver" + } +} +EOF + +rm -f $NAME.tar.gz +[ -d "$NAME" ] && rm -rf "$NAME" +git clone --branch release-1.4 https://github.com/roundcube/roundcubemail.git $NAME +pushd $NAME +git reset --hard $GIT_REF +popd + +[ -d roundcubemail-skin-elastic ] && rm -rf roundcubemail-skin-elastic +git clone --branch master ssh://git@git.kolab.org/source/roundcubemail-skin-elastic.git roundcubemail-skin-elastic + +[ -d roundcubemail-plugins-kolab-latest ] && rm -rf roundcubemail-plugins-kolab-latest +git clone --branch master ssh://git@git.kolab.org/diffusion/RPK/roundcubemail-plugins-kolab.git roundcubemail-plugins-kolab-latest + +# Run composer and other install processes +mv composer.json $NAME/composer.json +pushd $NAME +composer install + # composer dump autoload? +bin/install-jsdeps.sh + +# May require an "npm install less" and "npm install less-plugin-clean-css" +pushd skins/elastic +$LESSC -x styles/styles.less > styles/styles.css +$LESSC -x styles/print.less > styles/print.css +$LESSC -x styles/embed.less > styles/embed.css +popd +$LESSC --clean-css="--s1 --advanced" --rewrite-urls=all plugins/libkolab/skins/elastic/libkolab.less > plugins/libkolab/skins/elastic/libkolab.min.css + +bin/updatecss.sh --dir skins/elastic + +popd + +# Install skins +for skin in "${SKINS[@]}"; do + cp -r "roundcubemail-skin-elastic/$skin" $NAME/skins/ +done + +pushd $NAME + +for skin in $(ls -1d skins/* | grep -vE '(classic|elastic|larry)'); do + skin=$(basename $skin) + + # Copy elastic skin over $skin (but don't overwrite what already existis) + find \ + ./skins/elastic/ \ + ./plugins/libkolab/skins/elastic/ \ + -type f | sort | while read file; do + target_dir=$(dirname ${file} | sed -e 's|%{datadir}|.|g' -e 's|./public_html/assets/|./|g' -e 's|./public_html/assets/plugins/libkolab/|./|g' -e "s/elastic/$skin/g") + file_name=$(basename ${file}) + echo "Target: $target_dir, file $file_name" + if [ ! -d ${target_dir} ]; then + mkdir -p ${target_dir} + fi + if [ ! -f "${target_dir}/${file_name}" ]; then + cp -av "${file}" "${target_dir}" + fi + done + + # Replace elastic references, but don't change the depends value in meta.json + sed -i -e "s/\"elastic\"/\"$skin\"/g" \ + $(find skins/$skin/ plugins/libkolab/skins/$skin/ -type f -not -name "meta.json") + + pushd skins/$skin + $LESSC -x styles/styles.less > styles/styles.css + $LESSC -x styles/print.less > styles/print.css + $LESSC -x styles/embed.less > styles/embed.css + popd + $LESSC --clean-css="--s1 --advanced" --rewrite-urls=all plugins/libkolab/skins/$skin/libkolab.less > plugins/libkolab/skins/$skin/libkolab.min.css + + #find . | sort + + # Compile and compress the CSS + #for file in `find . -type f -name "styles.less" -o -name "print.less" -o -name "embed.less" -o -name "libkolab.less"`; do + # %{_bindir}/lessc --relative-urls ${file} > $(dirname ${file})/$(basename ${file} .less).css + # + # sed -i \ + # -e "s|../../../skins/plesk/images/contactpic.png|../../../../skins/plesk/images/contactpic.png|" \ + # -e "s|../../../skins/plesk/images/watermark.jpg|../../../../skins/plesk/images/watermark.jpg|" \ + # $(dirname ${file})/$(basename ${file} .less).css + # + # cat $(dirname ${file})/$(basename ${file} .less).css + #done + + bin/updatecss.sh --dir skins/$skin +done + +popd + +tar --exclude="$NAME/.git" -czf "$ROOT_DIR/$NAME.tar.gz" $NAME + +cd "$PWD" diff --git a/docker/roundcube/do-it-again.sh b/docker/roundcube/do-it-again.sh new file mode 100755 index 00000000..88f661c0 --- /dev/null +++ b/docker/roundcube/do-it-again.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +export CACHE_DRIVER="array" +export COMPOSER_ARGS="--no-dev" +export DB_CONNECTION="sqlite" +export DB_DATABASE=":memory:" +export GIT_URI=https://git.kolab.org/source/kolab.git +export LARAVEL_ENV=production +export LOG_CHANNEL="stderr" +export MAIL_DRIVER="array" +export QUEUE_CONNECTION="sync" +export SESSION_DRIVER="array" + +docker build -t roundcube . + +docker kill roundcube + +docker rm roundcube + +docker_opts="\ + -e CACHE_DRIVER=${CACHE_DRIVER} \ + -e COMPOSER_ARGS=${COMPOSER_ARGS} \ + -e DB_CONNECTION=${DB_CONNECTION} \ + -e DB_DATABASE=${DB_DATABASE} \ + -e GIT_URI=${GIT_URI} \ + -e LARAVEL_ENV=${LARAVEL_ENV} \ + -e LOG_CHANNEL=${LOG_CHANNEL} \ + -e MAIL_DRIVER=${MAIL_DRIVER} \ + -e QUEUE_CONNECTION=${QUEUE_CONNECTION} \ + -e SESSION_DRIVER=${SESSION_DRIVER}" + +docker run -it \ + ${docker_opts} \ + --name roundcube roundcube /usr/local/bin/build-image + +docker commit roundcube roundcube-s2i + +docker kill roundcube-s2i + +docker rm roundcube-s2i + +docker run -it -p 8000:8000 \ + ${docker_opts} \ + --name roundcube-s2i roundcube-s2i /usr/local/bin/run-container diff --git a/docker/roundcube/rootfs/usr/local/bin/build-image b/docker/roundcube/rootfs/usr/local/bin/build-image new file mode 100755 index 00000000..78f0f37b --- /dev/null +++ b/docker/roundcube/rootfs/usr/local/bin/build-image @@ -0,0 +1,34 @@ +#!/bin/bash + +set -x + +set -e + +pwd + +if [ -z "${GIT_URI}" ]; then + echo "No GIT_URI specified. Exiting." + exit 1 +fi + +git clone -b ${GIT_BRANCH:-master} ${GIT_URI} + +cd $(basename ${GIT_URI} .git) + +if [ ! -z "${APP_SRC}" ]; then + cd ${APP_SRC} +fi + +if [ -f "composer.json" ]; then + echo "Detected composer.json, running install" + php -dmemory_limit=${COMPOSER_MEMORY_LIMIT:--1} /usr/bin/composer install ${COMPOSER_ARGS} + rm -rf ~/.cache/composer/ +fi + +if [ -z "${LARAVEL_ENV}" ]; then + LARAVEL_ENV=prod +fi + +npm install + +npm run ${LARAVEL_ENV} && rm -rf ~/.npm/ diff --git a/docker/roundcube/rootfs/usr/local/bin/run-container b/docker/roundcube/rootfs/usr/local/bin/run-container new file mode 100755 index 00000000..f565ce15 --- /dev/null +++ b/docker/roundcube/rootfs/usr/local/bin/run-container @@ -0,0 +1,42 @@ +#!/bin/bash + +set -x + +set -e + +if [ -z "$@" ]; then + cd $(basename ${GIT_URI} .git) + + if [ ! -z "${APP_SRC}" ]; then + cd ${APP_SRC} + fi + + if [ ! -f ".env" -a -f ".env.example" ]; then + mv .env.example .env + fi + + if [ -z "${APP_KEY}" ]; then + ./artisan key:generate + unset APP_KEY + fi + + if [ -z "${JWT_SECRET}" ]; then + ./artisan jwt:secret -f + fi + + ./artisan clear-compiled + + # This should not occur in production + #./artisan cache:clear + + # A standalone environment doesn't have anything to ping + #timeout 10m ./artisan db:ping --wait + + ./artisan migrate + + env + + exec ./artisan octane:start +else + exec $@ +fi