Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:

- name: Build app
run:
sudo docker-compose up -d --build &&
sudo docker-compose -f dev-docker-compose.yml up -d --build &&
sudo chmod -R 777 $(pwd)/www &&
sudo docker-compose run php composer update &&
sudo docker-compose run php composer upgrade &&
sudo docker-compose run php composer install &&
sudo docker-compose run php php artisan migrate
sudo docker-compose -f dev-docker-compose.yml run php composer update &&
sudo docker-compose -f dev-docker-compose.yml run php composer upgrade &&
sudo docker-compose -f dev-docker-compose.yml run php composer install &&
sudo docker-compose -f dev-docker-compose.yml run php php artisan migrate

- name: Make seed
run: sudo docker-compose run php php artisan db:seed
run: sudo docker-compose -f dev-docker-compose.yml run php php artisan db:seed

# - name: Testing app
# run: sudo docker-compose run php php artisan test
83 changes: 83 additions & 0 deletions dev-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: "3"

services:
web:
build:
context: .
dockerfile: ./etc/nginx/nginx.Dockerfile
container_name: beautiful-web
ports:
- '80:80'
volumes:
- ./www:/var/www
depends_on:
- php
networks:
- beautiful-net
php:
build:
context: .
dockerfile: ./etc/php/php.dev.Dockerfile
ports:
- '9000:9000'
depends_on:
- cache
- db
volumes:
- ./www:/var/www
networks:
- beautiful-net

cache:
build:
context: .
dockerfile: ./etc/redis/redis.Dockerfile
ports:
- '6379:6379'
networks:
- beautiful-net
volumes:
- volume-cache:/data

db:
build:
context: .
dockerfile: ./etc/postgresql/postgres.Dockerfile
env_file:
- ./etc/postgresql/.env
ports:
- '5432:5432'
volumes:
- volume-db:/var/lib/postgresql/data
networks:
- beautiful-net

s3:
image: adobe/s3mock
restart: unless-stopped
environment:
- debug=true
- COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS=laravel
- COM_ADOBE_TESTING_S3MOCK_STORE_RETAIN_FILES_ON_EXIT=true
- COM_ADOBE_TESTING_S3MOCK_STORE_ROOT=containers3root
ports:
- '9090:9090'
volumes:
- ./locals3root:/containers3root
networks:
- beautiful-net

adminer:
image: adminer
ports:
- '8080:8080'
networks:
- beautiful-net

networks:
beautiful-net:
driver: bridge

volumes:
volume-db:
volume-cache:
38 changes: 38 additions & 0 deletions etc/php/php.dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM php:8.4-fpm-alpine

WORKDIR /var/www

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apk update && apk --no-cache add \
build-base \
libpng-dev \
libjpeg-turbo-dev \
libwebp-dev \
libxpm-dev \
freetype-dev \
libzip-dev \
zip \
unzip \
git \
bash \
fcgi \
libmcrypt-dev \
oniguruma-dev \
postgresql-dev

