Added Docker Setup

This commit is contained in:
2024-02-07 15:54:30 +01:00
parent c7c16830f7
commit 2026710b4a
6 changed files with 161 additions and 0 deletions

2
.gitignore vendored
View File

@@ -10,6 +10,8 @@ scripts/addressdb/import
todo
files/*
vendor/
data/
phinx.php
*.sql
!/db/**/*.sql

34
Dockerfile Normal file
View File

@@ -0,0 +1,34 @@
# Use Debian Bookworm as base image
FROM debian:bookworm
# Install apache2 and PHP and PHP modules
RUN apt update && \
apt install -y apache2 php8.2 php8.2-mysqli php8.2-gd php8.2-zip php8.2-dom php8.2-mbstring && \
apt clean && \
rm -rf /var/lib/apt/lists/*
# Enable PHP in Apache2
RUN a2enmod php8.2
# Enable Apache2 mod_rewrite
RUN a2enmod rewrite
# Install Composer
RUN apt update && \
apt install -y curl php8.2-cli unzip && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
apt clean && \
rm -rf /var/lib/apt/lists/*
# Change PHP.ini memory limit to 1024MB
RUN sed -i 's/memory_limit = .*/memory_limit = 1024M/' /etc/php/8.2/apache2/php.ini
# Composer install
WORKDIR /var/www/html
COPY composer.json composer.lock ./
RUN composer install --no-interaction
# Start Apache in the foreground
CMD ["apachectl", "-D", "FOREGROUND"]

55
README.md Normal file
View File

@@ -0,0 +1,55 @@
# TheTool
## Introduction
This Project is a PHP Project.
## Table of Contents
- [Docker Setup](#docker-setup)
### Docker Setup
#### Build fresh image
Build a fresh local docker image with all dependencies.
This is based on debian-bookworm and installs apache2, php8.2 & composer with all dependencies
```bash
docker build -t debian-php .
```
#### Volume Bindings
| Type | Location |
| ------------------------------- | --------------------------------- |
| MySQL Logs | `docker/mysql/logs` |
| MySQL Config | `docker/mysql/conf.d` |
| Apache Config | `docker/apache2/000-default.conf` |
| DocumentRoot (inside container) | `docker/mysql/logs` |
#### Start Docker Setup
Use this command to start all Containers.
TheTool will be available at http://localhost
Adminer will be available at http://localhost:8080
Use `-d` to start it detached from your current console
```bash
docker compose up [-d]
```
Use this command to use the container context (!! Keep in mind, not all folders are synced)
```bash
docker compose exec php bash -it
```
#### Initialize Database
Either initialize the Database with phinx (documentation located in `/db`)
##### OR
Use Adminer and a existing export to import the current state of the Database

31
docker-compose.yml Normal file
View File

@@ -0,0 +1,31 @@
version: '3.8'
services:
php:
image: debian-php2
ports:
- 80:80
volumes:
- ./docker/apache2/000-default.conf:/etc/apache2/sites-available/000-default.conf
- ./:/var/www/html
- vendor:/var/www/html/vendor
db:
image: mariadb
environment:
- MYSQL_ROOT_PASSWORD=junghan5
- MYSQL_DATABASE=thetool
- MYSQL_USER=luca
- MYSQL_PASSWORD=junghan5
volumes:
- ./docker/mysql/data:/var/lib/mysql
- ./docker/mysql/conf.d:/etc/mysql/conf.d
- ./docker/mysql/logs:/var/log/mysql
adminer:
image: adminer
ports:
- 8080:8080
volumes:
vendor:

View File

@@ -0,0 +1,31 @@
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
allowoverride all
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

View File

@@ -0,0 +1,8 @@
[mysqld]
general_log = 1
general_log_file = /var/log/mysql/query.log
slow_query_log = 1
long_query_time = 1 # seconds
slow_query_log_file = /var/log/mysql/slow.log
log_queries_not_using_indexes = 1