-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kimai in a docker way with seperate db
- Loading branch information
Sören Rohweder
committed
Nov 11, 2017
0 parents
commit 2522b19
Showing
8 changed files
with
992 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM php:7.0-apache | ||
|
||
MAINTAINER Sören Rohweder <[email protected]> | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
unzip libmcrypt-dev mysql-client\ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& docker-php-ext-install -j$(nproc) iconv mcrypt mysqli | ||
|
||
ARG KIMAI_VERSION=1.1.0 | ||
ARG KIMAI_SHA256=3484b3f30f95b5866cf3dfa1e52bbff5ef85f19da9f9620f6458a26b8cc30e81 | ||
|
||
COPY ./libpcre3_8.38-3.1_amd64.deb /root/libpcre3_8.38-3.1_amd64.deb | ||
RUN dpkg -i /root/libpcre3_8.38-3.1_amd64.deb | ||
RUN a2enmod rewrite \ | ||
&& rm /root/libpcre3_8.38-3.1_amd64.deb | ||
|
||
RUN curl -L -o kimai.zip https://github.com/kimai/kimai/releases/download/${KIMAI_VERSION}/kimai_${KIMAI_VERSION}.zip \ | ||
&& echo "${KIMAI_SHA256} kimai.zip" | sha256sum -c \ | ||
&& mkdir -p /var/www/html \ | ||
&& unzip kimai.zip -d /var/www/html/ \ | ||
&& chown -R www-data:www-data /var/www/html/ \ | ||
&& rm *.zip | ||
COPY kimai_dump.sql /root | ||
COPY setup.php /var/www/html | ||
COPY ./wait-for-it.sh ./docker-php-entrypoint /usr/local/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Kimai Docker Image | ||
|
||
This docker image entry-point sets up the kimai without using the installer. Configured by env variables to setup the database connection, enabling the configuration of Kimai in a cluster environment. | ||
|
||
There is no need to run the installer after the image is started, also there is not installer anymore, it is already removed. | ||
|
||
The Configuration is done in docker style, there need to be a second container running a database. | ||
|
||
## Variables | ||
|
||
### KIMAI\_MYSQL\_HOSTNAME | ||
This sets the hostname for the database | ||
|
||
### KIMAI\_MYSQL\_DATABASE | ||
The Databasename to setup e.q. kimai | ||
|
||
### KIMAI\_MYSQL\_USERNAME | ||
The database username | ||
|
||
### KIMAI\_MYSQL\_PASSWORD | ||
The password for the user | ||
|
||
### KIMAI\_SALT | ||
A salt for better password hashing in the db | ||
|
||
The default password for the "admin" user ist "changeme" | ||
|
||
## TODOs | ||
Make the default "admin" password configurable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: "3" | ||
|
||
services: | ||
kimai: | ||
image: kimai | ||
ports: | ||
- 8090:80 | ||
environment: | ||
- KIMAI_MYSQL_HOSTNAME=db | ||
- KIMAI_MYSQL_DATABASE=kimai | ||
- KIMAI_MYSQL_USERNAME=root | ||
- KIMAI_MYSQL_PASSWORD=password | ||
- KIMAI_SALT=rBPg0PZHSUzYZLKbiqRSY | ||
# TODO Remove for deployment | ||
# - TYPO3_CONTEXT=Development | ||
- KIMAI_RECREATE_FIXTURES=1 | ||
links: | ||
- db | ||
|
||
db: | ||
image: mysql:5.7 | ||
environment: | ||
- MYSQL_DATABASE=kimai | ||
- MYSQL_ROOT_PASSWORD=password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
cd /var/www/html | ||
|
||
TIMEOUT=100 wait-for-it.sh $KIMAI_MYSQL_HOSTNAME:3306 | ||
|
||
echo "Running as $(whoami)" | ||
|
||
if [ ! -f ".initialized" ]; then | ||
echo "Setting up Kimai..." | ||
mkdir -p include | ||
cat << EOF > includes/autoconf.php | ||
<?php | ||
\$server_hostname = "${KIMAI_MYSQL_HOSTNAME}"; | ||
\$server_database = "${KIMAI_MYSQL_DATABASE}"; | ||
\$server_username = "${KIMAI_MYSQL_USERNAME}"; | ||
\$server_password = "${KIMAI_MYSQL_PASSWORD}"; | ||
\$server_prefix = "kimai_"; | ||
\$language = "en"; | ||
\$password_salt = "${KIMAI_SALT}"; | ||
\$defaultTimezone = "UTC"; | ||
\$skin = "standard"; | ||
\$authenticator = "kimai"; | ||
\$billable = array ( | ||
0 => 0, | ||
1 => 50, | ||
2 => 100, | ||
); | ||
EOF | ||
echo "DROP DATABASE $KIMAI_MYSQL_DATABASE; CREATE DATABASE ${KIMAI_MYSQL_DATABASE}" |\ | ||
mysql -h $KIMAI_MYSQL_HOSTNAME -u $KIMAI_MYSQL_USERNAME -p$KIMAI_MYSQL_PASSWORD $KIMAI_MYSQL_DATABASE | ||
echo "Importing Kimai fixtures..." | ||
cat /root/kimai_dump.sql |\ | ||
mysql -h $KIMAI_MYSQL_HOSTNAME -u $KIMAI_MYSQL_USERNAME -p$KIMAI_MYSQL_PASSWORD $KIMAI_MYSQL_DATABASE | ||
echo "Setting up initial stuff" | ||
|
||
php /var/www/html/setup.php | ||
rm -rf installer | ||
|
||
touch .initialized | ||
fi | ||
|
||
# first arg is `-f` or `--some-option` | ||
if [ "${1#-}" != "$1" ]; then | ||
set -- apache2-foreground "$@" | ||
fi | ||
|
||
exec "$@" |
Oops, something went wrong.