# Build stage: generate a static index page for the repository
FROM python:3.11-slim AS builder
WORKDIR /workspace
COPY . /workspace
RUN mkdir -p build
RUN python - << 'PY'
import os
entries = [f for f in os.listdir('.') if not f.startswith('.')]
html_items = []
for f in sorted(entries):
html_items.append(f'<li><a href="./{f}">{f}</a></li>')
html = '<html><head><meta charset="utf-8"/><title>Repository Index</title></head><body><h1>Repository Index</h1><ul>' + ''.join(html_items) + '</ul></body></html>'
open('build/index.html','w').write(html)
print('index.html generated')
PY
# Final runtime image
FROM python:3.11-slim
WORKDIR /app
# Copy the built site into /app/build so it can be served from the repo root
COPY --from=builder /workspace/build /app/build
EXPOSE 8000
# Serve from repository root; /build/index.html will be accessible as http://host:8000/build/index.html
CMD ["python", "-m", "http.server", "8000"]