Add Docker build/push and Dockge deploy workflow
- Add api/admin/upload Dockerfiles and .dockerignore - Add deploy/docker-compose.yml (ports 3001-3004) and deploy/README.md - Add scripts/docker-build-push.sh for Gitea registry push - Add Gitea/SSH scripts and Google Drive controller updates Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
20
api/.dockerignore
Normal file
20
api/.dockerignore
Normal file
@@ -0,0 +1,20 @@
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
node_modules
|
||||
vendor
|
||||
storage/logs/*
|
||||
storage/framework/cache/*
|
||||
storage/framework/sessions/*
|
||||
storage/framework/views/*
|
||||
tests
|
||||
.phpunit.result.cache
|
||||
.phpunit.cache
|
||||
.idea
|
||||
.vscode
|
||||
*.log
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
README.md
|
||||
42
api/Dockerfile
Normal file
42
api/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# event-uploader API – Laravel. Same image used for api and queue (different command).
|
||||
FROM php:8.3-cli-alpine
|
||||
|
||||
# PHP extensions for Laravel + MySQL + Google etc.
|
||||
RUN apk add --no-cache \
|
||||
git \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libxml2-dev \
|
||||
oniguruma-dev \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
pdo_mysql \
|
||||
gd \
|
||||
fileinfo \
|
||||
mbstring \
|
||||
xml \
|
||||
zip \
|
||||
pcntl \
|
||||
bcmath
|
||||
|
||||
# Composer
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Dependencies first (better layer cache)
|
||||
COPY composer.json composer.lock ./
|
||||
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||
|
||||
# Application
|
||||
COPY . .
|
||||
|
||||
# .env and APP_KEY are provided at runtime via compose
|
||||
|
||||
# Writable dirs (runtime will mount or use defaults)
|
||||
RUN mkdir -p storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache \
|
||||
&& chmod -R 775 storage bootstrap/cache
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Services\GoogleDrive\GoogleDriveService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -53,7 +54,9 @@ class GoogleDriveController extends Controller
|
||||
|
||||
public function status(): JsonResponse
|
||||
{
|
||||
$connection = Auth::user()?->googleDriveConnections()->first();
|
||||
/** @var User|null $user */
|
||||
$user = Auth::user();
|
||||
$connection = $user?->googleDriveConnections()?->first();
|
||||
|
||||
return response()->json([
|
||||
'connected' => (bool) $connection,
|
||||
@@ -63,7 +66,9 @@ class GoogleDriveController extends Controller
|
||||
|
||||
public function disconnect(): JsonResponse
|
||||
{
|
||||
Auth::user()?->googleDriveConnections()->delete();
|
||||
/** @var User|null $user */
|
||||
$user = Auth::user();
|
||||
$user?->googleDriveConnections()?->delete();
|
||||
|
||||
return response()->json(['message' => 'Disconnected']);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Upload;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -52,7 +53,7 @@ class EventUploadController extends Controller
|
||||
|
||||
public function upload(Request $request, string $slug): JsonResponse
|
||||
{
|
||||
\Log::info('Upload request received', [
|
||||
Log::info('Upload request received', [
|
||||
'slug' => $slug,
|
||||
'has_file' => $request->hasFile('file'),
|
||||
'files' => array_keys($request->allFiles()),
|
||||
@@ -76,7 +77,7 @@ class EventUploadController extends Controller
|
||||
|
||||
$file = $request->file('file');
|
||||
|
||||
\Log::info('File details', [
|
||||
Log::info('File details', [
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'size' => $file->getSize(),
|
||||
'mime' => $file->getMimeType(),
|
||||
@@ -112,7 +113,7 @@ class EventUploadController extends Controller
|
||||
$tempPath = $file->storeAs('uploads/temp', $storedName, ['disk' => 'local']);
|
||||
|
||||
if ($tempPath === false || $tempPath === null) {
|
||||
\Log::error('File storeAs returned false/null', [
|
||||
Log::error('File storeAs returned false/null', [
|
||||
'original_name' => $originalName,
|
||||
'stored_name' => $storedName,
|
||||
'temp_dir' => $tempDir,
|
||||
@@ -122,7 +123,7 @@ class EventUploadController extends Controller
|
||||
return response()->json(['message' => 'Failed to store file'], 500);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('File storage exception', [
|
||||
Log::error('File storage exception', [
|
||||
'error' => $e->getMessage(),
|
||||
'original_name' => $originalName,
|
||||
'stored_name' => $storedName,
|
||||
@@ -133,7 +134,7 @@ class EventUploadController extends Controller
|
||||
// Local disk stores in app/private/, so construct full path accordingly
|
||||
$fullPath = storage_path('app/private/'.$tempPath);
|
||||
|
||||
\Log::info('File stored successfully', [
|
||||
Log::info('File stored successfully', [
|
||||
'temp_path' => $tempPath,
|
||||
'full_path' => $fullPath,
|
||||
'file_exists' => file_exists($fullPath),
|
||||
|
||||
@@ -203,6 +203,7 @@ class GoogleDriveService
|
||||
$file->setParents([$folderId]);
|
||||
|
||||
$client->setDefer(true);
|
||||
/** @var \Psr\Http\Message\RequestInterface $request When defer is true, create() returns the request instead of executing it */
|
||||
$request = $service->files->create($file, [
|
||||
'mimeType' => $mimeType,
|
||||
'uploadType' => 'resumable',
|
||||
|
||||
Reference in New Issue
Block a user