fix(dev): support root bind mounts and LAN Vite access

Keep the dev container as root for s6 init so composer can create
vendor/ on root-owned mounts, then chown writable paths to www-data.
Move init-setup into a shell script and expose VITE_HOST/PORT for
remote HMR (LAN/Tailscale) with Vite listening on 0.0.0.0.
This commit is contained in:
Andras Bacsai committed 2026-07-18 20:56:01 +02:00
1 parent 913d033c75
commit e2c2180f4f
20 files changed
+80 -44

No files matched your search

+17 -20
View File
@@ -2,33 +2,30 @@ import { defineConfig, loadEnv } from "vite";
import laravel from "laravel-vite-plugin";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const viteHost = env.VITE_HOST || null;
const vitePort = Number(env.VITE_PORT || 5173);
const env = loadEnv(mode, process.cwd(), "");
// Prefer process.env so Docker Compose can override without writing .env.
// Set VITE_HOST to a browser-reachable hostname/IP when accessing the app
// from another device (LAN / Tailscale), e.g. VITE_HOST=100.75.155.70
const viteHost = (process.env.VITE_HOST || env.VITE_HOST || "localhost").trim();
const vitePort = Number(process.env.VITE_PORT || env.VITE_PORT || 5173);
return {
server: {
watch: {
ignored: [
"**/dev_*_data/**",
"**/storage/**",
],
ignored: ["**/dev_*_data/**", "**/storage/**"],
},
// Listen on all interfaces so Docker / remote clients can reach the dev server
host: "0.0.0.0",
port: vitePort,
strictPort: true,
allowedHosts: true,
cors: {
origin: [
/^https?:\/\/localhost(:\d+)?$/,
/^https?:\/\/127\.0\.0\.1(:\d+)?$/,
/^https?:\/\/\[::1\](:\d+)?$/,
...(env.APP_URL ? [env.APP_URL] : []),
...(viteHost ? [`http://${viteHost}:${vitePort}`, `https://${viteHost}:${vitePort}`] : []),
],
// App (:8000) and Vite (:5173) are different origins; allow any host in dev
cors: true,
origin: `http://${viteHost}:${vitePort}`,
hmr: {
host: viteHost,
clientPort: vitePort,
},
origin: viteHost ? `http://${viteHost}:${vitePort}` : undefined,
hmr: viteHost
? { host: viteHost, clientPort: vitePort }
: true,
},
plugins: [
laravel({
@@ -36,5 +33,5 @@ export default defineConfig(({ mode }) => {
refresh: true,
}),
],
}
};
});