Skip to content

Commit

Permalink
Refactor Docker configuration and development setup
Browse files Browse the repository at this point in the history
- Update .dockerignore with comprehensive ignore patterns for API and client
- Modify docker-compose files to improve service configurations
- Enhance Nginx configuration for development and production environments
- Refactor Dockerfile.api with improved build process
- Add docker-setup.sh script for simplified Docker deployment
- Update update-credentials.vue page with improved UI
- Remove hCaptcha dependency from package-lock.json
- Update PHP configuration and entrypoint scripts
  • Loading branch information
JhumanJ committed Jan 29, 2025
1 parent bf85d8f commit f7df6bc
Show file tree
Hide file tree
Showing 26 changed files with 1,980 additions and 1,751 deletions.
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,38 @@
/Dockerfile
/data
\.env

# API ignores
api/vendor/
api/storage/framework/
api/storage/logs/
api/storage/app/
api/.env
api/.env.*
api/.git/
api/.idea/
api/.vscode/
api/node_modules/
api/*.log

# Client ignores
client/node_modules/
client/.nuxt/
client/dist/
client/.output/
client/coverage/
client/.env
client/.env.*
client/.git/
client/.idea/
client/.vscode/
client/npm-debug.log*
client/yarn-debug.log*
client/yarn-error.log*

# Global ignores
**/.DS_Store
**/*.log
**/.git/
**/.idea/
**/.vscode/
9 changes: 7 additions & 2 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "client/**"
- "docker/**"
- "docker-compose*.yml"
- ".github/workflows/dockerhub.yml"
workflow_dispatch:

permissions:
Expand All @@ -30,8 +31,8 @@ jobs:
echo "UI_TAGS=${{secrets.DOCKER_UI_REPO}}:latest,${{secrets.DOCKER_UI_REPO}}:${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
else
echo "VERSION=dev" >> $GITHUB_ENV
echo "API_TAGS=${{secrets.DOCKER_API_REPO}}:dev" >> $GITHUB_ENV
echo "UI_TAGS=${{secrets.DOCKER_UI_REPO}}:dev" >> $GITHUB_ENV
echo "API_TAGS=${{secrets.DOCKER_API_REPO}}:dev,${{secrets.DOCKER_API_REPO}}:dev-${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "UI_TAGS=${{secrets.DOCKER_UI_REPO}}:dev,${{secrets.DOCKER_UI_REPO}}:dev-${GITHUB_SHA::7}" >> $GITHUB_ENV
fi
- name: Check out the repo
Expand Down Expand Up @@ -59,6 +60,8 @@ jobs:
build-args: |
APP_ENV=${{ env.VERSION == 'dev' && 'local' || 'production' }}
tags: ${{ env.API_TAGS }}
cache-from: type=registry,ref=${{secrets.DOCKER_API_REPO}}:dev
cache-to: type=inline

- name: Build and push Client image
uses: docker/build-push-action@v5
Expand All @@ -68,3 +71,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.UI_TAGS }}
cache-from: type=registry,ref=${{secrets.DOCKER_UI_REPO}}:dev
cache-to: type=inline
4 changes: 3 additions & 1 deletion api/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Middleware\AcceptsJsonMiddleware;
use App\Http\Middleware\AuthenticateJWT;
use App\Http\Middleware\CustomDomainRestriction;
use App\Http\Middleware\DevCorsMiddleware;
use App\Http\Middleware\ImpersonationMiddleware;
use App\Http\Middleware\IsAdmin;
use App\Http\Middleware\IsModerator;
Expand All @@ -25,6 +26,7 @@ class Kernel extends HttpKernel
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
DevCorsMiddleware::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
Expand Down Expand Up @@ -66,7 +68,7 @@ class Kernel extends HttpKernel
],

'api-external' => [
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
Expand Down
33 changes: 33 additions & 0 deletions api/app/Http/Middleware/DevCorsMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class DevCorsMiddleware
{
public function handle(Request $request, Closure $next)
{
// Only apply in development mode
if (!config('app.dev_cors')) {
return $next($request);
}

$response = $next($request);

// Handle preflight OPTIONS request
if ($request->isMethod('OPTIONS')) {
$response = response('', 200);
}

// Add CORS headers
$response->headers->set('Access-Control-Allow-Origin', 'http://localhost:3000', true);
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, PATCH', true);
$response->headers->set('Access-Control-Allow-Headers', 'DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization, X-XSRF-TOKEN, Accept', true);
$response->headers->set('Access-Control-Allow-Credentials', 'true', true);
$response->headers->set('Access-Control-Expose-Headers', 'Content-Length, Content-Range', true);

return $response;
}
}
Empty file modified api/bootstrap/cache/.gitignore
100644 → 100755
Empty file.
Loading

0 comments on commit f7df6bc

Please sign in to comment.