From: Pablo Zmdl Date: Fri, 4 Apr 2025 12:56:54 +0000 (+0200) Subject: An image for development of Roundcubemail X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=d18cc239f192ea7e4668e24db3bdb3a9a15ed8c2;p=roundcube-roundcubemail-docker.git An image for development of Roundcubemail --- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 187b6fa..9659ce3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,6 +56,10 @@ jobs: docker-tag: roundcube/roundcubemail:1.6.x-fpm-alpine-nonroot,roundcube/roundcubemail:1.6.10-fpm-alpine-nonroot,roundcube/roundcubemail:latest-fpm-alpine-nonroot test-tag: roundcube/roundcubemail:latest-fpm-alpine-nonroot target: 'nonroot' + - variant: 'development' + test-files: 'development' + docker-tag: roundcube/roundcubemail:development + test-tag: roundcube/roundcubemail:development steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/development/Dockerfile b/development/Dockerfile new file mode 100644 index 0000000..d4aba85 --- /dev/null +++ b/development/Dockerfile @@ -0,0 +1,31 @@ +FROM docker.io/roundcube/roundcubemail:latest-apache-nonroot + +ENV DEBIAN_FRONTEND=noninteractive + +USER root + +RUN apt-get update \ + && apt-get install -y --no-install-recommends npm git sudo \ + && apt-get clean + +COPY --chmod=0755 docker-entrypoint.sh / + +# Prevent the upstream image from overwriting our code +RUN rm -r /usr/src/roundcubemail + +RUN install -d -o www-data -g www-data /var/roundcube + +# Pre-download js dependencies (these don't change much over time). +ENV CACHEDIR=/var/cache/roundcubemail/jsdeps +RUN install -o www-data -d "$CACHEDIR" + +USER www-data + +# We need the code from the repo, not from a released tarball. +RUN cd /tmp \ + && curl -OLs https://github.com/roundcube/roundcubemail/archive/refs/heads/master.zip \ + && unzip -q master.zip \ + && ./roundcubemail-master/bin/install-jsdeps.sh \ + && rm -rf master.zip roundcubemail-master + +VOLUME /var/www/html diff --git a/development/docker-entrypoint.sh b/development/docker-entrypoint.sh new file mode 100644 index 0000000..7c24ef3 --- /dev/null +++ b/development/docker-entrypoint.sh @@ -0,0 +1,53 @@ +#!/bin/bash -ex + +if [[ ! -f index.php ]]; then + echo "Error: No source code in /var/www/html – you must mount your code base to that path!" + exit 1 +fi + +if [[ "$1" != apache2* && "$1" != php-fpm && "$1" != bin* ]]; then + exec $@ +fi + +# Ensure two very essential requirements are set in the config file. +if ! grep -q "log_driver.*stdout" config/config.inc.php; then + echo "\$config['log_driver'] = 'stdout';" >> config/config.inc.php +fi +if ! grep -q "db_dsnw" config/config.inc.php; then + echo "\$config['db_dsnw'] = 'sqlite:////var/roundcube/sqlite.db?mode=0644';" >> config/config.inc.php +fi + +# Run the steps necessary to actually use the repository code. + +# Install dependencies +if [[ ! -f composer.json ]]; then + # For older versions of Roundcubemail. + cp -v composer.json-dist composer.json +fi +composer --prefer-dist --no-interaction --optimize-autoloader install + +# Download external Javascript dependencies. +bin/install-jsdeps.sh + +# Translate elastic's styles to CSS. +if grep -q css-elastic Makefile; then + make css-elastic +else + # Older versions + ( + npm install less && \ + npm install less-plugin-clean-css && \ + cd skins/elastic && \ + npx lessc --clean-css="--s1 --advanced" styles/styles.less > styles/styles.min.css && \ + npx lessc --clean-css="--s1 --advanced" styles/print.less > styles/print.min.css && \ + npx lessc --clean-css="--s1 --advanced" styles/embed.less > styles/embed.min.css \ + ) +fi + +# Update cache-buster parameters in CSS-URLs. +bin/updatecss.sh + +# Initialize or update the database. +sudo -u www-data bin/initdb.sh --dir=$PWD/SQL --update || echo "Failed to initialize/update the database. Please start with an empty database and restart the container." + +exec apache2-foreground