From bb6b8015fe8dd841a1f45eb6e56f24a1f5fa94af Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Mon, 3 Jul 2017 12:30:41 +0200 Subject: [PATCH 1/3] Add docker-compose.yml file to build development environment based on Docker --- Dockerfile | 15 ++++++++------- docker-compose.yml | 33 +++++++++++++++++++++++++++++++++ docker-run.sh | 15 +++++++++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker-run.sh diff --git a/Dockerfile b/Dockerfile index 00a5d0ef567..caa7b0c436a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM php:5.6-apache +FROM php:7.0-apache + +ENV HOST_USER_ID 33 +ENV PHP_INI_DATE_TIMEZONE 'UTC' RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ && rm -rf /var/lib/apt/lists/* \ @@ -9,11 +12,9 @@ RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ && docker-php-ext-install mysqli \ && apt-get purge -y libpng12-dev libjpeg-dev libldap2-dev -COPY htdocs/ /var/www/html/ - -RUN chown -hR www-data:www-data /var/www/html - -VOLUME /var/www/html/conf -VOLUME /var/www/html/documents +COPY docker-run.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-run.sh EXPOSE 80 + +ENTRYPOINT ["docker-run.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..2f0b5536d4f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +# This docker-compose.yml file is used to build and run Dolibarr +# in the current workspace +# +# Before build/run, define the variable HOST_USER_ID as following: +# $ export HOST_USER_ID=$(id -u) +# And then, you can run : +# $ docker-compose up + +mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: dolibarr + +phpmyadmin: + image: phpmyadmin/phpmyadmin + environment: + PMA_HOST: mariadb + links: + - mariadb + ports: + - "8080:80" + +web: + build: . + environment: + HOST_USER_ID: $HOST_USER_ID + volumes: + - ./htdocs:/var/www/html + links: + - mariadb + ports: + - "80:80" diff --git a/docker-run.sh b/docker-run.sh new file mode 100644 index 00000000000..c151e1c3cab --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +usermod -u $HOST_USER_ID www-data +groupmod -g $HOST_USER_ID www-data + +chown -hR www-data:www-data /var/www + +if [ ! -f /usr/local/etc/php/php.ini ]; then + cat < /usr/local/etc/php/php.ini +date.timezone = $PHP_INI_DATE_TIMEZONE +display_errors = On +EOF +fi + +exec apache2-foreground From d09ca6f3da0c621820dc3f8374d12bdf65a6f461 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 26 Jul 2017 11:41:12 +0200 Subject: [PATCH 2/3] Move all docker files into build/docker --- .dockerignore | 16 -------------- build/docker/.dockerignore | 3 +++ Dockerfile => build/docker/Dockerfile | 0 build/docker/README.md | 21 +++++++++++++++++++ .../docker/docker-compose.yml | 10 +-------- docker-run.sh => build/docker/docker-run.sh | 0 6 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 .dockerignore create mode 100644 build/docker/.dockerignore rename Dockerfile => build/docker/Dockerfile (100%) create mode 100644 build/docker/README.md rename docker-compose.yml => build/docker/docker-compose.yml (59%) rename docker-run.sh => build/docker/docker-run.sh (100%) diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e5908c26ac0..00000000000 --- a/.dockerignore +++ /dev/null @@ -1,16 +0,0 @@ -build -build.xml -ChangeLog -composer.json -CONTRIBUTING.md -COPYING -COPYRIGHT -dev -doc -Dockerfile -INSTALL -README-FR.md -README.md -robots.txt -scripts -test \ No newline at end of file diff --git a/build/docker/.dockerignore b/build/docker/.dockerignore new file mode 100644 index 00000000000..e345920fb8c --- /dev/null +++ b/build/docker/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +README.md +docker-compose.yml diff --git a/Dockerfile b/build/docker/Dockerfile similarity index 100% rename from Dockerfile rename to build/docker/Dockerfile diff --git a/build/docker/README.md b/build/docker/README.md new file mode 100644 index 00000000000..113c03d21b5 --- /dev/null +++ b/build/docker/README.md @@ -0,0 +1,21 @@ +# How to use it ? + +The docker-compose.yml file is used to build and run Dolibarr in the current workspace. + +Before build/run, define the variable HOST_USER_ID as following: + + export HOST_USER_ID=$(id -u) + +And then, you can run : + + docker-compose up + +This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin. + +The URL to go to the Dolibarr is : + + http://0.0.0.0 + +The URL to go to PhpMyAdmin is (login/password is root/root) : + + http://0.0.0.0:8080 diff --git a/docker-compose.yml b/build/docker/docker-compose.yml similarity index 59% rename from docker-compose.yml rename to build/docker/docker-compose.yml index 2f0b5536d4f..a2017335197 100644 --- a/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -1,11 +1,3 @@ -# This docker-compose.yml file is used to build and run Dolibarr -# in the current workspace -# -# Before build/run, define the variable HOST_USER_ID as following: -# $ export HOST_USER_ID=$(id -u) -# And then, you can run : -# $ docker-compose up - mariadb: image: mariadb:latest environment: @@ -26,7 +18,7 @@ web: environment: HOST_USER_ID: $HOST_USER_ID volumes: - - ./htdocs:/var/www/html + - ../../htdocs:/var/www/html links: - mariadb ports: diff --git a/docker-run.sh b/build/docker/docker-run.sh similarity index 100% rename from docker-run.sh rename to build/docker/docker-run.sh From 700da4308e6cd0c46bf9a7ee6d3f621d84b2fd22 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Fri, 11 Aug 2017 19:01:01 +0200 Subject: [PATCH 3/3] update README for docker --- build/docker/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/docker/README.md b/build/docker/README.md index 113c03d21b5..5a0997cf121 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -6,6 +6,10 @@ Before build/run, define the variable HOST_USER_ID as following: export HOST_USER_ID=$(id -u) +Go in repository build/docker : + + cd build/docker + And then, you can run : docker-compose up