Dockerized for dev purposes
This commit is contained in:
16
ReadMe.md
Normal file
16
ReadMe.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# **Dev Installation Instructions**
|
||||||
|
|
||||||
|
1. Create a .env file from .env.example and set database config as such
|
||||||
|
```
|
||||||
|
DB_CONNECTION=pgsql
|
||||||
|
DB_HOST=postgres
|
||||||
|
DB_PORT=5432
|
||||||
|
DB_DATABASE=dredge_tours
|
||||||
|
DB_USERNAME=dredge
|
||||||
|
DB_PASSWORD=dredge123
|
||||||
|
```
|
||||||
|
2. Run `docker compose up -d --build` on first use and `docker compose up -d` on subsequent uses
|
||||||
|
3. With containers running, run `docker compose run php php artisan app:init`
|
||||||
|
|
||||||
|
4. Run `docker compose exec php npm run dev` to start a hot reload environment, or `docker compose exec php npm run build` for a static, manual reload
|
||||||
|
|
||||||
64
app/Console/Commands/InitializeApp.php
Normal file
64
app/Console/Commands/InitializeApp.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
|
class InitializeApp extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'app:initialize-app';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->info('🚀 Initializing application...');
|
||||||
|
|
||||||
|
// Composer install
|
||||||
|
$this->info('📦 Installing Composer dependencies...');
|
||||||
|
$this->runProcess(['composer', 'install', '--no-interaction']);
|
||||||
|
|
||||||
|
// NPM install
|
||||||
|
$this->info('📦 Installing NPM dependencies...');
|
||||||
|
$this->runProcess(['npm', 'install']);
|
||||||
|
|
||||||
|
// Generate key
|
||||||
|
$this->info('🔑 Generating application key...');
|
||||||
|
Artisan::call('key:generate', [], $this->output);
|
||||||
|
|
||||||
|
// Migrate and seed
|
||||||
|
$this->info('🗄️ Running migrations and seeders...');
|
||||||
|
Artisan::call('migrate:fresh', ['--seed' => true], $this->output);
|
||||||
|
|
||||||
|
$this->info('✅ Application initialized successfully!');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function runProcess(array $command)
|
||||||
|
{
|
||||||
|
$process = new Process($command);
|
||||||
|
$process->setTimeout(300); // 5 minutes
|
||||||
|
$process->run(function ($type, $buffer) {
|
||||||
|
echo $buffer;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!$process->isSuccessful()) {
|
||||||
|
$this->error("Failed to run: " . implode(' ', $command));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
docker-compose.yml
Normal file
45
docker-compose.yml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
services:
|
||||||
|
php:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/php/Dockerfile
|
||||||
|
container_name: dredge-tours-php
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
ports:
|
||||||
|
- "5173:5173"
|
||||||
|
networks:
|
||||||
|
- dredge-tours
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.27
|
||||||
|
container_name: dredge-tours-nginx
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
depends_on:
|
||||||
|
- php
|
||||||
|
networks:
|
||||||
|
- dredge-tours
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:16
|
||||||
|
container_name: dredge-tours-postgres
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: dredge
|
||||||
|
POSTGRES_PASSWORD: dredge123
|
||||||
|
POSTGRES_DB: dredge_tours
|
||||||
|
volumes:
|
||||||
|
- pgdata:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
networks:
|
||||||
|
- dredge-tours
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dredge-tours:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
pgdata:
|
||||||
19
docker/nginx/default.conf
Normal file
19
docker/nginx/default.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
root /var/www/html/public;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_max_body_size 100M;
|
||||||
|
}
|
||||||
16
docker/php/Dockerfile
Normal file
16
docker/php/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM php:8.4-fpm
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git curl zip unzip libpq-dev \
|
||||||
|
&& docker-php-ext-install pdo pdo_pgsql
|
||||||
|
|
||||||
|
# Install Node.js 20.x
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||||
|
&& apt-get install -y nodejs
|
||||||
|
|
||||||
|
# Install Composer globally
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
CMD ["php-fpm"]
|
||||||
1293
package-lock.json
generated
1293
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@ export default defineConfig({
|
|||||||
ssr: 'resources/js/ssr.ts',
|
ssr: 'resources/js/ssr.ts',
|
||||||
refresh: true,
|
refresh: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
wayfinder({
|
wayfinder({
|
||||||
formVariants: true,
|
formVariants: true,
|
||||||
@@ -30,4 +31,14 @@ export default defineConfig({
|
|||||||
autoImport: true,
|
autoImport: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
server: {
|
||||||
|
host: '0.0.0.0',
|
||||||
|
port: 5173,
|
||||||
|
hmr: {
|
||||||
|
host: 'localhost'
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
usePolling: true, // Needed for Docker on Windows
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user