From 9b26eabb7c5e57bd369f2d579e7a42bfff68ad23 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Sun, 12 Jun 2022 01:30:09 -0400 Subject: [PATCH] Install TimeTrex in PHP Docker image --- .gitignore | 1 + Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ Vagrantfile | 12 ++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ docker-timetrex-entrypoint | 10 ++++++++++ 5 files changed, 82 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Vagrantfile create mode 100644 docker-compose.yml create mode 100755 docker-timetrex-entrypoint diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8000dd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vagrant diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..abfc312 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM php:7.4-apache-bullseye +ARG URL=https://www.timetrex.com/direct_download/TimeTrex_Community_Edition-manual-installer.zip + +# Install PHP extensions +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libarchive-tools \ + libpq-dev \ + zlib1g-dev \ + libpng-dev \ + libicu-dev \ + libxml2-dev \ + libzip-dev \ + && rm -rf /var/lib/apt/lists/* +RUN docker-php-ext-install pgsql gd gettext intl soap zip bcmath +RUN ln -s "$(which php)" /usr/bin/php + +# Download and place TimeTrex +RUN curl -s "$URL" | bsdtar -xf- -C /var/www/html/ && \ + cp -r /var/www/html/TimeTrex_*/* /var/www/html/ && \ + rm -rf /var/www/html/TimeTrex_* && \ + cp timetrex.ini.php-example_linux timetrex.ini.php + +# Create directories +RUN mkdir -p /var/timetrex/storage && \ + mkdir -p /var/log/timetrex && \ + chgrp -R www-data /var/timetrex/ && \ + chmod 775 -R /var/timetrex && \ + chgrp www-data -R /var/log/timetrex/ && \ + chmod 775 -R /var/log/timetrex && \ + chgrp www-data -R /var/www/html/ && \ + chmod 775 -R /var/www/html/ + +# Add our own entrypoint +COPY docker-timetrex-entrypoint /usr/local/bin +ENTRYPOINT ["docker-timetrex-entrypoint"] diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..6387e97 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,12 @@ +Vagrant.configure("2") do |config| + config.vm.box = "debian/bullseye64" + config.vm.network "forwarded_port", guest: 8080, host: 8080 + config.vm.provision "shell", inline: <<-EOF + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y docker.io docker-compose + usermod -aG docker vagrant + cd /vagrant + docker-compose up -d --build + EOF +end diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ad158c6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3' + +services: + timetrex: + build: . + ports: + - 8080:80 + links: + - postgres + environment: + POSTGRES_PASSWORD: password + POSTGRES_HOST: postgres + postgres: + image: postgres:13-bullseye + volumes: + - postgres:/var/lib/postgresql/data + environment: + POSTGRES_DB: timetrex + POSTGRES_USER: timetrex + POSTGRES_PASSWORD: password + +volumes: + postgres: diff --git a/docker-timetrex-entrypoint b/docker-timetrex-entrypoint new file mode 100755 index 0000000..61286d1 --- /dev/null +++ b/docker-timetrex-entrypoint @@ -0,0 +1,10 @@ +#!/bin/bash + +function timetrex_set() { + sed -i '/^'"$1"' /s/=.*$/= '"$2"'/' /var/www/html/timetrex.ini.php +} + +timetrex_set 'base_url' "${BASE_URL:=\/\/interface}" +timetrex_set 'password' "$POSTGRES_PASSWORD" +timetrex_set 'host' "$POSTGRES_HOST" +apache2-foreground