commit 296216444a6bffd321f01031373b5272a40c6268 Author: franv Date: Thu Aug 13 13:50:56 2020 -0700 first commit diff --git a/000-default.conf b/000-default.conf new file mode 100644 index 0000000..5702d89 --- /dev/null +++ b/000-default.conf @@ -0,0 +1,22 @@ + + ServerAdmin webmaster@localhost + DocumentRoot /opt/kimai/public + + PassEnv DATABASE_PREFIX + PassEnv MAILER_FROM + PassEnv APP_ENV + PassEnv APP_SECRET + PassEnv DATABASE_URL + PassEnv MAILER_URL + PassEnv TRUSTED_PROXIES + PassEnv TRUSTED_HOSTS + + + Require all granted + DirectoryIndex index.php + AllowOverride All + + + + +ServerName localhost diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5ca8661 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,246 @@ +# _ ___ _ ____ +# | |/ (_)_ __ ___ __ _(_)___ \ +# | ' /| | '_ ` _ \ / _` | | __) | +# | . \| | | | | | | (_| | |/ __/ +# |_|\_\_|_| |_| |_|\__,_|_|_____| +# + +# Source base [fpm-alpine/apache-debian] +ARG BASE="fpm-alpine" + +########################### +# Shared tools +########################### + +# full kimai source +FROM alpine:3.11 AS git-dev +ARG KIMAI="1.8" +RUN apk add --no-cache git && \ + git clone --depth 1 --branch ${KIMAI} https://github.com/kevinpapst/kimai2.git /opt/kimai + +# production kimai source +FROM git-dev AS git-prod +WORKDIR /opt/kimai +RUN rm -r tests + +# composer with prestissimo (faster deps install) +FROM composer:1.9 AS composer +RUN mkdir /opt/kimai && \ + composer require --working-dir=/opt/kimai hirak/prestissimo + + + +########################### +# PHP extensions +########################### + +#fpm alpine php extension base +FROM php:7.4.4-fpm-alpine3.11 AS fpm-alpine-php-ext-base +RUN apk add --no-cache \ + # build-tools + autoconf \ + dpkg \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libatomic \ + libc-dev \ + libgomp \ + libmagic \ + m4 \ + make \ + mpc1 \ + mpfr4 \ + musl-dev \ + perl \ + re2c \ + # gd + freetype-dev \ + libpng-dev \ + # icu + icu-dev \ + # ldap + openldap-dev \ + libldap \ + # zip + libzip-dev \ + # xsl + libxslt-dev + + +# apache debian php extension base +FROM php:7.4.4-apache-buster AS apache-debian-php-ext-base +RUN apt-get update +RUN apt-get install -y \ + libldap2-dev \ + libicu-dev \ + libpng-dev \ + libzip-dev \ + libxslt1-dev \ + libfreetype6-dev + + +# php extension gd - 13.86s +FROM ${BASE}-php-ext-base AS php-ext-gd +RUN docker-php-ext-configure gd \ + --with-freetype && \ + docker-php-ext-install -j$(nproc) gd + +# php extension intl : 15.26s +FROM ${BASE}-php-ext-base AS php-ext-intl +RUN docker-php-ext-install -j$(nproc) intl + +# php extension ldap : 8.45s +FROM ${BASE}-php-ext-base AS php-ext-ldap +RUN docker-php-ext-configure ldap && \ + docker-php-ext-install -j$(nproc) ldap + +# php extension pdo_mysql : 6.14s +FROM ${BASE}-php-ext-base AS php-ext-pdo_mysql +RUN docker-php-ext-install -j$(nproc) pdo_mysql + +# php extension zip : 8.18s +FROM ${BASE}-php-ext-base AS php-ext-zip +RUN docker-php-ext-install -j$(nproc) zip + +# php extension xsl : ?.?? s +FROM ${BASE}-php-ext-base AS php-ext-xsl +RUN docker-php-ext-install -j$(nproc) xsl + + + +########################### +# fpm-alpine base build +########################### + +# fpm-alpine base build +FROM php:7.4.4-fpm-alpine3.11 AS fpm-alpine-base +RUN apk add --no-cache \ + bash \ + freetype \ + haveged \ + icu \ + libldap \ + libpng \ + libzip \ + libxslt-dev && \ + touch /use_fpm + +EXPOSE 9000 + + + +########################### +# apache-debian base build +########################### + +FROM php:7.4.4-apache-buster AS apache-debian-base +COPY 000-default.conf /etc/apache2/sites-available/000-default.conf +RUN apt-get update && \ + apt-get install -y \ + bash \ + haveged \ + libicu63 \ + libpng16-16 \ + libzip4 \ + libxslt1.1 \ + libfreetype6 && \ + echo "Listen 8001" > /etc/apache2/ports.conf && \ + a2enmod rewrite && \ + touch /use_apache + +EXPOSE 8001 + + + +########################### +# global base build +########################### + +FROM ${BASE}-base AS base +LABEL maintainer="tobias@neontribe.co.uk" +LABEL maintainer="bastian@schroll-software.de" + +ARG KIMAI="1.8" +ENV KIMAI=${KIMAI} + +ARG TZ=Europe/Berlin +ENV TZ=${TZ} +RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone && \ + # make composer home dir + mkdir /composer && \ + chown -R www-data:www-data /composer + +# copy startup script +COPY startup.sh /startup.sh + +# copy composer +COPY --from=composer /usr/bin/composer /usr/bin/composer +COPY --from=composer --chown=www-data:www-data /opt/kimai/vendor /opt/kimai/vendor + +# copy php extensions + +# PHP extension xsl +COPY --from=php-ext-xsl /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini +COPY --from=php-ext-xsl /usr/local/lib/php/extensions/no-debug-non-zts-20190902/xsl.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/xsl.so +# PHP extension pdo_mysql +COPY --from=php-ext-pdo_mysql /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini +COPY --from=php-ext-pdo_mysql /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_mysql.so +# PHP extension zip +COPY --from=php-ext-zip /usr/local/etc/php/conf.d/docker-php-ext-zip.ini /usr/local/etc/php/conf.d/docker-php-ext-zip.ini +COPY --from=php-ext-zip /usr/local/lib/php/extensions/no-debug-non-zts-20190902/zip.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/zip.so +# PHP extension ldap +COPY --from=php-ext-ldap /usr/local/etc/php/conf.d/docker-php-ext-ldap.ini /usr/local/etc/php/conf.d/docker-php-ext-ldap.ini +COPY --from=php-ext-ldap /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ldap.so +# PHP extension gd +COPY --from=php-ext-gd /usr/local/etc/php/conf.d/docker-php-ext-gd.ini /usr/local/etc/php/conf.d/docker-php-ext-gd.ini +COPY --from=php-ext-gd /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so +# PHP extension intl +COPY --from=php-ext-intl /usr/local/etc/php/conf.d/docker-php-ext-intl.ini /usr/local/etc/php/conf.d/docker-php-ext-intl.ini +COPY --from=php-ext-intl /usr/local/lib/php/extensions/no-debug-non-zts-20190902/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/intl.so + +ENV DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite +ENV APP_SECRET=change_this_to_something_unique +# The default container name for nginx is nginx +ENV TRUSTED_PROXIES=nginx-proxy,localhost,127.0.0.1 +ENV TRUSTED_HOSTS=nginx-proxy,localhost,127.0.0.1 +ENV MAILER_FROM=kimai@example.com +ENV MAILER_URL=null://localhost +ENV ADMINPASS= +ENV ADMINMAIL= + +VOLUME [ "/opt/kimai/var" ] + +ENTRYPOINT /startup.sh + + + +########################### +# final builds +########################### + +# developement build +FROM base AS dev +# copy kimai develop source +COPY --from=git-dev --chown=www-data:www-data /opt/kimai /opt/kimai +# do the composer deps installation +RUN export COMPOSER_HOME=/composer && \ + composer install --working-dir=/opt/kimai --optimize-autoloader && \ + composer clearcache && \ + composer require --working-dir=/opt/kimai laminas/laminas-ldap && \ + chown -R www-data:www-data /opt/kimai && \ + sed "s/128M/256M/g" /usr/local/etc/php/php.ini-development > /usr/local/etc/php/php.ini +USER www-data + +# production build +FROM base AS prod +# copy kimai production source +COPY --from=git-prod --chown=www-data:www-data /opt/kimai /opt/kimai +# do the composer deps installation +RUN export COMPOSER_HOME=/composer && \ + composer install --working-dir=/opt/kimai --no-dev --optimize-autoloader && \ + composer clearcache && \ + composer require --working-dir=/opt/kimai laminas/laminas-ldap && \ + chown -R www-data:www-data /opt/kimai +USER www-data diff --git a/Dockerfile.good b/Dockerfile.good new file mode 100644 index 0000000..9d2d0e4 --- /dev/null +++ b/Dockerfile.good @@ -0,0 +1,246 @@ +# _ ___ _ ____ +# | |/ (_)_ __ ___ __ _(_)___ \ +# | ' /| | '_ ` _ \ / _` | | __) | +# | . \| | | | | | | (_| | |/ __/ +# |_|\_\_|_| |_| |_|\__,_|_|_____| +# + +# Source base [fpm-alpine/apache-debian] +ARG BASE="fpm-alpine" + +########################### +# Shared tools +########################### + +# full kimai source +FROM alpine:3.11 AS git-dev +ARG KIMAI="1.8" +RUN apk add --no-cache git && \ + git clone --depth 1 --branch ${KIMAI} https://github.com/kevinpapst/kimai2.git /opt/kimai + +# production kimai source +FROM git-dev AS git-prod +WORKDIR /opt/kimai +RUN rm -r tests + +# composer with prestissimo (faster deps install) +FROM composer:1.9 AS composer +RUN mkdir /opt/kimai && \ + composer require --working-dir=/opt/kimai hirak/prestissimo + + + +########################### +# PHP extensions +########################### + +#fpm alpine php extension base +FROM php:7.4.4-fpm-alpine3.11 AS fpm-alpine-php-ext-base +RUN apk add --no-cache \ + # build-tools + autoconf \ + dpkg \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libatomic \ + libc-dev \ + libgomp \ + libmagic \ + m4 \ + make \ + mpc1 \ + mpfr4 \ + musl-dev \ + perl \ + re2c \ + # gd + freetype-dev \ + libpng-dev \ + # icu + icu-dev \ + # ldap + openldap-dev \ + libldap \ + # zip + libzip-dev \ + # xsl + libxslt-dev + + +# apache debian php extension base +FROM php:7.4.4-apache-buster AS apache-debian-php-ext-base +RUN apt-get update +RUN apt-get install -y \ + libldap2-dev \ + libicu-dev \ + libpng-dev \ + libzip-dev \ + libxslt1-dev \ + libfreetype6-dev + + +# php extension gd - 13.86s +FROM ${BASE}-php-ext-base AS php-ext-gd +RUN docker-php-ext-configure gd \ + --with-freetype && \ + docker-php-ext-install -j$(nproc) gd + +# php extension intl : 15.26s +FROM ${BASE}-php-ext-base AS php-ext-intl +RUN docker-php-ext-install -j$(nproc) intl + +# php extension ldap : 8.45s +FROM ${BASE}-php-ext-base AS php-ext-ldap +RUN docker-php-ext-configure ldap && \ + docker-php-ext-install -j$(nproc) ldap + +# php extension pdo_mysql : 6.14s +FROM ${BASE}-php-ext-base AS php-ext-pdo_mysql +RUN docker-php-ext-install -j$(nproc) pdo_mysql + +# php extension zip : 8.18s +FROM ${BASE}-php-ext-base AS php-ext-zip +RUN docker-php-ext-install -j$(nproc) zip + +# php extension xsl : ?.?? s +FROM ${BASE}-php-ext-base AS php-ext-xsl +RUN docker-php-ext-install -j$(nproc) xsl + + + +########################### +# fpm-alpine base build +########################### + +# fpm-alpine base build +FROM php:7.4.4-fpm-alpine3.11 AS fpm-alpine-base +RUN apk add --no-cache \ + bash \ + freetype \ + haveged \ + icu \ + libldap \ + libpng \ + libzip \ + libxslt-dev && \ + touch /use_fpm + +EXPOSE 9000 + + + +########################### +# apache-debian base build +########################### + +FROM php:7.4.4-apache-buster AS apache-debian-base +COPY 000-default.conf /etc/apache2/sites-available/000-default.conf +RUN apt-get update && \ + apt-get install -y \ + bash \ + haveged \ + libicu63 \ + libpng16-16 \ + libzip4 \ + libxslt1.1 \ + libfreetype6 && \ + echo "Listen 8001" > /etc/apache2/ports.conf && \ + a2enmod rewrite && \ + touch /use_apache + +EXPOSE 8001 + + + +########################### +# global base build +########################### + +FROM ${BASE}-base AS base +LABEL maintainer="tobias@neontribe.co.uk" +LABEL maintainer="bastian@schroll-software.de" + +ARG KIMAI="1.8" +ENV KIMAI=${KIMAI} + +ARG TZ=Europe/Berlin +ENV TZ=${TZ} +RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone && \ + # make composer home dir + mkdir /composer && \ + chown -R www-data:www-data /composer + +# copy startup script +COPY startup.sh /startup.sh + +# copy composer +COPY --from=composer /usr/bin/composer /usr/bin/composer +COPY --from=composer --chown=www-data:www-data /opt/kimai/vendor /opt/kimai/vendor + +# copy php extensions + +# PHP extension xsl +COPY --from=php-ext-xsl /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini +COPY --from=php-ext-xsl /usr/local/lib/php/extensions/no-debug-non-zts-20190902/xsl.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/xsl.so +# PHP extension pdo_mysql +COPY --from=php-ext-pdo_mysql /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini +COPY --from=php-ext-pdo_mysql /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_mysql.so +# PHP extension zip +COPY --from=php-ext-zip /usr/local/etc/php/conf.d/docker-php-ext-zip.ini /usr/local/etc/php/conf.d/docker-php-ext-zip.ini +COPY --from=php-ext-zip /usr/local/lib/php/extensions/no-debug-non-zts-20190902/zip.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/zip.so +# PHP extension ldap +COPY --from=php-ext-ldap /usr/local/etc/php/conf.d/docker-php-ext-ldap.ini /usr/local/etc/php/conf.d/docker-php-ext-ldap.ini +COPY --from=php-ext-ldap /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ldap.so +# PHP extension gd +COPY --from=php-ext-gd /usr/local/etc/php/conf.d/docker-php-ext-gd.ini /usr/local/etc/php/conf.d/docker-php-ext-gd.ini +COPY --from=php-ext-gd /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so +# PHP extension intl +COPY --from=php-ext-intl /usr/local/etc/php/conf.d/docker-php-ext-intl.ini /usr/local/etc/php/conf.d/docker-php-ext-intl.ini +COPY --from=php-ext-intl /usr/local/lib/php/extensions/no-debug-non-zts-20190902/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/intl.so + +ENV DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite +ENV APP_SECRET=change_this_to_something_unique +# The default container name for nginx is nginx +ENV TRUSTED_PROXIES=nginx,localhost,127.0.0.1 +ENV TRUSTED_HOSTS=nginx,localhost,127.0.0.1 +ENV MAILER_FROM=kimai@example.com +ENV MAILER_URL=null://localhost +ENV ADMINPASS= +ENV ADMINMAIL= + +VOLUME [ "/opt/kimai/var" ] + +ENTRYPOINT /startup.sh + + + +########################### +# final builds +########################### + +# developement build +FROM base AS dev +# copy kimai develop source +COPY --from=git-dev --chown=www-data:www-data /opt/kimai /opt/kimai +# do the composer deps installation +RUN export COMPOSER_HOME=/composer && \ + composer install --working-dir=/opt/kimai --optimize-autoloader && \ + composer clearcache && \ + composer require --working-dir=/opt/kimai laminas/laminas-ldap && \ + chown -R www-data:www-data /opt/kimai && \ + sed "s/128M/256M/g" /usr/local/etc/php/php.ini-development > /usr/local/etc/php/php.ini +USER www-data + +# production build +FROM base AS prod +# copy kimai production source +COPY --from=git-prod --chown=www-data:www-data /opt/kimai /opt/kimai +# do the composer deps installation +RUN export COMPOSER_HOME=/composer && \ + composer install --working-dir=/opt/kimai --no-dev --optimize-autoloader && \ + composer clearcache && \ + composer require --working-dir=/opt/kimai laminas/laminas-ldap && \ + chown -R www-data:www-data /opt/kimai +USER www-data diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..82f39e5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Toby Batch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c8bfc6f --- /dev/null +++ b/README.md @@ -0,0 +1,147 @@ +# Kimai Dockers + +We provide a set of docker images for the [Kimai v2](https://github.com/kevinpapst/kimai2) project. + +## Upgrading + +The newer kimai instances cache images in the var directory (/opt/kimai/var). +This folder will need to be preserved and mounted into newer builds. +The docker compose file below will handle that but if you didn't save those file you will need to do that manually. + +## Quick start + +### Evaluate + +Run a throw away instance of kimai for evaluation or testing. +This is built against the master branch of the kevinpapst/kimai2 project and runs against a sqlite database inside the container using the built in php server. +When stopped all trace of the docker will disappear. +If you run the lines below you can hit kimai at `http://localhost:8001` and log in with `admin` / `changemeplease` +The test users listed in [the develop section](https://www.kimai.org/documentation/installation.html) also exist. + +```bash +docker run --rm -ti -p 8001:8001 --name kimai2 kimai/kimai2:apache-debian-1.8-dev +docker exec kimai2 rm /opt/kimai/var/data/kimai.sqlite +docker exec kimai2 /opt/kimai/bin/console kimai:reset-dev +docker exec kimai2 /opt/kimai/bin/console kimai:create-user admin admin@example.com ROLE_SUPER_ADMIN changemeplease +``` + +### Production + +Run a production kimai with persistent database in a seperate mysql container. +The best way of doing this is with a docker compose file. +You can hit kimai at `http://localhost:8001` and log in with `superadmin` / `changemeplease`. + +```yaml +version: '3.5' +services: + + sqldb: + image: mysql:5.7 + environment: + - MYSQL_DATABASE=kimai + - MYSQL_USER=kimaiuser + - MYSQL_PASSWORD=kimaipassword + - MYSQL_ROOT_PASSWORD=changemeplease + volumes: + - /var/lib/mysql + command: --default-storage-engine innodb + restart: unless-stopped + healthcheck: + test: mysqladmin -pchangemeplease ping -h localhost + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 + + nginx: + build: compose + ports: + - 8001:80 + volumes: + - ./nginx_site.conf:/etc/nginx/conf.d/default.conf:ro + - public:/opt/kimai/public:ro + restart: unless-stopped + depends_on: + - kimai + healthcheck: + test: wget --spider http://nginx/health || exit 1 + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 + + kimai: + image: kimai/kimai2:fpm-alpine-1.8-prod + environment: + - APP_ENV=prod + - TRUSTED_HOSTS=localhost + - ADMINMAIL=admin@kimai.local + - ADMINPASS=changemeplease + volumes: + - public:/opt/kimai/public + - var:/opt/kimai/var + # - ./ldap.conf:/etc/openldap/ldap.conf:z + # - ./ROOT-CA.pem:/etc/ssl/certs/ROOT-CA.pem:z + restart: unless-stopped + healthcheck: + test: wget --spider http://nginx || exit 1 + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 + + postfix: + image: catatnight/postfix:latest + environment: + maildomain: kimai.local + smtp_user: kimai:kimai + restart: unless-stopped + restart: always + +volumes: + var: + public: +``` + +## Permissions + +If you are mounting the code base into the container (`-v $PWD/kimai:/opt/kimai`) then you will need to fix the permissions on the var folder. + +```bash +docker exec --user root CONTAINER_NAME chown -R www-data:www-data /opt/kimai/var +``` + +or + +```bash +docker-compose --user root exec CONTAINER_NAME chown -R www-data:www-data /opt/kimai/var +``` + +## Runtime Arguments + +The following settings can set at runtime: + +Kimai/symfony core settings, see the symfony and kimai docs for more info on these. + +```bash +DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite +APP_SECRET=change_this_to_something_unique +TRUSTED_PROXIES=nginx,localhost,127.0.0.1 +TRUSTED_HOSTS=nginx,localhost,127.0.0.1 +MAILER_FROM=kimai@example.com +MAILER_URL=null://localhost +``` + +Start up values: + +If set then these values will try and create a new admin user. + +```bash +ADMINPASS= +ADMINMAIL= +``` + +## NGINX and proxying + +While outside the direct responsibility of this project we get a lot of issues reported that relate to proxying with NGINX into the FPM container. +Note that you will need to set the name of your NGINX container to be in the list of TRUSTED_HOSTS when you start the kimai container. diff --git a/ROOT-CA.pem b/ROOT-CA.pem new file mode 100644 index 0000000..4f73503 --- /dev/null +++ b/ROOT-CA.pem @@ -0,0 +1 @@ +# Add your Root CA here diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..3f06f43 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +function usage { + echo + echo "VERSIONS is a space delimited list of branches and or tags." + echo "e.g. 1.7 fixes/foo" + echo + echo " -b The images bases, e.g. apache-debian fpm-alpine" + echo " -t The timezone, e.g. Europe/London" + echo " -s The stages, e.g. dev prod" + echo " -k Do not use Docker Build Kit" + echo " -c Use the docker cache, default behaviour is to add --nocache" + echo " -h Show help" +} + +export DOCKER_BUILDKIT=1 +export TZ=Europe/London +export STAGES="dev prod" +export BASES="apache-debian fpm-alpine" +NOCACHE="--no-cache" + +USAGE="$0 [-t TIMEZONE] [-b BASES] [-s STAGES] [-k] [-c] [-h] VERSIONS" + +while getopts "b:t:s:kch" options; do + case $options in + b) export BASES="$OPTARG";; + s) export STAGES="$OPTARG";; + t) export TZ="$OPTARG";; + k) unset DOCKER_BUILDKIT;; + c) unset NOCACHE;; + h) echo $USAGE; usage; exit 0;; + esac +done + +shift $((OPTIND-1)) +export KIMAIS=$@ + +if [ ! -z "$1" ] && [ -z "$KIMAIS" ]; then + KIMAIS=$@ +fi + +for KIMAI in $KIMAIS; do + for STAGE_NAME in $STAGES; do + for BASE in $BASES; do + docker build $NOCACHE -t kimai/kimai2:${BASE}-${KIMAI}-${STAGE_NAME} --build-arg KIMAI=${KIMAI} --build-arg BASE=${BASE} --build-arg TZ=${TZ} --target=${STAGE_NAME} $(dirname $0)/.. + done + done +done diff --git a/bin/push.sh b/bin/push.sh new file mode 100755 index 0000000..4294330 --- /dev/null +++ b/bin/push.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [ ! -z "$1" ] && [ -z "$KIMAIS" ]; then + KIMAIS=$@ +fi + +for KIMAI in $KIMAIS; do + docker push kimai/kimai2:apache-debian-$KIMAI-dev + docker push kimai/kimai2:fpm-alpine-$KIMAI-dev + docker push kimai/kimai2:apache-debian-$KIMAI-prod + docker push kimai/kimai2:fpm-alpine-$KIMAI-prod + docker push kimai/kimai2:apache-debian-master-dev + docker push kimai/kimai2:fpm-alpine-master-dev + docker push kimai/kimai2:apache-debian-master-prod + docker push kimai/kimai2:fpm-alpine-master-prod +done diff --git a/bin/simple-test.sh b/bin/simple-test.sh new file mode 100755 index 0000000..d547638 --- /dev/null +++ b/bin/simple-test.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +BASEDIR=$(realpath $(dirname $0)/..) +COMPOSEDIR="$BASEDIR/compose" +SLEEP_COUNT=6 +SLEEP_DURATION=5 + +ESC_SEQ="\x1b[" +COL_RESET=$ESC_SEQ"39;49;00m" +COL_RED=$ESC_SEQ"31;01m" +COL_GREEN=$ESC_SEQ"32;01m" +TICK="\xE2\x9C\x94" + +function main { + cleanup all + cleanup volumes + + test_container http://localhost:8001 base apache.dev + test_container http://localhost:8001 base apache.dev apache.prod + test_container http://localhost:8001 base apache.dev mysql + test_container http://localhost:8001 base apache.dev apache.prod mysql + test_container http://localhost:8002 base fpm.dev nginx + test_container http://localhost:8002 base fpm.prod nginx + test_container http://localhost:8002 base fpm.dev nginx mysql + test_container http://localhost:8002 base fpm.prod nginx mysql + test_container http://localhost:8001 base apache.dev ldap + test_container http://localhost:8002 base fpm.dev nginx ldap + + finally +} + +function finally { + cleanup all + cleanup volumes + exit $1 +} + +function test_container { + cleanup kimai + + URL=$1 + cmd=$(make_cmd "${@:2}") + echo -e ${COL_GREEN}${KIMAI} ${@:2}${COL_RESET} starting... + echo $cmd + $cmd 2>&1 > /dev/null + STATUS=$(isready $URL) + if [ "$STATUS" == "FAILED" ]; then + echo -e ${COL_RED}Failed:${COL_RESET} $cmd + finally 1 + fi + # TODO add some function tests + echo -e "\n${COL_GREEN}${TICK} Done.\n${COL_RESET}" +} + +function isready { + count=0 + STATUS=$(check_command $1) + until [ "$STATUS" == 200 ]; do + >&2 echo -n $STATUS", " + count=$(( count + 1 )) + if [ $count -gt $SLEEP_COUNT ]; then + echo FAILED + return + fi + sleep $SLEEP_DURATION + STATUS=$(check_command $1) + done + >&2 echo -n $STATUS + echo $STATUS +} + +function check_command { + echo $(curl -L -s -o /dev/null -w "%{http_code}" $1) +} + +function cleanup { + if [ -z "$1" ]; then + TAG=all + else + TAG=$1 + fi + + case $TAG in + all) + _cleanup kimai_func_tests_;; + postfix) + _cleanup kimai_func_tests_postfix;; + mysql) + _cleanup kimai_func_tests_sqldb;; + kimai) + _cleanup kimai_func_tests_kimai;; + volumes) + for x in $(docker volume ls |grep kimai_func_tests_|awk '{print $1}'); do + docker volume rm $x > /dev/null 2>&1 + done + esac +} + +function _cleanup { + if [ -z "$1" ]; then + echo Cannot run $0 with a target. + return + fi + + for x in $(docker ps -a |grep $1|awk '{print $1}'); do + docker stop $x > /dev/null 2>&1 + docker rm $x > /dev/null 2>&1 + done + +} + +function make_cmd { + cmd="docker-compose -p kimai_func_tests --log-level CRITICAL " + for x in $@; do + cmd="$cmd -f $COMPOSEDIR/docker-compose.$x.yml" + done + cmd="$cmd up -d" + echo $cmd +} + +if [ ! -z "$1" ] && [ -z "$KIMAIS" ]; then + KIMAIS=$@ +fi + +for KIMAI in $KIMAIS; do + export KIMAI + main +done diff --git a/compose/Dockerfile b/compose/Dockerfile new file mode 100644 index 0000000..888ef66 --- /dev/null +++ b/compose/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:alpine + +ADD nginx_site.conf /etc/nginx/conf.d/default.conf diff --git a/compose/README.md b/compose/README.md new file mode 100644 index 0000000..aa87cd7 --- /dev/null +++ b/compose/README.md @@ -0,0 +1,44 @@ + +## Reset and clean + + docker-compose stop && docker-compose rm && docker volume prune + +## Apache/Kimai dev/sqlite + + docker-compose -f docker-compose.base.yml -f docker-compose.apache.dev.yml up + +## Apache/Kimai prod/sqlite + + docker-compose -f docker-compose.base.yml -f docker-compose.apache.prod.yml up + +## Apache/Kimai dev/mysql + + docker-compose -f docker-compose.base.yml -f docker-compose.apache.dev.yml -f docker-compose.mysql.yml up + +## Apache/Kimai prod/mysql + + docker-compose -f docker-compose.base.yml -f docker-compose.apache.prod.yml -f docker-compose.mysql.yml up + +## FPM/Kimai dev/sqlite + + docker-compose -f docker-compose.base.yml -f docker-compose.fpm.dev.yml -f docker-compose.nginx.yml up + +## FPM/Kimai prod/sqlite + + docker-compose -f docker-compose.base.yml -f docker-compose.fpm.prod.yml -f docker-compose.nginx.yml up + +## FPM/Kimai dev/mysql + + docker-compose -f docker-compose.base.yml -f docker-compose.fpm.dev.yml -f docker-compose.nginx.yml -f docker-compose.mysql.yml up + +## FPM/Kimai prod/mysql + + docker-compose -f docker-compose.base.yml -f docker-compose.fpm.prod.yml -f docker-compose.nginx.yml -f docker-compose.mysql.yml up + +## Apache/Kimai dev/sqlite/LDAP + + docker-compose -f docker-compose.base.yml -f docker-compose.apache.dev.yml -f docker-compose.ldap.yml up + +## FPM/Kimai dev/sqlite/LDAP + + docker-compose -f docker-compose.base.yml -f docker-compose.fpm.dev.yml -f docker-compose.nginx.yml -f docker-compose.ldap.yml up diff --git a/compose/docker-compose.apache.dev.yml b/compose/docker-compose.apache.dev.yml new file mode 100644 index 0000000..eba9042 --- /dev/null +++ b/compose/docker-compose.apache.dev.yml @@ -0,0 +1,5 @@ +version: '3.5' +services: + + kimai: + image: kimai/kimai2:apache-debian-$KIMAI-dev diff --git a/compose/docker-compose.apache.prod.yml b/compose/docker-compose.apache.prod.yml new file mode 100644 index 0000000..41a311f --- /dev/null +++ b/compose/docker-compose.apache.prod.yml @@ -0,0 +1,8 @@ +version: '3.5' +services: + + # Apache with sqlite, the dev/evaluate option + kimai: + image: kimai/kimai2:apache-debian-$KIMAI-prod + environment: + - APP_ENV=prod diff --git a/compose/docker-compose.base.yml b/compose/docker-compose.base.yml new file mode 100644 index 0000000..17b620a --- /dev/null +++ b/compose/docker-compose.base.yml @@ -0,0 +1,21 @@ +version: '3.5' +services: + + # Apache with sqlite, the dev/evaluate option + kimai: + environment: + - APP_ENV=dev + - TRUSTED_HOSTS=localhost + - ADMINMAIL=admin@kimai.local + - ADMINPASS=changemeplease + volumes: + - /opt/kimai/var + ports: + - 8001:8001 + restart: unless-stopped + healthcheck: + test: curl -s -o /dev/null http://localhost:8001 || exit 1 + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 diff --git a/compose/docker-compose.fpm.dev.yml b/compose/docker-compose.fpm.dev.yml new file mode 100644 index 0000000..9983572 --- /dev/null +++ b/compose/docker-compose.fpm.dev.yml @@ -0,0 +1,11 @@ +# example composer file for the fpm-alpine image +version: '3.5' +services: + + kimai: + image: kimai/kimai2:fpm-alpine-$KIMAI-dev + volumes: + - fpm-kimai:/opt/kimai + +volumes: + fpm-kimai: diff --git a/compose/docker-compose.fpm.prod.yml b/compose/docker-compose.fpm.prod.yml new file mode 100644 index 0000000..4595d5c --- /dev/null +++ b/compose/docker-compose.fpm.prod.yml @@ -0,0 +1,14 @@ +# example composer file for the fpm-alpine image +version: '3.5' +services: + + kimai: + image: kimai/kimai2:fpm-alpine-$KIMAI-prod + environment: + - APP_ENV=prod + volumes: + - fpm-kimai:/opt/kimai + +volumes: + fpm-kimai: + diff --git a/compose/docker-compose.ldap.yml b/compose/docker-compose.ldap.yml new file mode 100644 index 0000000..37ff499 --- /dev/null +++ b/compose/docker-compose.ldap.yml @@ -0,0 +1,28 @@ +version: '3.5' +services: + + kimai: + volumes: + - ./local.yaml:/opt/kimai/config/packages/local.yaml + + ldap: + image: osixia/openldap:1.3.0 + ports: + - 389:389 + environment: + LDAP_ADMIN_PASSWORD: password123 + volumes: + - ./ldap-seed.ldif:/container/service/slapd/assets/config/bootstrap/ldif/50-bootstrap.ldif + command: --copy-service + + ldapadmin: + image: dinkel/phpldapadmin + links: + - ldap:openldap + ports: + - 8003:80 + environment: + LDAP_SERVER_HOST: ldap + LDAP_SERVER_PORT: 389 + restart: always + diff --git a/compose/docker-compose.mysql.yml b/compose/docker-compose.mysql.yml new file mode 100644 index 0000000..ae09bd2 --- /dev/null +++ b/compose/docker-compose.mysql.yml @@ -0,0 +1,25 @@ +# example composer file for the fpm-alpine image +version: '3.5' +services: + + kimai: + environment: + - DATABASE_URL=mysql://kimaiuser:kimaipassword@sqldb/kimai + + sqldb: + image: mysql:5.7 + environment: + - MYSQL_DATABASE=kimai + - MYSQL_USER=kimaiuser + - MYSQL_PASSWORD=kimaipassword + - MYSQL_ROOT_PASSWORD=changemeplease + volumes: + - /var/lib/mysql + command: --default-storage-engine innodb + restart: unless-stopped + healthcheck: + test: mysqladmin -pchangemeplease ping -h localhost + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 diff --git a/compose/docker-compose.nginx.yml b/compose/docker-compose.nginx.yml new file mode 100644 index 0000000..dfa201b --- /dev/null +++ b/compose/docker-compose.nginx.yml @@ -0,0 +1,35 @@ +# example composer file for the fpm-alpine image +version: '3.5' +services: + + kimai: + volumes: + - fpm-var:/opt/kimai/var + healthcheck: + test: wget --spider http://nginx || exit 1 + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 + + nginx: + build: . + ports: + - 8002:80 + volumes: + - ./nginx_site.conf:/etc/nginx/conf.d/default.conf + restart: unless-stopped + depends_on: + - kimai + volumes: + - fpm-kimai:/opt/kimai + - fpm-var:/opt/kimai/var + healthcheck: + test: wget --spider http://nginx/health || exit 1 + interval: 20s + start_period: 10s + timeout: 10s + retries: 3 + +volumes: + fpm-var: diff --git a/compose/ldap-seed.ldif b/compose/ldap-seed.ldif new file mode 100755 index 0000000..1375831 --- /dev/null +++ b/compose/ldap-seed.ldif @@ -0,0 +1,52 @@ +version: 1 + +# Entry 3: ou=groups,dc=example,dc=org +dn: ou=groups,dc=example,dc=org +objectclass: organizationalUnit +objectclass: top +ou: groups + +# Entry 4: cn=staff,ou=groups,dc=example,dc=org +dn: cn=staff,ou=groups,dc=example,dc=org +cn: staff +gidnumber: 500 +objectclass: posixGroup +objectclass: top + +# Entry 5: ou=users,dc=example,dc=org +dn: ou=users,dc=example,dc=org +objectclass: organizationalUnit +objectclass: top +ou: users + +# Entry 6: cn=Lenny ldap,ou=users,dc=example,dc=org +dn: cn=Lenny ldap,ou=users,dc=example,dc=org +cn: Lenny ldap +gidnumber: 500 +givenname: Lenny +homedirectory: /home/users/lenny +loginshell: /bin/sh +mail: lenny@example.com +objectclass: inetOrgPerson +objectclass: posixAccount +objectclass: top +sn: ldap +uid: lenny +uidnumber: 1000 +userpassword: {MD5}SCyBHaXVtLxtSX/6mEkeOA== + +# Entry 7: uid=billy,dc=example,dc=org +dn: uid=billy,dc=example,dc=org +cn: billy +gecos: Billy User +gidnumber: 14564100 +homedirectory: /home/billy +loginshell: /bin/bash +mail: billy@example.org +objectclass: top +objectclass: posixAccount +objectclass: inetOrgPerson +sn: 3 +uid: billy +uidnumber: 14583102 +userpassword: {SSHA}5et/8Jrdgo55zIIM8fiVw6GEv4bRoBFx diff --git a/compose/local.yaml b/compose/local.yaml new file mode 100644 index 0000000..a42852c --- /dev/null +++ b/compose/local.yaml @@ -0,0 +1,20 @@ +kimai: + ldap: + connection: + host: ldap + username: cn=admin,dc=example,dc=org + password: password123 + user: + baseDn: ou=users,dc=example,dc=org + role: + baseDn: ou=groups,dc=example,dc=org + +security: + providers: + chain_provider: + chain: + providers: [kimai_ldap] + firewalls: + secured_area: + kimai_ldap: ~ + diff --git a/compose/nginx_site.conf b/compose/nginx_site.conf new file mode 100644 index 0000000..00a767b --- /dev/null +++ b/compose/nginx_site.conf @@ -0,0 +1,48 @@ +server { + listen 80; + index index.php; + server_name php-docker.local; + root /opt/kimai/public; + + # cache static asset files + location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { + expires max; + log_not_found off; + } + + # for health checks + location /health { + return 200 'alive'; + add_header Content-Type text/plain; + } + + location / { + # try to serve file directly, fallback to index.php + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ ^/index\.php(/|$) { + fastcgi_pass kimai:9000; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + + # optionally set the value of the environment variables used in the application + # fastcgi_param APP_ENV prod; + # fastcgi_param APP_SECRET ; + # fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"; + + # When you are using symlinks to link the document root to the + # current version of your application, you should pass the real + # application path instead of the path to the symlink to PHP + # FPM. + # Otherwise, PHP's OPcache may not properly detect changes to + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 + # for more information). + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + # Prevents URIs that include the front controller. This will 404: + # http://domain.tld/index.php/some-path + # Remove the internal directive to allow URIs like this + internal; + } +} diff --git a/data/ca.pem b/data/ca.pem new file mode 100644 index 0000000..9e98cee Binary files /dev/null and b/data/ca.pem differ diff --git a/data/client-cert.pem b/data/client-cert.pem new file mode 100644 index 0000000..910ac7b Binary files /dev/null and b/data/client-cert.pem differ diff --git a/data/public_key.pem b/data/public_key.pem new file mode 100644 index 0000000..674cf6f Binary files /dev/null and b/data/public_key.pem differ diff --git a/data/server-cert.pem b/data/server-cert.pem new file mode 100644 index 0000000..13c45af Binary files /dev/null and b/data/server-cert.pem differ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..85e7def --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,91 @@ +version: '3.5' +services: + + sqldb: + image: mysql:5.7 + environment: + - MYSQL_DATABASE=kimai + - MYSQL_USER=kimaiuser + - MYSQL_PASSWORD=kimaipassword + - MYSQL_ROOT_PASSWORD=changemeplease + volumes: + - ./data:/var/lib/mysql + command: --default-storage-engine innodb + restart: unless-stopped + healthcheck: + test: mysqladmin -pchangemeplease ping -h localhost + interval: 20s +# start_period: 10s +# timeout: 10s +# retries: 3 + + nginx: + build: compose +# ports: +# - 8001:80 + environment: + - VIRTUAL_HOST=time.franv.site + - LETSENCRYPT_HOST=time.franv.site + - LETSENCRYPT_EMAIL=ouch@thetrauma.org + - VIRTUAL_PORT=8001 + - TRUSTED_PROXY=nginx-proxy + + + volumes: + - ./compose/nginx_site.conf:/etc/nginx/conf.d/default.conf:ro + - public:/opt/kimai/public:ro + restart: unless-stopped + depends_on: + - kimai +# healthcheck: +# test: wget --spider http://nginx/health || exit 1 +# interval: 20s +# start_period: 10s +# timeout: 10s +# retries: 3 + + kimai: + image: kimai/kimai2:fpm-alpine-1.5-prod + environment: + - APP_ENV=prod + - TRUSTED_HOSTS=time.franv.site +# - TRUSTED_HOSTS=167.86.125.173 +# - TRUSTED_PROXY=nginx-proxy +# - VIRTUAL_HOST=time.franv.site +# - LETSENCRYPT_HOST=time.franv.site +# - LETSENCRYPT_EMAIL=ouch@thetrauma.org +# - VIRTUAL_PORT=8001 + + + - ADMINMAIL=admin@kimai.local + - ADMINPASS=changemeplease + volumes: + - public:/opt/kimai/public + - var:/opt/kimai/var + # - ./ldap.conf:/etc/openldap/ldap.conf:z + # - ./ROOT-CA.pem:/etc/ssl/certs/ROOT-CA.pem:z + restart: unless-stopped + healthcheck: + test: wget --spider http://nginx || exit 1 + interval: 20s +# start_period: 10s +# timeout: 10s +# retries: 3 + +# postfix: +# image: catatnight/postfix:latest +# environment: +# maildomain: neontribe.co.uk +# smtp_user: kimai:kimai +# restart: unless-stopped +# restart: always + +volumes: + var: + public: + +networks: + default: + external: + name: franvproxy_proxy-tier + diff --git a/docker-compose.yml.good b/docker-compose.yml.good new file mode 100644 index 0000000..7b6affb --- /dev/null +++ b/docker-compose.yml.good @@ -0,0 +1,86 @@ +version: '3.5' +services: + + sqldb: + image: mysql:5.7 + environment: + - MYSQL_DATABASE=kimai + - MYSQL_USER=kimaiuser + - MYSQL_PASSWORD=kimaipassword + - MYSQL_ROOT_PASSWORD=changemeplease + volumes: + - /var/lib/mysql + command: --default-storage-engine innodb + restart: unless-stopped + healthcheck: + test: mysqladmin -pchangemeplease ping -h localhost + interval: 20s +# start_period: 10s +# timeout: 10s +# retries: 3 + + nginx: + build: compose + ports: + - 8001:80 +# environment: +# - VIRTUAL_PORT=8001 + + + volumes: + - ./compose/nginx_site.conf:/etc/nginx/conf.d/default.conf:ro + - public:/opt/kimai/public:ro + restart: unless-stopped + depends_on: + - kimai +# healthcheck: +# test: wget --spider http://nginx/health || exit 1 +# interval: 20s +# start_period: 10s +# timeout: 10s +# retries: 3 + + kimai: + image: kimai/kimai2:fpm-alpine-1.5-prod + environment: + - APP_ENV=prod + - TRUSTED_HOSTS=time.franv.site +# - TRUSTED_HOSTS=167.86.125.173 + - VIRTUAL_HOST=time.franv.site + - LETSENCRYPT_HOST=time.franv.site + - LETSENCRYPT_EMAIL=ouch@thetrauma.org + - VIRTUAL_PORT=8001 + + + - ADMINMAIL=admin@kimai.local + - ADMINPASS=changemeplease + volumes: + - public:/opt/kimai/public + - var:/opt/kimai/var + # - ./ldap.conf:/etc/openldap/ldap.conf:z + # - ./ROOT-CA.pem:/etc/ssl/certs/ROOT-CA.pem:z + restart: unless-stopped + healthcheck: + test: wget --spider http://nginx || exit 1 + interval: 20s +# start_period: 10s +# timeout: 10s +# retries: 3 + + postfix: + image: catatnight/postfix:latest + environment: + maildomain: neontribe.co.uk + smtp_user: kimai:kimai + restart: unless-stopped + restart: always + +volumes: + var: + public: + +networks: + default: + external: + name: proxy_proxy-tier + diff --git a/index.html b/index.html new file mode 100644 index 0000000..258fa0a --- /dev/null +++ b/index.html @@ -0,0 +1,7 @@ +
+Fatal error: Uncaught Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException: Untrusted Host "localhost". in /opt/kimai/vendor/symfony/http-foundation/Request.php:1191 +Stack trace: +#0 /opt/kimai/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php(41): Symfony\Component\HttpFoundation\Request->getHost() +#1 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(298): Symfony\Component\HttpKernel\EventListener\ValidateRequestListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#2 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(260): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#3 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(235): Symfony\Component\EventDispatcher\Ev in /opt/kimai/vendor/friendsofsymfony/rest-bundle/View/ViewHandler.php on line 366
diff --git a/index.html.1 b/index.html.1 new file mode 100644 index 0000000..258fa0a --- /dev/null +++ b/index.html.1 @@ -0,0 +1,7 @@ +
+Fatal error: Uncaught Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException: Untrusted Host "localhost". in /opt/kimai/vendor/symfony/http-foundation/Request.php:1191 +Stack trace: +#0 /opt/kimai/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php(41): Symfony\Component\HttpFoundation\Request->getHost() +#1 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(298): Symfony\Component\HttpKernel\EventListener\ValidateRequestListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#2 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(260): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#3 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(235): Symfony\Component\EventDispatcher\Ev in /opt/kimai/vendor/friendsofsymfony/rest-bundle/View/ViewHandler.php on line 366
diff --git a/index.html.2 b/index.html.2 new file mode 100644 index 0000000..258fa0a --- /dev/null +++ b/index.html.2 @@ -0,0 +1,7 @@ +
+Fatal error: Uncaught Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException: Untrusted Host "localhost". in /opt/kimai/vendor/symfony/http-foundation/Request.php:1191 +Stack trace: +#0 /opt/kimai/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php(41): Symfony\Component\HttpFoundation\Request->getHost() +#1 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(298): Symfony\Component\HttpKernel\EventListener\ValidateRequestListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#2 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(260): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#3 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(235): Symfony\Component\EventDispatcher\Ev in /opt/kimai/vendor/friendsofsymfony/rest-bundle/View/ViewHandler.php on line 366
diff --git a/index.html.3 b/index.html.3 new file mode 100644 index 0000000..258fa0a --- /dev/null +++ b/index.html.3 @@ -0,0 +1,7 @@ +
+Fatal error: Uncaught Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException: Untrusted Host "localhost". in /opt/kimai/vendor/symfony/http-foundation/Request.php:1191 +Stack trace: +#0 /opt/kimai/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php(41): Symfony\Component\HttpFoundation\Request->getHost() +#1 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(298): Symfony\Component\HttpKernel\EventListener\ValidateRequestListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#2 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(260): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) +#3 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(235): Symfony\Component\EventDispatcher\Ev in /opt/kimai/vendor/friendsofsymfony/rest-bundle/View/ViewHandler.php on line 366
diff --git a/index.html.4 b/index.html.4 new file mode 100644 index 0000000..595fda6 --- /dev/null +++ b/index.html.4 @@ -0,0 +1,164 @@ + + + + BookStack + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
 
