first try at docker

This commit is contained in:
j3d1 2019-12-17 01:33:40 +01:00
parent 6eecd02c5a
commit 08b1a62dc6
5 changed files with 58 additions and 0 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@
Homestead.json Homestead.json
Homestead.yaml Homestead.yaml
.env .env
.local
/public/docs /public/docs
/public/staticimages /public/staticimages
/public/thumbnails /public/thumbnails

View file

@ -37,17 +37,22 @@ class ItemController extends Controller
public function showOneItem($event, $id) public function showOneItem($event, $id)
{ {
$eid = Event::where('slug','=',$event)->first()->eid;
return response()->json(Item::find($id)); return response()->json(Item::find($id));
} }
public function create($event, Request $request) public function create($event, Request $request)
{ {
$eid = Event::where('slug','=',$event)->first()->eid;
$data = $request->all();
$data['eid'] = $eid;
$item = Item::create($request->all()); $item = Item::create($request->all());
return response()->json($item, 201); return response()->json($item, 201);
} }
public function update($event, $id, Request $request) public function update($event, $id, Request $request)
{ {
$eid = Event::where('slug','=',$event)->first()->eid;
$item = Item::findOrFail($id); $item = Item::findOrFail($id);
$item->update($request->all()); $item->update($request->all());
@ -56,6 +61,7 @@ class ItemController extends Controller
public function delete($event, $id) public function delete($event, $id)
{ {
$eid = Event::where('slug','=',$event)->first()->eid;
Item::findOrFail($id)->delete(); Item::findOrFail($id)->delete();
return response()->json(array("satus"=>'Deleted Successfully'), 200); return response()->json(array("satus"=>'Deleted Successfully'), 200);
} }

6
container/db/01_init.sql Normal file
View file

@ -0,0 +1,6 @@
DROP DATABASE IF EXISTS lostfound;
CREATE DATABASE lostfound;
CREATE OR REPLACE USER lostfound IDENTIFIED BY 'lostfound';
GRANT ALL privileges ON `lostfound`.* TO 'lostfound';

8
container/web/01_init.sh Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
cd /app
echo "executing COMPOSER UPDATE"
composer update
echo "executing DATABASE MIGRATE"
php artisan migrate --force

37
docker-compose.yml Normal file
View file

@ -0,0 +1,37 @@
version: '3.6'
services:
webserver:
image: webdevops/php-nginx-dev
ports:
- "80:80"
volumes:
- ./:/app
- ./container/web/:/entrypoint.d
environment:
WEB_DOCUMENT_ROOT: /app/public
XDEBUG_REMOTE_HOST: marvin
links:
- dbserver
depends_on:
- dbserver
networks:
- backend
restart: on-failure
dbserver:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: 'foobar'
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
networks:
- backend
restart: on-failure
ports:
- "${DB_PORT}:3306"
volumes:
- ./.local/db:/var/lib/mysql
- ./container/db/:/docker-entrypoint-initdb.d
networks:
backend:
driver: bridge