fix: replace broken symlink with REPORTS_DIR env var
The ln -sf /data/reports /app/reports was creating the symlink INSIDE /app/reports/ (since that dir already existed from COPY) instead of replacing it. Result: sitespeed.io wrote to /app/reports/<id> and the parser looked there too, but the volume was at /data/reports. Fix: set REPORTS_DIR=/data/reports in Docker ENV and use it in both runner.js (outputFolder) and app.js (static serving). No symlink needed. Also add .dockerignore to exclude reports/, node_modules/, .git/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules/
|
||||||
|
reports/
|
||||||
|
speedboard.db
|
||||||
|
*.db-shm
|
||||||
|
*.db-wal
|
||||||
|
.git/
|
||||||
10
Dockerfile
10
Dockerfile
@@ -26,15 +26,13 @@ RUN SITESPEED_JS=$(find / -name 'sitespeed.js' -path '*/bin/*' 2>/dev/null | hea
|
|||||||
echo "Build-time sitespeed.js found at: $SITESPEED_JS"; \
|
echo "Build-time sitespeed.js found at: $SITESPEED_JS"; \
|
||||||
echo "export SITESPEED_BIN=$SITESPEED_JS" > /sitespeed_env
|
echo "export SITESPEED_BIN=$SITESPEED_JS" > /sitespeed_env
|
||||||
|
|
||||||
# Create persistent directories
|
# Create the persistent data directories (volume mount points)
|
||||||
RUN mkdir -p /data/reports
|
RUN mkdir -p /data/reports /data/db
|
||||||
|
|
||||||
# Symlink reports dir into app folder
|
# Runtime env — REPORTS_DIR and DB_PATH point to the mounted volumes
|
||||||
RUN ln -sf /data/reports /app/reports
|
|
||||||
|
|
||||||
# Runtime env
|
|
||||||
ENV PORT=3132 \
|
ENV PORT=3132 \
|
||||||
IN_DOCKER=1 \
|
IN_DOCKER=1 \
|
||||||
|
REPORTS_DIR=/data/reports \
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
EXPOSE 3132
|
EXPOSE 3132
|
||||||
|
|||||||
5
app.js
5
app.js
@@ -27,8 +27,9 @@ app.set('view engine', 'pug');
|
|||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
// Static reports
|
// Static reports — use REPORTS_DIR env var so Docker and local both work
|
||||||
app.use('/reports', express.static(join(__dirname, 'reports')));
|
const REPORTS_DIR = process.env.REPORTS_DIR || join(__dirname, 'reports');
|
||||||
|
app.use('/reports', express.static(REPORTS_DIR));
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
app.use('/', indexRouter);
|
app.use('/', indexRouter);
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import { existsSync } from 'fs';
|
|||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
const LOCAL_BIN = join(__dirname, '..', 'sitespeed.io', 'bin', 'sitespeed.js');
|
const LOCAL_BIN = join(__dirname, '..', 'sitespeed.io', 'bin', 'sitespeed.js');
|
||||||
|
const REPORTS_DIR = process.env.REPORTS_DIR || join(__dirname, 'reports');
|
||||||
|
|
||||||
export function runTest(job, onLine) {
|
export function runTest(job, onLine) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const outputFolder = join(__dirname, 'reports', job.id);
|
const outputFolder = join(REPORTS_DIR, job.id);
|
||||||
const isDocker = !!process.env.IN_DOCKER;
|
const isDocker = !!process.env.IN_DOCKER;
|
||||||
|
|
||||||
const sitespeedArgs = [
|
const sitespeedArgs = [
|
||||||
|
|||||||
Reference in New Issue
Block a user