create a docker template for development

thanks to mbuchalik for this idea
This commit is contained in:
Sebijk 2023-10-14 14:24:25 +02:00
parent 8808752b30
commit e3436e999a
6 changed files with 111 additions and 1 deletions

View file

@ -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

2
dev-docker/.env Normal file
View file

@ -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

15
dev-docker/Dockerfile Normal file
View file

@ -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

29
dev-docker/README.md Normal file
View file

@ -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.

View file

@ -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

View file

@ -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 <<EOF
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
EOF
tee ../src/data/.htaccess <<EOF
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
EOF