33800 Docs

← Retour

Proposition : Déploiement hellocar-api en PROD

Date : 09-12-2024 00:38 Status : IMPLEMENTEE Service : hellocar:api Environnement : PROD


Analyse du projet

Élément Valeur
Type Monorepo pnpm
Framework API Elysia (Bun)
Dépendance workspace @hellocar/common
Shortcut bun
Port 4510
Domaine hellocar-api-prod.33800.nowhere84.com

Variables d'environnement (résolues)

Variable Valeur
NODE_ENV production
API_PORT 4510
API_HOST 0.0.0.0
SUPABASE_URL https://hellocar-api.33800.nowhere84.com
SUPABASE_SERVICE_ROLE_KEY eyJhbGci... (présent dans prod.env)
TZ Europe/Paris

Actions prévues

1. Build du package common

cd /tmp/hellocar && pnpm install && pnpm --filter @hellocar/common build

2. Dockerfile personnalisé (monorepo)

Création d'un Dockerfile adapté au monorepo :

FROM oven/bun:latest

WORKDIR /app

# Installer pnpm
RUN npm install -g pnpm

# Copier les fichiers workspace
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/common/package.json ./packages/common/
COPY apps/api/package.json ./apps/api/

# Installer les dépendances
RUN pnpm install --frozen-lockfile

# Copier le code source
COPY packages/common ./packages/common
COPY apps/api ./apps/api

# Build common puis API
RUN pnpm --filter @hellocar/common build
RUN pnpm --filter @hellocar/api build

WORKDIR /app/apps/api

EXPOSE 4510

CMD ["bun", "dist/index.js"]

3. Build de l'image Docker

docker build -t hellocar-api:prod .

4. Lancement du container

docker run -d \
  --name hellocar-api-prod \
  --restart unless-stopped \
  -p 4510:4510 \
  -e NODE_ENV=production \
  -e API_PORT=4510 \
  -e API_HOST=0.0.0.0 \
  -e SUPABASE_URL=... \
  -e SUPABASE_SERVICE_ROLE_KEY=... \
  -e TZ=Europe/Paris \
  hellocar-api:prod

Résultat attendu


Validation requise

Confirmes-tu le déploiement ? (oui/non)