feat: update docker-compose to add static file service and configure Nginx with Traefik routing

feat: enhance Next.js configuration with rewrites for public directory
fix: adjust audio file path in AudioPlayer component to include public directory
This commit is contained in:
averel10
2026-03-13 09:40:56 +01:00
parent a1ea5e95e5
commit 1debc1b36e
3 changed files with 42 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ services:
container_name: tts-app
expose:
- "3000"
env_file: .env
environment:
- NODE_ENV=production
- NEXT_PUBLIC_APP_URL=https://tts.averel10.app
@@ -56,6 +57,35 @@ services:
- traefik
restart: unless-stopped
static:
image: nginx:alpine
container_name: tts-static
expose:
- "80"
volumes:
- ./public:/usr/share/nginx/html:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.tts-static.rule=Host(`tts.averel10.app`) && PathPrefix(`/public`)"
- "traefik.http.routers.tts-static.entrypoints=web,websecure"
- "traefik.http.routers.tts-static.service=tts-static-service"
- "traefik.http.routers.tts-static.middlewares=https-redirect,public-strip"
- "traefik.http.routers.tts-static-secure.rule=Host(`tts.averel10.app`) && PathPrefix(`/public`)"
- "traefik.http.routers.tts-static-secure.entrypoints=websecure"
- "traefik.http.routers.tts-static-secure.tls=true"
- "traefik.http.routers.tts-static-secure.tls.certresolver=letsencrypt"
- "traefik.http.routers.tts-static-secure.service=tts-static-service"
- "traefik.http.routers.tts-static-secure.middlewares=public-strip"
- "traefik.http.services.tts-static-service.loadbalancer.server.port=80"
- "traefik.http.middlewares.public-strip.stripprefix.prefixes=/public"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
networks:
- traefik-network
depends_on:
- traefik
restart: unless-stopped
networks:
traefik-network:
driver: bridge
driver: bridge

View File

@@ -7,6 +7,16 @@ const nextConfig: NextConfig = {
},
},
output: "standalone",
async rewrites() {
return {
beforeFiles: [
{
source: '/public/:path*',
destination: '/:path*',
},
],
};
},
};
export default nextConfig;

View File

@@ -17,7 +17,7 @@ export default function AudioPlayer({ fileName, datasetId, externalId }: AudioPl
// Extract file extension from original fileName and construct URL using externalId
const fileExtension = fileName.substring(fileName.lastIndexOf('.'));
const audioPath = `/datasets/${datasetId}/${externalId}${fileExtension}`;
const audioPath = `/public/datasets/${datasetId}/${externalId}${fileExtension}`;
// Stop playing if another audio started
useEffect(() => {