From c922797429e6c078a2c659a6a79284e498244533 Mon Sep 17 00:00:00 2001 From: Philipp Le Date: Sun, 21 Feb 2021 01:52:03 +0100 Subject: fix: Build image on our own from Debian 9 Some packages were missing in the older approach. So we have set up the image from a plain Debian 9 Slim image and installed PHP7 and all required packages on owr own. --- .gitignore | 2 ++ Dockerfile | 34 ++++++++++++++++++++++++++----- README.md | 15 ++++++++++++++ baikal.env | 4 ---- bin/runapache2 | 33 ++++++++++++++++++++++++++++++ docker-compose.yml | 53 ++++++++++++++++++++++++++++-------------------- resources/baikal.apache2 | 22 ++++++++++++++++++++ sample.env | 7 +++++++ 8 files changed, 139 insertions(+), 31 deletions(-) create mode 100644 .gitignore create mode 100644 README.md delete mode 100644 baikal.env create mode 100755 bin/runapache2 create mode 100644 resources/baikal.apache2 create mode 100644 sample.env diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9df269f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +volumes/ diff --git a/Dockerfile b/Dockerfile index f3140e3..151241d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,38 @@ -FROM php:7.4-apache AS intermediate +FROM debian:9-slim RUN apt-get update RUN apt-get install -y curl RUN apt-get install -y unzip +RUN apt-get install -y apache2 +RUN apt-get install -y rsyslog +RUN apt-get install -y sqlite3 +RUN apt-get install -y php +RUN apt-get install -y libapache2-mod-php +RUN apt-get install -y php-date +RUN apt-get install -y php-dompdf +RUN apt-get install -y php-mbstring +RUN apt-get install -y php-sqlite3 +RUN apt-get install -y php-mysql +RUN apt-get install -y php-dom + WORKDIR /src RUN curl -LO https://github.com/fruux/Baikal/releases/download/0.4.6/baikal-0.4.6.zip && unzip baikal-0.4.6.zip && rm -f baikal-0.4.6.zip RUN rm -r baikal/Specific/* +RUN mkdir -p /var/www/ +RUN mv /src/baikal/* /var/www/html/ -FROM php:7.4-apache - -COPY --from=intermediate /src/baikal/* /var/www/html/ -WORKDIR /var/www/html VOLUME /var/www/html/Specific + +WORKDIR /etc/apache2/sites-available +RUN /etc/init.d/apache2 stop ; a2enmod rewrite +RUN mv -f 000-default.conf .. +COPY resources/baikal.apache2 /etc/apache2/sites-available/000-default.conf +RUN echo "error_log = syslog" >> /etc/php/7.0/apache2/php.ini + +WORKDIR / +COPY bin/runapache2 / + +RUN awk '/vim: syntax/ { printf("# Poxy; CVE-2016-5387\nLoadModule headers_module /usr/lib/apache2/modules/mod_headers.so\nRequestHeader unset Proxy early\n%s\n", $0); next; } { print; }' /etc/apache2/apache2.conf > /tmp/apache2.conf +RUN cat /tmp/apache2.conf > /etc/apache2/apache2.conf && rm /tmp/apache2.conf + +ENTRYPOINT [ "/runapache2" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..c637b5c --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +Based on: [https://github.com/pr3d4t0r/calendar](https://github.com/pr3d4t0r/calendar) + +# Installation + +``` +docker-compose build +mkdir -p volumes/Specific/db +chown -R 33:33 volumes/Specific +``` + +# Start + +``` +docker-compose up -d +``` diff --git a/baikal.env b/baikal.env deleted file mode 100644 index 918c6d3..0000000 --- a/baikal.env +++ /dev/null @@ -1,4 +0,0 @@ -MYSQL_ROOT_PASSWORD=verysecurepassword -MYSQL_DATABASE=baikal -MYSQL_USER=baikal -MYSQL_PASSWORD=somepassword diff --git a/bin/runapache2 b/bin/runapache2 new file mode 100755 index 0000000..f1aaa84 --- /dev/null +++ b/bin/runapache2 @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright (c) 2016 by CIME Software Ltd. All rights reserved. + +# See: LICENSE.txt for complete licensing information. + + +if [[ -n "$CONTAINER_DOMAIN_NAME" ]] +then + DOMAIN_NAME="$CONTAINER_DOMAIN_NAME" +else + DOMAIN_NAME="example.org" +fi + +if [[ -n "$CONTAINER_HOST_NAME" ]] +then + HOST_NAME="$CONTAINER_HOST_NAME" +else + HOST_NAME="calendar" +fi + +hostname "$HOST_NAME.$DOMAIN_NAME" +domainname "$DOMAIN_NAME" + +source /etc/apache2/envvars + +mkdir -p "$APACHE_LOCK_DIR" +mkdir -p "$APACHE_RUN_DIR" + +service rsyslog start + +/usr/sbin/apache2 -DFOREGROUND + diff --git a/docker-compose.yml b/docker-compose.yml index 63e731b..7a7d6fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,26 +1,35 @@ version: '3.3' services: - db: - image: mysql:5.7 - volumes: - - ./volumes/db:/var/lib/mysql - restart: always - env_file: - - baikal.env + db: + image: mysql:5.7 + volumes: + - ./volumes/db:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} - baikal: - depends_on: - - db - build: - context: . - dockerfile: Dockerfile - ports: - - "8080:80" - restart: always - labels: - - traefik.http.middlewares.strip-baikal.stripprefix.prefixes=/baikal - - traefik.http.routers.baikal.rule=(Host(`example.org`) || Host(`www.example.org`) && PathPrefix(`baikal`) - - traefik.http.routers.baikal.middlewares=strip-baikal@docker - volumes: - - ./volumes/Specific:/var/www/html/Specific + baikal: + depends_on: + - db + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:80" + environment: + CONTAINER_DOMAIN_NAME: ${DOMAIN_NAME} + CONTAINER_HOST_NAME: ${HOST_NAME} + restart: always + labels: + - "traefik.http.routers.baikal.rule=Host(`${HOST_NAME}.${DOMAIN_NAME}`)" + - "traefik.http.middlewares.baikal-path.replacepathregex.regex=^/${PATH_PREFIX}/(.*)" + - "traefik.http.middlewares.baikal-path.replacepathregex.replacement=/$$1" + - "traefik.http.routers.baikal-nosub.rule=(Host(`${DOMAIN_NAME}`) || Host(`www.${DOMAIN_NAME}`) && PathPrefix(`${PATH_PREFIX}`)" + - "traefik.http.routers.baikal-nosub.middlewares=baikal-path@docker" + - "traefik.http.routers.baikal-wellknown.rule=(Host(`${DOMAIN_NAME}`) || Host(`www.${DOMAIN_NAME}`) && (Path(`.well-known/caldav`) || Path(`.well-known/carddav`))" + volumes: + - ./volumes/Specific:/var/www/html/Specific diff --git a/resources/baikal.apache2 b/resources/baikal.apache2 new file mode 100644 index 0000000..6572b1f --- /dev/null +++ b/resources/baikal.apache2 @@ -0,0 +1,22 @@ +ServerName calendar.example.org + + + DocumentRoot /var/www/html/html + ServerName calendar.example.org + + RewriteEngine On + RewriteRule /.well-known/carddav /dav.php [R,L] + RewriteRule /.well-known/caldav /dav.php [R,L] + + + Options None + Options +FollowSymlinks + AllowOverride All + + Require all granted + + + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet + diff --git a/sample.env b/sample.env new file mode 100644 index 0000000..6c86ec6 --- /dev/null +++ b/sample.env @@ -0,0 +1,7 @@ +MYSQL_ROOT_PASSWORD=verysecurepassword +MYSQL_DATABASE=baikal +MYSQL_USER=baikal +MYSQL_PASSWORD=somepassword +DOMAIN_NAME=example.org +HOST_NAME=cal +PATH_PREFIX=baikal -- cgit v1.1