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 RUN npm install && npm run prod && rm -R node_modules
FROM php:8.1.6-fpm as php 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 WORKDIR /app
RUN docker-php-ext-install pdo_mysql curl gd intl mbstring 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 . /app
COPY --chown=www-data:www-data --from=node /app/public /app/public COPY --chown=www-data:www-data --from=node /app/public /app/public
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor 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 /public/mix-manifest.json
resources/img/sprite.svg resources/img/sprite.svg
/.php-cs-fixer.cache /.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") 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) ![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 <?php
return [ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Default Broadcaster | Default Broadcaster
@ -15,7 +14,7 @@ return [
| |
*/ */
'default' => env('BROADCAST_DRIVER', 'null'), 'default' => env('BROADCAST_DRIVER', 'log'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -29,7 +28,6 @@ return [
*/ */
'connections' => [ 'connections' => [
'pusher' => [ 'pusher' => [
'driver' => 'pusher', 'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'), 'key' => env('PUSHER_APP_KEY'),
@ -53,7 +51,5 @@ return [
'null' => [ 'null' => [
'driver' => 'null', 'driver' => 'null',
], ],
], ],
]; ];

View File

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

View File

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

View File

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