Mod docker compose
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Philipp Lang 2023-05-15 19:48:37 +02:00
parent 7ff735acac
commit 708b0cf386
10 changed files with 168 additions and 108 deletions

15
.app.env.example Normal file
View File

@ -0,0 +1,15 @@
APP_NAME="Adrema"
APP_ENV=local
APP_KEY=YOUR_APP_KEY
APP_DEBUG=true
APP_URL=http://localhost:8000
APP_MODE=stamm
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME=me

18
.docker/nginx.Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM composer:2.2.7 as composer
WORKDIR /app
COPY . /app
RUN composer install --ignore-platform-reqs --no-dev
FROM node:17.9.0-slim as node
WORKDIR /app
COPY . /app
RUN npm install && npm run prod && npm run img && rm -R node_modules
FROM nginx:1.21.6-alpine as nginx
WORKDIR /app
COPY --chown=www-data:www-data . /app
COPY --chown=www-data:www-data --from=node /app/public /app/public
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@ -9,8 +9,10 @@ COPY . /app
RUN npm install && npm run prod && rm -R node_modules
FROM php:8.1.6-fpm as php
RUN apt-get update && apt-get install -y libcurl3-dev apt-utils zlib1g-dev libpng-dev libicu-dev libonig-dev texlive
RUN docker-php-ext-install pdo_mysql curl gd intl mbstring
WORKDIR /app
RUN apt-get update && apt-get install -y rsync libcurl3-dev apt-utils zlib1g-dev libpng-dev libicu-dev libonig-dev texlive texlive-fonts-extra
RUN docker-php-ext-install pdo_mysql curl gd intl mbstring pcntl
RUN pecl install redis && docker-php-ext-enable redis
COPY --chown=www-data:www-data . /app
COPY --chown=www-data:www-data --from=node /app/public /app/public
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor

View File

@ -1,50 +0,0 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_MODE=
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
XELATEX_BIN=
PDFLATEX_BIN=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

2
.gitignore vendored
View File

@ -26,3 +26,5 @@ tags
/public/mix-manifest.json
resources/img/sprite.svg
/.php-cs-fixer.cache
/data
.app.env

View File

@ -31,3 +31,59 @@ Ziel dieses Projektes ist es, viele Dinge, die man normalerweise manuell zu tun
Außerdem ist AdReMa auch problemlos auf Handys und Tablets bedienbar ("mobiles Design")
![Mobile Ansicht](https://git.zoomyboy.de/silva/adrema/raw/branch/master/doc/assets/member-mobile.jpg)
# Installation
Submodules updaten:
```
git submodule update --init
```
Example env erstellen:
```
cp .app.env.example .app.env
```
Container bauen
```
docker-compose build
```
Key generieren
```
docker-compose run php php artisan key:generate --show
```
Ersetze nun "YOUR_APP_KEY" in .app.env mit dem generierten Key (base64:qzX....).
Führe nun den DB Container aus, um eine erste Version der Datenbank zu erstellen.
```
docker-compose up db -d
```
Migrations ausführen
```
docker-compose run php php artisan migrate --seed
```
Alles stoppen, dann alles neu starten
```
docker-compose stop
docker-compose up -d
```
Nun kannst du auf localhost:8000 die App öffnen, einen LB verwenden, den Port mit CLI Optionen ändern, etc.
## Standard Login
Wenn du die Seeder ausführst ("--seed", siehe oben), wird ein Benutzer mit folgenden Zugangsdaten erstellt:
* E-Mail-Adresse: admin@example.com
* Passwort: admin

View File

@ -1,7 +1,6 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
@ -15,7 +14,7 @@ return [
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
'default' => env('BROADCAST_DRIVER', 'log'),
/*
|--------------------------------------------------------------------------
@ -29,7 +28,6 @@ return [
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
@ -53,7 +51,5 @@ return [
'null' => [
'driver' => 'null',
],
],
];

View File

@ -3,7 +3,6 @@
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
@ -31,7 +30,7 @@ return [
|
*/
'lifetime' => env('SESSION_LIFETIME', 120000),
'lifetime' => env('SESSION_LIFETIME', 10080), // one week
'expire_on_close' => false,
@ -195,5 +194,4 @@ return [
*/
'same_site' => 'lax',
];

View File

@ -15,10 +15,11 @@ class UserSeeder extends Seeder
*/
public function run()
{
User::factory()->create([
User::create([
'email' => 'admin@example.com',
'email_verified_at' => now(),
'password' => Hash::make('admin'),
'name' => 'Adrema Benutzer',
]);
}
}

View File

@ -1,48 +1,70 @@
version: '1'
version: '3'
services:
webservice:
image: nginx:1.21.6-alpine
container_name: nginx
depends_on:
- php
ports:
- "8000:80"
volumes:
- ./:/app
- ./storage:/app/storage
- ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf
php:
build:
context: .
dockerfile: ./.docker/php.Dockerfile
container_name: php
depends_on:
- db
- dbtest
command: php-fpm -F -R
volumes:
- ./:/app
- ./storage:/app/storage
- ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf
db:
image: mariadb:10.6.5
container_name: db
environment:
MARIADB_ROOT_PASSWORD: local
MYSQL_PASSWORD: local
MYSQL_DATABASE: db
MYSQL_USER: db
volumes:
- /opt/mysql-docker/scoutrobot-db:/var/lib/mysql
ports:
- "3309:3306"
dbtest:
image: mariadb:10.6.5
container_name: dbtest
environment:
MARIADB_ROOT_PASSWORD: local
MYSQL_PASSWORD: local
MYSQL_DATABASE: db
MYSQL_USER: db
volumes:
- /opt/mysql-docker/scoutrobot-dbtest:/var/lib/mysql
webservice:
build:
context: .
dockerfile: ./.docker/nginx.Dockerfile
image: nginx:1.21.6-alpine
container_name: nginx
depends_on:
- php
ports:
- '8000:80'
volumes:
- ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf
php:
build:
context: .
dockerfile: ./.docker/php.Dockerfile
container_name: php
depends_on:
- db
command: php-fpm -F -R
env_file:
- .app.env
environment:
DB_HOST: db
DB_DATABASE: db
DB_USERNAME: db
DB_PASSWORD: secret
QUEUE_CONNECTION: redis
XELATEX_BIN: /usr/bin/xelatex
PDFLATEX_BIN: /usr/bin/pdflatex
REDIS_HOST: redis
horizon:
build:
context: .
dockerfile: ./.docker/php.Dockerfile
container_name: horizon
depends_on:
- db
- php
command: php artisan horizon
env_file:
- .app.env
environment:
DB_HOST: db
DB_DATABASE: db
DB_USERNAME: db
DB_PASSWORD: secret
QUEUE_CONNECTION: redis
XELATEX_BIN: /usr/bin/xelatex
PDFLATEX_BIN: /usr/bin/pdflatex
REDIS_HOST: redis
db:
image: mariadb:10.6.5
container_name: db
environment:
MARIADB_ROOT_PASSWORD: secret_root_password
MYSQL_PASSWORD: secret
MYSQL_DATABASE: db
MYSQL_USER: db
volumes:
- ./data/db:/var/lib/mysql
redis:
image: redis:alpine3.18
container_name: redis