Hello,
I'm trying to dockerize my laravel, inertiajs, vue setup but I keep getting 404 results in laravel font.
I believe I have narrowed down the issue to inertiajs but what exactly is wrong here I am unsure about, something about how inertiajs serves routes(? a SPA?). I'd appreciate any insight or feedback on what could be wrong.
My stack is laravel, inertiajs, vue3, docker, docker compose, previously pnpm but now I wish to run bun instead, vite, laravel, postgresql.
The containers can ping eachother and networking looks ok, the routes are generated for localhost:8080, the database can be reached over pgadmin, the vite server serves at localhost, the composer installs, migrations run through.
I get no apparent errors in logs except for the constant 404 on localhost:8080 inertia routes, I tried with a test dd route and that renders fine
Route::get('/test', function () {
return dd('test');
});
// Regular domain routes
Route::domain(config('app.domain'))->group(function () {
// Standalone routes
Route::get('/', [HomeController::class, 'welcome'])->name('welcome');
Route::get('/about', [HomeController::class, 'about'])->name('about');
Route::get('home', [HomeController::class, 'index'])->name('home');
...
my nginx config (at the moment I'm only trying to get local development to work, prod comes later):
server {
listen 80;
server_name localhost;
index index.php index.html;
server_name localhost;
root /var/www/html/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
the Dockerfile:
FROM php:8.3-fpm-alpine
# Install dependencies
RUN apk add --no-cache postgresql-dev libzip-dev \
zip \
unzip \
curl \
bash \
nodejs \
npm \
&& docker-php-ext-install pdo pdo_pgsql zip
# Install composer
COPY --from=composer/composer:latest-bin /composer /usr/bin/composer
# Copy existing application directory permissions
COPY --chown=www-data:www-data . /var/www/html
WORKDIR /var/www/html
EXPOSE 9000
docker-compose:
services:
db:
container_name: db
image: postgres:15-alpine
environment:
LANG: en_GB.UTF-8
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=en_GB.UTF-8"
volumes:
- postgres_data:/var/lib/postgresql/data
command: postgres -c fsync=off
networks:
- default
pgAdmin:
container_name: pgAdmin
image: dpage/pgadmin4
ports:
- "5050:80"
environment:
PGADMIN_DEFAULT_EMAIL: email
PGADMIN_DEFAULT_PASSWORD: password
depends_on:
- db
volumes:
- pgadmin_data:/var/lib/pgadmin
networks:
- default
app:
container_name: app
build:
context: .
dockerfile: Dockerfile
image: dhycken/grindvakt:${COMPOSE_PROFILES:-dev}
volumes:
- ./:/var/www/html
environment:
- APP_ENV=${APP_ENV:-local}
- DB_HOST=db
ports:
- "9000:9000"
depends_on:
- db
networks:
- default
profiles: [dev, prod]
bun:
container_name: bun
profiles: [dev]
image: oven/bun:latest
command: bun run dev
working_dir: /var/www/html
volumes:
- .:/var/www/html
networks:
- default
nginx-dev:
profiles: [dev]
container_name: nginx-dev
restart: unless-stopped
image: nginx:alpine
volumes:
- ./:/var/www/html
- ./nginx.dev.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"
depends_on:
- app
networks:
- default
networks:
default:
name: app-network
volumes:
postgres_data:
pgadmin_data:
docker ps:
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
app dhycken/grindvakt:dev "docker-php-entrypoi…" app 8 minutes ago Up 8 minutes 0.0.0.0:9000->9000/tcp
bun oven/bun:latest "/usr/local/bin/dock…" bun 8 minutes ago Up 8 minutes
db postgres:15-alpine "docker-entrypoint.s…" db 8 minutes ago Up 8 minutes 5432/tcp
nginx-dev nginx:alpine "/docker-entrypoint.…" nginx-dev 8 minutes ago Up 8 minutes 0.0.0.0:8080->80/tcp
pgAdmin dpage/pgadmin4 "/entrypoint.sh" pgAdmin 8 minutes ago Up 8 minutes 443/tcp, 0.0.0.0:5050->80/tcp