RUN rm -rf /var/cache/apk/*

RUN docker-php-ext-configure gd \
--with-freetype=/usr/include/ \
--with-jpeg=/usr/include/ \
--with-webp=/usr/include/ \
&& docker-php-ext-install gd \
&& docker-php-ext-install pdo pdo_pgsql mbstring zip exif pcntl bcmath opcache

RUN chown 1000:1000 -R /var/www
RUN find . -type d -exec chmod 775 {} \; && \
find . -type f -exec chmod 664 {} \;

USER 1000
CMD ["php-fpm"]
2 changes: 2 additions & 0 deletions www/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost

ADMIN_PASSWORD=password

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
Expand Down
39 changes: 39 additions & 0 deletions www/app/Modules/Admin/Admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Modules\Admin;

use App\Interfaces\ModuleInterface;
use App\Modules\Admin\Routes\Route;

class Admin implements ModuleInterface
{
private $name = 'Admin';
private $version = '0.0.1';

public function enable(): bool
{
return true;
}

public function disable(): bool
{
return true;
}

public function registerRoutes(): ModuleInterface
{
Route::index();

return $this;
}

public function getName(): string
{
return $this->name;
}

public function getVersion(): string
{
return $this->version;
}
}
23 changes: 23 additions & 0 deletions www/app/Modules/Admin/Controllers/AdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Modules\Admin\Controllers;

use App\Modules\Master\Repository\UserRepository;
use App\Modules\Profile\Repository\CommentRepository;
use App\Modules\Profile\Repository\PostRepository;
use \Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;

class AdminController extends Controller
{
public function index(Request $request, array $data = []): View
{
return view('admin.index', [
'usersCount' => Cache::remember('users_count', 60, fn () => UserRepository::getAll()->count()),
'postsCount' => Cache::remember('posts_count', 60, fn () => PostRepository::getAll()->count()),
'commentCount' => Cache::remember('comments_count', 60, fn () => CommentRepository::getAll()->count()),
]);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\Modules\Admin\Controllers\Contents;

use App\Modules\Admin\Controllers\Controller;
use App\Modules\Profile\Models\Comment;
use App\Modules\Profile\Repository\CommentRepository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;

class CommentsAdminController extends Controller
{

public function index(Request $request, array $data = []): View|RedirectResponse
{
$data = $this->getData($request, 'comments', (new CommentRepository));

$result = parent::index($request, $data);
if($result) {
return $result;
}

$comment = new Comment;
$contents = $this->getContents($comment);

return view('admin.content.index', [
'fillables' => $this->getFillables($comment),
'contents' => $contents,
'currentPage' => $contents->currentPage(),
'lastPage' => $contents->lastPage(),
'route' => 'admin.comments',
]);
}

private function getFillables(Comment $comment): array
{
$fillables = $comment->getFillable();
$fillables = array_merge(['id',], $fillables);
$fillables = array_merge($fillables, ['created_at', 'updated_at']);

return $fillables;
}

private function getContents(Comment $comment): LengthAwarePaginator
{
return $comment->limit(20)
->paginate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\Modules\Admin\Controllers\Contents;

use App\Modules\Admin\Controllers\Controller;
use App\Modules\Master\Models\User;
use App\Modules\Master\Repository\UserRepository;
use App\Modules\Profile\Models\Post;
use App\Modules\Profile\Repository\PostRepository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;

class PostsAdminController extends Controller
{

public function index(Request $request, array $data = []): View|RedirectResponse
{
$data = $this->getData($request, 'posts', (new PostRepository));

$result = parent::index($request, $data);
if($result) {
return $result;
}

$post = new Post;
$contents = $this->getContents($post);

return view('admin.content.index', [
'fillables' => $this->getFillables($post),
'contents' => $contents,
'currentPage' => $contents->currentPage(),
'lastPage' => $contents->lastPage(),
'route' => 'admin.posts'
]);
}

private function getFillables(Post $post): array
{
$fillables = $post->getFillable();
$fillables = array_merge(['id',], $fillables);
$fillables = array_merge($fillables, ['created_at', 'updated_at']);

return $fillables;
}

private function getContents(Post $post): LengthAwarePaginator
{
return $post
->limit(20)
->paginate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\Modules\Admin\Controllers\Contents;

use App\Modules\Admin\Controllers\Controller;
use App\Modules\Master\Models\Role;
use App\Modules\Master\Repository\RoleRepository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;

class RolesAdminController extends Controller
{

public function index(Request $request, array $data = []): View|RedirectResponse
{
$data = $this->getData($request, 'roles', (new RoleRepository));

$result = parent::index($request, $data);
if($result) {
return $result;
}

$role = new Role;
$contents = $this->getContents($role);

return view('admin.content.index', [
'fillables' => $this->getFillables($role),
'contents' => $contents,
'currentPage' => $contents->currentPage(),
'lastPage' => $contents->lastPage(),
'route' => 'admin.roles',
]);
}

private function getFillables(Role $role): array
{
$fillables = $role->getFillable();
$fillables = array_merge(['id',], $fillables);
$fillables = array_merge($fillables, ['created_at', 'updated_at']);

return $fillables;
}

private function getContents(Role $role): LengthAwarePaginator
{
return $role->limit(20)
->paginate();
}
}
Loading