Project-Image-Uploader/frontend/start-dev.sh
matthias.lotz aec9db2a76 feat(frontend): integrate preview images in gallery components
- Add imageUtils.js helper with getImageSrc() and getGroupPreviewSrc()
- Update ImageGalleryCard to use preview images for galleries
- Update ModerationGroupsPage to show preview images in modal
- Update ModerationGroupImagesPage to use preview images
- Update PublicGroupImagesPage to pass all image fields
- SlideshowPage continues using original images (full quality)
- Update nginx.dev.conf with /api/previews and /api/download routes
- Update start-dev.sh to generate correct nginx config
- Fix GroupRepository.getAllGroupsWithModerationInfo() to return full image data
- Remove obsolete version from docker-compose.override.yml
- Update TODO.md: mark frontend cleanup as completed

Performance: Gallery load times reduced by ~96% (100KB vs 3MB per image)
2025-10-31 18:20:50 +01:00

135 lines
4.5 KiB
Bash

#!/bin/bash
set -euo pipefail
# Make public writable so env.sh can write env-config.js
chmod -R a+rw ./public || true
# Run env.sh if present
if [ -x ./env.sh ]; then
./env.sh || true
fi
# Copy nginx config from mounted source if available so dev config can be
# edited on the host without rebuilding the image. Priority:
# 1) ./conf/conf.d/default.conf (project's conf folder)
# 2) ./nginx.dev.conf (bundled with the dev image at build time)
if [ -f /app/conf/conf.d/default.conf ]; then
echo "Using nginx config from /app/conf/conf.d/default.conf (creating dev variant)"
# Backup original
cp /app/conf/conf.d/default.conf /app/conf/conf.d/default.conf.backup || true
# Write a deterministic dev nginx config that proxies known API routes to
# the backend and proxies '/' to the CRA dev server so HMR works through nginx.
cat > /etc/nginx/conf.d/default.conf <<'NGINXDEV'
server {
listen 80 default_server;
listen [::]:80 default_server;
client_max_body_size 200M;
location /upload {
proxy_pass http://image-uploader-backend:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 200M;
}
location /api/upload {
proxy_pass http://image-uploader-backend:5000/upload;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 200M;
}
location /api/download {
proxy_pass http://image-uploader-backend:5000/download;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/previews {
proxy_pass http://image-uploader-backend:5000/previews;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/groups {
proxy_pass http://image-uploader-backend:5000/groups;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /moderation/groups {
proxy_pass http://image-uploader-backend:5000/moderation/groups;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ ^/groups/[a-zA-Z0-9_-]+(/.*)?$ {
proxy_pass http://image-uploader-backend:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /download {
proxy_pass http://image-uploader-backend:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Proxy webpack dev server (supports HMR / WebSocket upgrades)
location /sockjs-node/ {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
NGINXDEV
elif [ -f /app/nginx.dev.conf ]; then
echo "Using bundled nginx.dev.conf"
cp /app/nginx.dev.conf /etc/nginx/conf.d/default.conf || true
fi
# Ensure node cache exists and is writable
mkdir -p /app/node_modules/.cache || true
chmod -R a+rw /app/node_modules || true
# Ensure HOST is set so CRA binds to 0.0.0.0
export HOST=${HOST:-0.0.0.0}
# Start the React development server in background
npm run dev &
DEV_PID=$!
# Start nginx in foreground so container stays alive; nginx will proxy to the dev server
exec nginx -g 'daemon off;'