added dockerfile for development (#377)

This commit is contained in:
Toby Batch
2018-10-31 12:19:48 +00:00
committed by Kevin Papst
parent 34a3f4e275
commit ab4a1a0a1d
2 changed files with 94 additions and 0 deletions

41
Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
# This file is part of the Kimai time-tracking app.
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
FROM php:7.2.9-apache-stretch
WORKDIR /opt/kimai
RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer && \
apt update && \
apt install -y \
git \
libicu-dev \
libjpeg-dev \
libldap2-dev \
libldb-dev \
libpng-dev \
unzip \
zip \
&& \
docker-php-ext-install \
gd \
intl \
ldap \
pdo_mysql \
zip && \
apt-get -y autoremove && \
apt-get clean && \
git clone https://github.com/kevinpapst/kimai2.git /opt/kimai && \
sed "s/prod/dev/g" .env.dist > .env && \
composer install --dev --optimize-autoloader && \
bin/console doctrine:database:create && \
bin/console doctrine:schema:create && \
bin/console doctrine:migrations:version --add --all && \
bin/console cache:warmup && \
chown -R www-data:www-data var
EXPOSE 8001
USER www-data
CMD /opt/kimai/bin/console server:run 0.0.0.0:8001

53
var/docs/docker.md Normal file
View File

@@ -0,0 +1,53 @@
# Docker
We bundle a simple docker that can be used for test purposes. Either pull it from docker hub or build it.
## Build the docker
docker build -t kimai/kimai2:dev .
## Run the docker
docker run -ti -p 8001:8001 --name kimai2 --rm kimai/kimai2:dev
You can then access the site on http://127.0.0.1:8001. If that doesn't work check the IP of your docker:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kimai2
You can find Kimai at that IP on port 8001.
### Mac using docker-machine
When using dock-machine on your Mac, you need to use the IP of your machine.
Considering you started the machine named `default`, you find the IP with:
docker-machine ip default
## Running commands in the docker
You can run any command in the container in this fashion once it is started. Add `-ti` to attach a terminal.
docker exec -ti kimai2 bash
## Create a user and dummy data
See the docs [here](installation.md) for full instructions, but this creates a user admin/admin with all privileges.
docker exec kimai2 bin/console kimai:create-user admin admin@example.com ROLE_SUPER_ADMIN admin
To install the fixtures:
docker exec kimai2 bin/console kimai:reset-dev
## Developing against the docker
It is possible to mount your source tree and sqlite DB into the container at run time.
docker run --rm -d -p 8001:8001 \
-v $(pwd)/src:/opt/kimai/src \
-v $(pwd)/var/data/kimai.sqlite:/opt/kimai/var/data/kimai.sqlite \
--name kimai2 kimai/kimai2:dev
Now edits in the local file tree will be served by the container and database changes will persist.
See [The official docker documentation](https://docs.docker.com/) for more options on running the container.