aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorDavid Siegfried <david.siegfried@uni-vechta.de>2022-06-21 09:04:10 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2022-06-21 09:04:10 +0000
commit8ce1b740c144abf8855b5ea7580d09be6af467fa (patch)
treeee0ec1e1f2a73ce40f3f046b0b8f44e823ad8fb2 /docker
parentb333f3fa1ea4d661db10e88325152eb2ef5437f3 (diff)
add gitlab-ci, closes #606
Closes #606 Merge request studip/studip!574
Diffstat (limited to 'docker')
-rw-r--r--docker/Readme.md9
-rw-r--r--docker/build_images.sh17
-rw-r--r--docker/release-cli/Dockerfile6
-rw-r--r--docker/studip/Dockerfile60
-rw-r--r--docker/studip/Dockerfile-Dev38
-rw-r--r--docker/studip/config_local.php46
-rw-r--r--docker/studip/docker-entrypoint.sh44
-rw-r--r--docker/tests/php72/Dockerfile24
-rw-r--r--docker/tests/php74/Dockerfile23
9 files changed, 267 insertions, 0 deletions
diff --git a/docker/Readme.md b/docker/Readme.md
new file mode 100644
index 0000000..a4a2a71
--- /dev/null
+++ b/docker/Readme.md
@@ -0,0 +1,9 @@
+# How to build ci images
+
+Use the script `build_images.sh` to build all relevant images for ci pipeline
+You can trigger an automated push to the studip docker repository by providing the string "push" as first argument. (Permission to push to hub.docker.com/studip is required)
+
+`./build_images.sh push`
+
+All images are automatically built for linux/amd64
+\ No newline at end of file \ No newline at end of file
diff --git a/docker/build_images.sh b/docker/build_images.sh
new file mode 100644
index 0000000..1fb09f6
--- /dev/null
+++ b/docker/build_images.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+PUSH=$1
+
+build_image () {
+ docker build -t studip/$2 --platform=linux/amd64 -f $1/Dockerfile .
+ if [[ $PUSH = 'push' ]]; then
+ docker push studip/$2
+ fi
+}
+
+build_image tests/php72 studip:tests-php7.2 &
+build_image tests/php74 studip:tests &
+build_image release-cli release-cli &
+wait
+
+echo "Images built" \ No newline at end of file
diff --git a/docker/release-cli/Dockerfile b/docker/release-cli/Dockerfile
new file mode 100644
index 0000000..4e41152
--- /dev/null
+++ b/docker/release-cli/Dockerfile
@@ -0,0 +1,6 @@
+FROM alpine
+
+RUN apk --no-cache add jq bash curl grep
+
+ADD https://release-cli-downloads.s3.amazonaws.com/latest/release-cli-linux-amd64 /usr/bin/release-cli
+RUN chmod u+x /usr/bin/release-cli \ No newline at end of file
diff --git a/docker/studip/Dockerfile b/docker/studip/Dockerfile
new file mode 100644
index 0000000..ec20ce1
--- /dev/null
+++ b/docker/studip/Dockerfile
@@ -0,0 +1,60 @@
+# Setup php, apache and stud.ip
+FROM php:7.4-apache as base
+
+# Install system requirements
+RUN apt update && apt install -y --no-install-recommends \
+ default-mysql-client \
+ default-libmysqlclient-dev \
+ libcurl4-openssl-dev zlib1g-dev \
+ libpng-dev \
+ libjpeg-dev \
+ libonig-dev \
+ libzip-dev \
+ libicu-dev \
+ vim \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install php extensions
+RUN docker-php-ext-configure gd --with-jpeg
+RUN docker-php-ext-install pdo gettext curl gd mbstring zip pdo pdo_mysql mysqli intl json
+
+FROM node:12 as nodejs
+
+# Install node modules
+COPY . /studip
+WORKDIR /studip
+RUN make webpack-prod
+
+FROM base as build
+
+# Install composer
+COPY --from=composer /usr/bin/composer /usr/bin/composer
+
+# Copy studip
+COPY --from=nodejs /studip /studip
+
+# Execute make to install composer dependencies and build assets
+WORKDIR /studip
+RUN make composer
+
+FROM base
+
+# Reconfigure apache
+ENV APACHE_DOCUMENT_ROOT /var/www/studip/public
+RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
+RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
+
+COPY --from=build /studip /var/www/studip
+
+WORKDIR /var/www/studip
+
+# Add config template
+COPY ./docker/studip/config_local.php ./config/config_local.inc.php
+
+# Add custom entrypoint
+COPY ./docker/studip/docker-entrypoint.sh /usr/local/bin/
+RUN chmod u+x /usr/local/bin/docker-entrypoint.sh
+
+# Set start parameters
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
+CMD ["apache2-foreground"] \ No newline at end of file
diff --git a/docker/studip/Dockerfile-Dev b/docker/studip/Dockerfile-Dev
new file mode 100644
index 0000000..960bd97
--- /dev/null
+++ b/docker/studip/Dockerfile-Dev
@@ -0,0 +1,38 @@
+# Setup php, apache and stud.ip
+FROM php:7.4-apache as base
+
+# Install system requirements
+RUN apt update && apt install -y --no-install-recommends \
+ default-mysql-client \
+ default-libmysqlclient-dev \
+ libcurl4-openssl-dev zlib1g-dev \
+ libpng-dev \
+ libjpeg-dev \
+ libonig-dev \
+ libzip-dev \
+ libicu-dev \
+ vim \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install php extensions
+RUN docker-php-ext-configure gd --with-jpeg
+RUN docker-php-ext-install pdo gettext curl gd mbstring zip pdo pdo_mysql mysqli intl json
+
+
+# Reconfigure apache
+ENV APACHE_DOCUMENT_ROOT /var/www/studip/public
+RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
+RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
+
+WORKDIR /var/www/studip
+
+# Add config template
+ADD ./docker/studip/config_local.php ./config/config_local.inc.php
+
+# Add custom entrypoint
+COPY ./docker/studip/docker-entrypoint.sh /usr/local/bin/
+RUN chmod u+x /usr/local/bin/docker-entrypoint.sh
+
+# Set start parameters
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
+CMD ["apache2-foreground"] \ No newline at end of file
diff --git a/docker/studip/config_local.php b/docker/studip/config_local.php
new file mode 100644
index 0000000..df8187a
--- /dev/null
+++ b/docker/studip/config_local.php
@@ -0,0 +1,46 @@
+<?php
+/*basic settings for Stud.IP
+----------------------------------------------------------------
+you find here the basic system settings. You shouldn't have to touch much of them...
+please note the CONFIG.INC.PHP for the indivual settings of your installation!*/
+
+namespace Studip {
+ //const ENV = 'development';
+ define ('ENV', getenv('ENV') ?? 'development');
+}
+
+namespace {
+ /*settings for database access
+ ----------------------------------------------------------------
+ please fill in your database connection settings.
+ */
+
+ // default Stud.IP database (DB_Seminar)
+ $DB_STUDIP_HOST = getenv('MYSQL_HOST');
+ $DB_STUDIP_USER = getenv('MYSQL_USER');
+ $DB_STUDIP_PASSWORD = getenv('MYSQL_PASSWORD');
+ $DB_STUDIP_DATABASE = getenv('MYSQL_DATABASE');
+
+ /*URL
+ ----------------------------------------------------------------
+ customize if automatic detection fails, e.g. when installation is hidden
+ behind a proxy
+ */
+ //$CANONICAL_RELATIVE_PATH_STUDIP = '/';
+ //$ABSOLUTE_URI_STUDIP = 'https://www.studip.de/';
+ //$ASSETS_URL = 'https://www.studip.de/assets/';
+
+ // Set proxy url
+ if ($PROXY_URL = getenv('PROXY_URL')) {
+ $ABSOLUTE_URI_STUDIP = $PROXY_URL;
+ $ASSETS_URL = $PROXY_URL.'/assets/';
+ unset($PROXY_URL);
+ }
+
+ // Use autoproxy
+ if (getenv('AUTO_PROXY')) {
+ $ABSOLUTE_URI_STUDIP = $_SERVER['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_X_FORWARDED_HOST'].'/';
+ $ASSETS_URL = $ABSOLUTE_URI_STUDIP.'/assets/';
+ }
+ $MAIL_TRANSPORT = getenv('STUDIP_MAIL_TRANSPORT');
+} \ No newline at end of file
diff --git a/docker/studip/docker-entrypoint.sh b/docker/studip/docker-entrypoint.sh
new file mode 100644
index 0000000..bafc2fe
--- /dev/null
+++ b/docker/studip/docker-entrypoint.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -e
+
+STUDIP='/var/www/studip'
+CONFIGFILE="$STUDIP/config/config_local.inc.php"
+DOCKERCONFIGFILE="/config/config_local.inc.php"
+CONF="$STUDIP/config/config.inc.php"
+
+# Check if we have a config
+if [ ! -f $CONFIGFILE ]; then
+ echo "Setting up new config"
+ cp "$DOCKERCONFIGFILE" "$CONFIGFILE"
+ cp "$CONF.dist" "$CONF"
+fi
+
+# wait until MySQL is really available
+maxcounter=45
+
+counter=1
+while ! mysql -u $MYSQL_USER -h $MYSQL_HOST -p$MYSQL_PASSWORD -e "show databases;" > /dev/null 2>&1; do
+ sleep 1
+ counter=`expr $counter + 1`
+ if [ $counter -gt $maxcounter ]; then
+ echo "We have been waiting for MySQL too long already; failing." >&2
+ exit 1
+ fi;
+done
+
+sh $STUDIP/.gitlab/scripts/install_db.sh
+
+if [ ! -z $AUTO_MIGRATE ]; then
+ echo "Migrate Instance"
+ # If migrate fails start instance anyway
+ php "$STUDIP/cli/studip migrate" || true
+ echo "Migration finished"
+fi
+
+# first arg is `-f` or `--some-option`
+if [ "${1#-}" != "$1" ]; then
+ set -- apache2-foreground "$@"
+fi
+
+exec "$@"
+
diff --git a/docker/tests/php72/Dockerfile b/docker/tests/php72/Dockerfile
new file mode 100644
index 0000000..796d064
--- /dev/null
+++ b/docker/tests/php72/Dockerfile
@@ -0,0 +1,24 @@
+# Setup php, apache and stud.ip
+FROM php:7.2-cli
+
+# Install system requirements
+RUN apt update && apt install -y --no-install-recommends \
+ default-mysql-client default-libmysqlclient-dev libcurl4-openssl-dev zlib1g-dev libpng-dev libjpeg-dev libonig-dev libzip-dev libicu-dev \
+ lsb-release \
+ zip \
+ tar \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install php extensions
+RUN docker-php-ext-configure gd --with-png-dir=/usr/include/ \
+ --with-jpeg-dir=/usr/include/
+RUN docker-php-ext-install pdo gettext curl gd mbstring zip pdo pdo_mysql mysqli intl json
+
+# Install npm using nvm
+RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
+RUN apt update && apt install -y --no-install-recommends nodejs \
+ curl apt-transport-https ca-certificates gnupg unzip git \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install composer
+COPY --from=composer /usr/bin/composer /usr/bin/composer
diff --git a/docker/tests/php74/Dockerfile b/docker/tests/php74/Dockerfile
new file mode 100644
index 0000000..7d77515
--- /dev/null
+++ b/docker/tests/php74/Dockerfile
@@ -0,0 +1,23 @@
+# Setup php, apache and stud.ip
+FROM php:7.4-cli
+
+# Install system requirements
+RUN apt update && apt install -y --no-install-recommends \
+ default-mysql-client default-libmysqlclient-dev libcurl4-openssl-dev zlib1g-dev libpng-dev libjpeg-dev libonig-dev libzip-dev libicu-dev \
+ lsb-release \
+ zip \
+ tar \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install php extensions
+RUN docker-php-ext-configure gd --with-jpeg
+RUN docker-php-ext-install pdo gettext curl gd mbstring zip pdo pdo_mysql mysqli intl json
+
+# Install npm using nvm
+RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
+RUN apt update && apt install -y --no-install-recommends nodejs \
+ curl apt-transport-https ca-certificates gnupg unzip git \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install composer
+COPY --from=composer /usr/bin/composer /usr/bin/composer