Pose l'infrastructure de base avant l'implémentation des fonctionnalités : - server/ : Fastify + TypeScript (ESM), route /health, sert client/dist - client/ : TypeScript vanilla + esbuild/sass, vue placeholder (shell) - server/Dockerfile : image multi-étapes avec yt-dlp + ffmpeg embarqués - .forgejo/workflows/publish-docker.yml : test puis publication sur le registre de conteneurs Forgejo (nécessite le secret REGISTRY_TOKEN) - biome.json : lint du repo entier (downloader/ exclu) - spec/architecture.md : documentation de ces choix Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
60 lines
2 KiB
Docker
60 lines
2 KiB
Docker
# Contexte de build = racine du dépôt (le Dockerfile copie aussi client/) :
|
|
# docker build -f server/Dockerfile -t youtubedownloader .
|
|
#
|
|
# Trois étapes : build client (esbuild + sass -> client/dist), build
|
|
# serveur (tsc -> server/dist), puis l'image runtime, qui ne contient que
|
|
# les deux dossiers dist/ compilés, les dépendances de production du
|
|
# serveur, et yt-dlp + ffmpeg (moteur d'extraction, utilisé par le futur
|
|
# service de téléchargement).
|
|
|
|
FROM node:22-alpine AS client-build
|
|
WORKDIR /app/client
|
|
COPY client/package.json client/package-lock.json* ./
|
|
RUN npm install
|
|
COPY client/build.mjs client/tsconfig.json ./
|
|
COPY client/src ./src
|
|
RUN npm run build
|
|
|
|
FROM node:22-alpine AS server-build
|
|
WORKDIR /app/server
|
|
COPY server/package.json server/package-lock.json* ./
|
|
RUN npm install
|
|
COPY server/tsconfig.json server/tsconfig.build.json ./
|
|
COPY server/src ./src
|
|
RUN npm run build
|
|
|
|
|
|
FROM node:22-alpine
|
|
|
|
# yt-dlp (binaire autonome, sans dépendance Python) + ffmpeg : dépendances
|
|
# d'exécution du futur service de téléchargement.
|
|
RUN apk add --no-cache ffmpeg curl && \
|
|
curl -fL https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux -o /usr/local/bin/yt-dlp && \
|
|
chmod +x /usr/local/bin/yt-dlp && \
|
|
apk del curl
|
|
|
|
WORKDIR /app/server
|
|
|
|
COPY server/package.json server/package-lock.json* ./
|
|
RUN npm install --omit=dev
|
|
|
|
COPY --from=server-build /app/server/dist ./dist
|
|
COPY --from=client-build /app/client/dist ../client/dist
|
|
|
|
# Dossier de travail temporaire du futur service de téléchargement,
|
|
# inscriptible par l'utilisateur non-root `node`.
|
|
RUN mkdir -p /app/server/tmp && chown -R node:node /app/server
|
|
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
HOST=0.0.0.0 \
|
|
CLIENT_DIST_PATH=/app/client/dist
|
|
|
|
USER node
|
|
EXPOSE 3000
|
|
|
|
# GET /health ne demande aucune authentification.
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|
CMD ["node", "-e", "fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
|
|
|
|
CMD ["node", "dist/index.js"]
|