+ +
+

Log In

+ +
+ + +
+
+ + +
+ +
+ + + +
+
+ +
+
+
+ +
+ +
+
+ +
+ + + + +
+
+ +
+ + + + + + + diff --git a/index.html.5 b/index.html.5 new file mode 100644 index 0000000..f0f7942 --- /dev/null +++ b/index.html.5 @@ -0,0 +1,164 @@ + + + + BookStack + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
 
+ +
+

Log In

+ +
+ + +
+
+ + +
+ +
+ + + +
+
+ +
+
+
+ +
+ +
+
+ +
+ + + + +
+
+ +
+ + + + + + + diff --git a/kimai-export.csv b/kimai-export.csv new file mode 100644 index 0000000..19f9204 --- /dev/null +++ b/kimai-export.csv @@ -0,0 +1,24 @@ +Date,From,To,Duration,Rate,User,Customer,Project,Activity,Description,Exported,Tags,Hourly rate,Fixed rate +2020-07-15,17:25,18:02,2220,0.00,livan,StJohn,T-3010_St John Society and Foundation,T-3010 Foundation,,Open,, CAD 46.50 , +2020-07-17,08:36,10:54,8280,0.00,livan,StJohn,T-3010_St John Society and Foundation,T-3010 Foundation,,Open,, CAD 46.50 , +2020-07-17,11:25,12:37,4320,0.00,livan,StJohn,Financial Statements Updates,MR report review and update,,Open,, CAD 46.50 , +2020-07-17,13:03,13:49,2760,0.00,livan,StJohn,Financial Statements Updates,MR report review and update,,Open,, CAD 46.50 , +2020-07-17,14:00,15:30,5400,0.00,livan,StJohn,IT problem solving,IT-Email issues,,Open,, CAD 46.50 , +2020-07-17,15:38,17:40,7320,0.00,livan,StJohn,Financial Statements Updates,MR report review and update,,Open,, CAD 46.50 , +2020-07-18,09:59,11:00,3660,0.00,livan,StJohn,YE Closing,GP YE Closing,"GP FY2019 St John Society Closing - Close Sales,Purchase, When close Fiscal Year, system error. Check with National Office.",Open,, CAD 46.50 , +2020-07-20,10:03,11:19,4560,0.00,livan,StJohn,Meetings,Finance Team Meeting - Training,Petty Cash,Open,, CAD 46.50 , +2020-07-20,11:29,11:46,1020,0.00,livan,StJohn,Routine Tasks,AP - Payment Planning,"CC payment for Karen's approval, Corporate Traveler account for Instructor's booking.",Open,, CAD 46.50 , +2020-07-20,11:46,12:00,840,0.00,livan,StJohn,Gaming report & application,Gaming Report,Change appendix A report,Open,, CAD 46.50 , +2020-07-20,12:30,13:34,3840,0.00,livan,StJohn,Routine Tasks,AP - Payment Planning,"Sign CHQ Payments and EFT submission, review Cashflow report and open mails,",Open,, CAD 46.50 , +2020-07-20,13:35,14:00,1500,0.00,livan,StJohn,Routine Tasks,AP - Payment Planning,"Sign cheques, Cash flow update and correction.",Open,, CAD 46.50 , +2020-07-20,14:05,16:15,7800,0.00,livan,StJohn,T-3010_St John Society and Foundation,T3010-St John Society,Prepare Back up Files for approval,Open,, CAD 46.50 , +2020-07-20,16:14,16:49,2100,0.00,livan,StJohn,Meetings,Finance Team Meeting - Training,"AR sales filing process, HR (CRA Grants and Contributions Direct Deposit Form), AR Aged list Review with Vera, +Month end progress update with AR team and Vera.",Open,, CAD 46.50 , +2020-07-22,09:16,10:23,4020,0.00,livan,StJohn,Month End Closing,Month end closing JE,Payroll JE for June 2020 and Accrual JE,Open,, CAD 46.50 , +2020-07-22,10:23,10:26,180,0.00,livan,StJohn,Meetings,Finance Team Meeting - Training,Meeting with Winnie for her AR questions,Open,, CAD 46.50 , +2020-07-22,10:26,10:45,1140,0.00,livan,StJohn,Month End Closing,Month end closing JE,Vacation Balance Verification,Open,, CAD 46.50 , +2020-07-22,10:44,11:04,1200,0.00,livan,StJohn,Meetings,Finance Team Meeting - Training,Meeting with Winnie for her AR questions,Open,, CAD 46.50 , +2020-07-22,11:03,12:14,4260,0.00,livan,StJohn,Month End Closing,Month end closing JE,Vacation Balance Verification,Open,, CAD 46.50 , +2020-07-22,13:06,14:36,5400,0.00,livan,StJohn,Month End Closing,Project Cost reallocation,Health Canada FY2019 YE cost reallocation adjustment. Back out reversal JE 1629480. Recognize Def Revenue and Expense Jan - Jun 2020,Open,, CAD 46.50 , +2020-07-22,15:15,15:55,2400,0.00,livan,StJohn,IT problem solving,Server folders reallocation,Move folders for the server mapping,Open,, CAD 46.50 , +2020-07-22,18:05,18:23,1080,0.00,livan,StJohn,IT problem solving,Server folders reallocation,Move folders for the server mapping,Open,, CAD 46.50 , diff --git a/ldap.conf b/ldap.conf new file mode 100644 index 0000000..fadecbd --- /dev/null +++ b/ldap.conf @@ -0,0 +1,14 @@ +# +# LDAP Defaults +# + +# See ldap.conf(5) for details +# This file should be world readable but not world writable. + +#BASE dc=example,dc=com +#URI ldap://ldap.example.com ldap://ldap-master.example.com:666 + +#SIZELIMIT 12 +#TIMELIMIT 15 +#DEREF never +TLS_CACERT /etc/ssl/certs/ROOT-CA.pem diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..305dda0 --- /dev/null +++ b/readme.md @@ -0,0 +1,19 @@ +## Installing +### Using apache-debian +- run container with named volume mount for `/opt/kimai/var` +> `docker run -p 8001:8001 --rm --name=Kimai2 -v kimai_var:/opt/kimai/var KIMAIIMAGE` +### Using fpm-alpine +- run compose file +> `docker-compose up -d` + +## Upgrading Kimai version +### Using apache-debian +- stop your container +- run new version and mount you named `/opt/kimai/var` volume into container +### Using fpm-alpine +- stop all containers with compose +- change kimai image in compose file +- delete the kimai `source` volume (NOT THE `var`) + (this volume will only be used to share kimai source with the nginx webserver. + delete forces to recreate and use the new, updated kimai sources ) +- restart your compose file \ No newline at end of file diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000..0259d6b --- /dev/null +++ b/startup.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +echo $KIMAI + +function waitForDB() { + # Parse sql connection data + # todo: port is not used atm + DB_TYPE=$(awk -F '[/:@]' '{print $1}' <<< $DATABASE_URL) + DB_USER=$(awk -F '[/:@]' '{print $4}' <<< $DATABASE_URL) + DB_PASS=$(awk -F '[/:@]' '{print $5}' <<< $DATABASE_URL) + DB_HOST=$(awk -F '[/:@]' '{print $6}' <<< $DATABASE_URL) + DB_BASE=$(awk -F '[/:@]' '{print $7}' <<< $DATABASE_URL) + + # If we use mysql wait until its online + if [[ $DB_TYPE == "mysql" ]]; then + echo "Using Mysql DB" + echo "Wait for db connection ..." + until php -r "new PDO(\"mysql:host=$DB_HOST;dbname=$DB_BASE\", \"$DB_USER\", \"$DB_PASS\");" &> /dev/null; do + sleep 3 + done + echo "Connection established" + else + echo "Using non mysql DB" + fi +} + +function handleStartup() { + # first start? + if ! [ -e /opt/kimai/installed ]; then + echo "first run - install kimai" + /opt/kimai/bin/console -n kimai:install + if [ ! -z "$ADMINPASS" ] && [ ! -a "$ADMINMAIL" ]; then + /opt/kimai/bin/console kimai:create-user superadmin $ADMINMAIL ROLE_SUPER_ADMIN $ADMINPASS + fi + echo $KIMAI > /opt/kimai/installed + fi + echo "Kimai2 ready" +} + +function runServer() { + if [ -e /use_apache ]; then + /usr/sbin/apache2ctl -D FOREGROUND + elif [ -e /use_fpm ]; then + exec php-fpm + else + echo "Error, unknown server type" + fi +} + +waitForDB +handleStartup +runServer +exit diff --git a/unittest.sh b/unittest.sh new file mode 100755 index 0000000..7b4fbbd --- /dev/null +++ b/unittest.sh @@ -0,0 +1,20 @@ + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/API || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Calendar || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Command || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Configuration || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Controller || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/DataFixtures || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Doctrine || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Entity || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Event || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/EventSubscriber || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Export || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Invoice || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Model || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Repository || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Security || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Timesheet || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Twig || exit 1 + #/opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Utils || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Validator || exit 1 + /opt/kimai/vendor/bin/phpunit /opt/kimai/tests/Voter || exit 1 \ No newline at end of file diff --git a/visu.py b/visu.py new file mode 100755 index 0000000..3f5480f --- /dev/null +++ b/visu.py @@ -0,0 +1,44 @@ +#!/bin/python3 + +# python3 ./visu.py | sudo docker run --rm -i vladgolubev/dot2png > file.png && xviewer file.png + +import re + +conns = [] +layer = "" + +def parseLine(line, actual_layer): + from_re = re.match("FROM (.*) AS (.*)", line) + if from_re: + actual_layer = from_re.group(2) + if ":" in from_re.group(1): + conns.append("\"" + from_re.group(1) + "\" [shape=box]") + conn = "\"" + from_re.group(1) + "\" -> \"" + from_re.group(2) + "\"" + if not conn in conns: + conns.append(conn) + + copy_re = re.match("COPY --from=([a-z-_]*)", line) + if copy_re: + conn = "\"" + copy_re.group(1) + "\" -> \"" + actual_layer + "\"[style=dashed]" + if not conn in conns: + conns.append(conn) + return actual_layer + + + +file = open("Dockerfile", "r") +conns.append("digraph {") +# conns.append("rankdir=LR;") +line = file.readline() +while line: + line = file.readline() + if "${BASE}" in line: + layer = parseLine(line.replace("${BASE}", "fpm-alpine"), layer) + layer = parseLine(line.replace("${BASE}", "apache-debian"), layer) + else: + layer = parseLine(line, layer) +conns.append("}") + + +for line in conns: + print(line)