diff --git a/README.md b/README.md index 0d0a571..4281da6 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ A big thanks goes to b1gMail founder Patrick Schlangen. He released b1gMail as f ## Getting started It is recommended to install the b1gMail developer copy on a local web server, e.g. standard Apache/PHP/MySQL on Linux or Wamp on Windows. Even better results -on Windows can be achieved with a WSL setup. +on Windows can be achieved with a WSL setup. If you use Docker, you can also +use our docker template in `docker-dev`. In order to install a development environment, proceed as follows: 1. Clone the repository diff --git a/dev-docker/.env b/dev-docker/.env new file mode 100644 index 0000000..ea632c0 --- /dev/null +++ b/dev-docker/.env @@ -0,0 +1,2 @@ +# Docker by default uses the folder name to isolate different projects. This might however be a problem because we call our folder "dev", which might also be how other projects call their folders. To avoid any collisions, we use an idea from https://stackoverflow.com/questions/50947938/docker-compose-orphan-containers-warning +COMPOSE_PROJECT_NAME=b1gmail-dev diff --git a/dev-docker/Dockerfile b/dev-docker/Dockerfile new file mode 100644 index 0000000..45dc9a3 --- /dev/null +++ b/dev-docker/Dockerfile @@ -0,0 +1,15 @@ +FROM php:8.2-apache + +# From the official documentation on https://hub.docker.com/_/php +RUN apt-get update && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libicu-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j$(nproc) gd + +# See https://github.com/docker-library/php/issues/391 +RUN docker-php-ext-install mysqli + +RUN docker-php-ext-install intl \ No newline at end of file diff --git a/dev-docker/README.md b/dev-docker/README.md new file mode 100644 index 0000000..b7a5eb6 --- /dev/null +++ b/dev-docker/README.md @@ -0,0 +1,29 @@ +**THIS SETUP IS ONLY MEANT FOR DEVELOPMENT PURPOSES!** + +> Make sure you have Docker installed on your system. + +In order to start a development server, simply run `docker compose up`. This will start an apache server with php (on `localhost:5000`), a mysql database, and phpmyadmin (on `localhost:3100`). + +The credentials for the database that you will later also need when installing b1gmail: + +- Host: `db` (Yes, you don't need to use any IP address or similar. Just `db` is sufficient.) +- Database name: `b1gmail` +- Username: `user` +- Password: `password` + +In order to log in to phpmyadmin, use the following credentials: + +- Username: `root` +- Password: `root` + +Important when recreating the containers: We don't only store data in the database, but also in `/src/temp/` and `/src/data/`. You might need to delete files and folders in these directories. You can delete everything from `/src/data/` and `/src/temp/` except for the following files: + +- `/src/data/.htaccess` +- `/src/data/index.html` +- `/src/temp/.htaccess` +- `/src/temp/index.html` +- `/src/temp/cache/dummy` +- `/src/temp/session/dummy` +- `/src/serverlib/config.inc.php` + +A script for automation is included. If you want to use a "hacky" approach for now: Simply delete these `/src/data/` and `/src/temp/` directories and then use git to revert the changes. diff --git a/dev-docker/docker-compose.yml b/dev-docker/docker-compose.yml new file mode 100644 index 0000000..c83cb81 --- /dev/null +++ b/dev-docker/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3.9' + +services: + php: + build: . + networks: + - default + ports: + - '5000:80' + volumes: + - ../src:/var/www/html + depends_on: + - db + + db: + image: mariadb + networks: + - default + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: b1gmail + MYSQL_USER: user + MYSQL_PASSWORD: password + ports: + - '3306:3306' + + phpmyadmin: + image: phpmyadmin/phpmyadmin:5 + ports: + - '3100:80' + depends_on: + - db diff --git a/dev-docker/remove_tempfiles.sh b/dev-docker/remove_tempfiles.sh new file mode 100644 index 0000000..056e121 --- /dev/null +++ b/dev-docker/remove_tempfiles.sh @@ -0,0 +1,31 @@ +#!/bin/bash +rm -Rf ../src/data +mkdir ../src/data +touch ../src/data/.htaccess +touch ../src/data/index.html +rm -Rf ../src/temp +mkdir ../src/temp +mkdir ../src/temp/cache +mkdir ../src/temp/session +touch ../src/temp/.htaccess +touch ../src/temp/index.html +touch ../src/temp/cache/dummy +touch ../src/temp/session/dummy +tee ../src/temp/.htaccess < + Require all denied + + + + Deny from all + +EOF +tee ../src/data/.htaccess < + Require all denied + + + + Deny from all + +EOF