Dockerized mysql,php,webserver

This commit is contained in:
Torsten 2022-03-23 13:19:51 +01:00
parent a2f70fc9ef
commit 2f29555240
16 changed files with 164440 additions and 93942 deletions

View file

@ -1,16 +1,16 @@
APP_NAME="Hoschis Tippspiel"
APP_ENV=local
APP_KEY=base64:kDZstIrXoxXzGa2reMEbvFjDhcaoJ4eKupyPnPL7euE=
APP_KEY=base64:dfy2mOUn+iJB57CxYbG/Oukhozcd4oNput/8Ofq8gMQ=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_HOST=db
DB_PORT=3306
DB_DATABASE=pfosten
DB_USERNAME=root
DB_PASSWORD=root
DB_USERNAME=pf_user
DB_PASSWORD=pf_password
BROADCAST_DRIVER=smtp
CACHE_DRIVER=file
@ -30,4 +30,4 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_SECRET=

View file

@ -6,11 +6,11 @@ APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_HOST=DB
DB_PORT=3306
DB_DATABASE=pfosten
DB_USERNAME=root
DB_PASSWORD=root
DB_USERNAME=pf_user
DB_PASSWORD=pf_password
BROADCAST_DRIVER=log
CACHE_DRIVER=file

36
pfosten/Dockerfile.dev Normal file
View file

@ -0,0 +1,36 @@
FROM php:7.2-fpm
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
libzip-dev \
-y mariadb-client
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install zip mysqli pdo_mysql mbstring exif pcntl bcmath gd && docker-php-ext-enable mysqli
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# Set working directory
WORKDIR /var/www
USER $user

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,58 @@
version: "3.7"
services:
app:
build:
args:
user: sammy
uid: 1000
context: ./
dockerfile: Dockerfile.dev
working_dir: /var/www/
environment:
- COMPOSER_MEMORY_LIMIT=-1
depends_on:
- db
volumes:
- ./:/var/www
networks:
- lahmi
db:
image: mysql:5.7
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql
- ./docker-compose/mysql/my.cnf:/etc/mysql/my.cnf
- ./docker-compose/mysql/init:/docker-entrypoint-initdb.d
ports:
- 3306:3306
networks:
- lahmi
nginx:
image: nginx:alpine
ports:
- 8005:80
depends_on:
- db
- app
volumes:
- ./:/var/www
- ./docker-compose/nginx:/etc/nginx/conf.d/
networks:
- lahmi
networks:
lahmi:
driver: bridge
volumes:
dbdata:
driver: local

View file

@ -0,0 +1,7 @@
# create databases
CREATE DATABASE IF NOT EXISTS `local_laravel`;
# create local_developer user and grant rights
CREATE USER 'local_developer'@'db' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON *.* TO 'local_developer'@'%';

View file

@ -0,0 +1,4 @@
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log

View file

@ -0,0 +1,21 @@
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}

View file

@ -1,7 +0,0 @@
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
echo "alias composer='php composer.phar'" >> ~/.bashrc

View file

@ -1,3 +0,0 @@
<?php
phpinfo();
?>

View file

@ -0,0 +1,4 @@
docker-compose down
docker-compose up -d --build
docker-compose exec app composer install
docker-compose exec app php artisan key:generate