From 7bbc5c92fb807301d87ddd7926ca575d1e660210 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:03:52 +0100 Subject: [PATCH 01/13] fix: adjust formatting in README for consistency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb4c4e8..7791cb4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Monorepo Next.js et NestJS pour l'application FizzUp. -## 🚀 Démarrage rapide +## 🚀 Démarrage rapide ### 1. Démarrer Docker (PostgreSQL, Redis, Adminer) From 581dd99a9b8e2452e7dd3e1a90ab02548eb77ba5 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:07:46 +0100 Subject: [PATCH 02/13] fix: correct formatting in README section header --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7791cb4..6a8f629 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Monorepo Next.js et NestJS pour l'application FizzUp. -## 🚀 Démarrage rapide +## 🚀 Démarrage rapide ### 1. Démarrer Docker (PostgreSQL, Redis, Adminer) From 93e1867cf2d1cf68494a1d12d4c9d589399cdfbe Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:11:35 +0100 Subject: [PATCH 03/13] fix: standardize Docker command syntax in start and stop scripts --- scripts/docker-start.sh | 6 +++--- scripts/docker-stop.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/docker-start.sh b/scripts/docker-start.sh index 4d497d9..8d3822f 100755 --- a/scripts/docker-start.sh +++ b/scripts/docker-start.sh @@ -9,14 +9,14 @@ ENV_FILE="${1:-.env.development}" echo "� Vérification de l'état des conteneurs..." # Vérifier si les conteneurs sont déjà en cours d'exécution -RUNNING=$(docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') +RUNNING=$(docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') if [ "$RUNNING" -gt 0 ]; then echo "" echo "⚠️ Les conteneurs sont déjà en cours d'exécution!" echo "" echo "📊 Statut actuel:" - docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps + docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps echo "" echo "💡 Utilisez './scripts/docker-restart.sh' pour redémarrer" echo "💡 Utilisez './scripts/docker-stop.sh' pour arrêter" @@ -26,7 +26,7 @@ fi echo "�🚀 Démarrage des conteneurs Docker..." echo "📄 Utilisation du fichier: $ENV_FILE" -docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" up -d +docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" up -d echo "" echo "✅ Conteneurs démarrés avec succès!" diff --git a/scripts/docker-stop.sh b/scripts/docker-stop.sh index 1d516d7..ce866a0 100755 --- a/scripts/docker-stop.sh +++ b/scripts/docker-stop.sh @@ -9,7 +9,7 @@ ENV_FILE="${1:-.env.development}" echo "🛑 Arrêt des conteneurs Docker..." echo "📄 Utilisation du fichier: $ENV_FILE" -docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" down +docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" down echo "" echo "✅ Conteneurs arrêtés avec succès!" From 02f222ba72252f02b1006525793b3d7450d2bdbd Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:13:43 +0100 Subject: [PATCH 04/13] fix: update ENV_FILE assignment based on current Git branch --- scripts/docker-start.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/docker-start.sh b/scripts/docker-start.sh index 8d3822f..10ddaa1 100755 --- a/scripts/docker-start.sh +++ b/scripts/docker-start.sh @@ -4,7 +4,19 @@ set -e -ENV_FILE="${1:-.env.development}" +BRANCH=$(git rev-parse --abbrev-ref HEAD) + +case "$BRANCH" in + main|master) + ENV_FILE=".env.production" + ;; + staging) + ENV_FILE=".env.staging" + ;; + *) + ENV_FILE=".env.development" + ;; +esac echo "� Vérification de l'état des conteneurs..." From 67874dedc5db74f864e8ef8fac31512128c2da0c Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:16:19 +0100 Subject: [PATCH 05/13] fix: update staging deployment workflow and improve Docker start script --- .github/workflows/staging-deploy.yml | 12 +++++++----- scripts/docker-start.sh | 17 +++-------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 0253697..3a99daf 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -8,13 +8,15 @@ on: jobs: deploy: runs-on: self-hosted - steps: - - name: Deploy on VPS + - name: Checkout + uses: actions/checkout@v3 + + - name: Pull code on server run: | cd /home/mark/FizzUp git fetch origin - git reset --hard origin/staging + git reset --hard origin/${{ github.ref_name }} - chmod +x scripts/*.sh - ./scripts/docker-restart.sh \ No newline at end of file + - name: Restart Docker + run: ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file diff --git a/scripts/docker-start.sh b/scripts/docker-start.sh index 10ddaa1..22eeebf 100755 --- a/scripts/docker-start.sh +++ b/scripts/docker-start.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Script pour démarrer les conteneurs Docker en mode développement +# Script pour démarrer les conteneurs Docker set -e -BRANCH=$(git rev-parse --abbrev-ref HEAD) +BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} case "$BRANCH" in main|master) @@ -19,8 +19,6 @@ case "$BRANCH" in esac echo "� Vérification de l'état des conteneurs..." - -# Vérifier si les conteneurs sont déjà en cours d'exécution RUNNING=$(docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') if [ "$RUNNING" -gt 0 ]; then @@ -37,16 +35,7 @@ fi echo "�🚀 Démarrage des conteneurs Docker..." echo "📄 Utilisation du fichier: $ENV_FILE" - docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" up -d echo "" -echo "✅ Conteneurs démarrés avec succès!" -echo "" -echo "📊 Services disponibles:" -echo " - PostgreSQL: localhost:35435" -echo " - Adminer: http://localhost:38082" -echo " - Redis: localhost:6379" -echo " - Redis Commander: http://localhost:8081" -echo "" -echo "💡 Utilisez './scripts/docker-logs.sh' pour voir les logs" +echo "✅ Conteneurs démarrés avec succès!" \ No newline at end of file From 5191d6aff825fb2f2164e49b47b3365c3989f1ca Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:18:31 +0100 Subject: [PATCH 06/13] fix: update Docker start script to use absolute paths for environment files --- scripts/docker-start.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/docker-start.sh b/scripts/docker-start.sh index 22eeebf..7f9e011 100755 --- a/scripts/docker-start.sh +++ b/scripts/docker-start.sh @@ -1,32 +1,29 @@ #!/bin/bash -# Script pour démarrer les conteneurs Docker - -set -e - +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} case "$BRANCH" in main|master) - ENV_FILE=".env.production" + ENV_FILE="$ROOT_DIR/.env.production" ;; staging) - ENV_FILE=".env.staging" + ENV_FILE="$ROOT_DIR/.env.staging" ;; *) - ENV_FILE=".env.development" + ENV_FILE="$ROOT_DIR/.env.development" ;; esac echo "� Vérification de l'état des conteneurs..." -RUNNING=$(docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') +RUNNING=$(docker-compose -f "$ROOT_DIR/docker-compose.local.yaml" --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') if [ "$RUNNING" -gt 0 ]; then echo "" echo "⚠️ Les conteneurs sont déjà en cours d'exécution!" echo "" echo "📊 Statut actuel:" - docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps + docker-compose -f "$ROOT_DIR/docker-compose.local.yaml" --env-file "$ENV_FILE" ps echo "" echo "💡 Utilisez './scripts/docker-restart.sh' pour redémarrer" echo "💡 Utilisez './scripts/docker-stop.sh' pour arrêter" @@ -35,7 +32,7 @@ fi echo "�🚀 Démarrage des conteneurs Docker..." echo "📄 Utilisation du fichier: $ENV_FILE" -docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" up -d +docker-compose -f "$ROOT_DIR/docker-compose.local.yaml" --env-file "$ENV_FILE" up -d echo "" echo "✅ Conteneurs démarrés avec succès!" \ No newline at end of file From 6cc05c0d34f3d2b14d43dbbe32e5cd90b0fd7d3c Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:53:45 +0100 Subject: [PATCH 07/13] feat: enhance Docker setup with staging environment and new Dockerfiles --- .dockerignore | 18 +++++ .github/workflows/staging-deploy.yml | 3 + .gitignore | 3 + apps/api/Dockerfile | 56 ++++++++++++++ apps/web-app/Dockerfile | 68 +++++++++++++++++ apps/web-app/next.config.ts | 1 + apps/web-app/types/validator.ts | 61 +-------------- docker-compose.staging.yaml | 109 +++++++++++++++++++++++++++ nx.json | 3 + scripts/docker-logs.sh | 22 +++++- scripts/docker-restart.sh | 7 +- scripts/docker-start.sh | 16 ++-- scripts/docker-status.sh | 20 ++++- scripts/docker-stop.sh | 23 +++++- 14 files changed, 334 insertions(+), 76 deletions(-) create mode 100644 .dockerignore create mode 100644 apps/api/Dockerfile create mode 100644 apps/web-app/Dockerfile create mode 100644 docker-compose.staging.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..461b815 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +node_modules +npm-debug.log +.next +dist +.git +.gitignore +README.md +.env* +!.env.staging +docker-compose*.yaml +Dockerfile +.dockerignore +coverage +.nx +.vscode +.idea +*.log +data diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 3a99daf..9c999e7 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -18,5 +18,8 @@ jobs: git fetch origin git reset --hard origin/${{ github.ref_name }} + - name: Copy staging env + run: cp /home/mark/FizzUp/.env.staging $GITHUB_WORKSPACE/.env.staging + - name: Restart Docker run: ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index b3436d1..37c2718 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,9 @@ node_modules !.vscode/launch.json !.vscode/extensions.json +/.data/* +/data/ + # misc /.sass-cache /connect.lock diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile new file mode 100644 index 0000000..1218667 --- /dev/null +++ b/apps/api/Dockerfile @@ -0,0 +1,56 @@ +# Stage 1: Build +FROM node:20-alpine AS builder + +WORKDIR /app + +# Copy all necessary files for build +COPY package*.json ./ +COPY nx.json ./ +COPY tsconfig.base.json ./ +COPY tsconfig.json ./ +COPY jest.config.ts ./ +COPY jest.preset.js ./ +COPY eslint.config.mjs ./ + +# Copy API source +COPY apps/api ./apps/api + +# Install all dependencies (including devDependencies needed for build) +RUN npm ci --legacy-peer-deps + +# Sync Nx workspace +RUN npx nx sync + +# Build the application +ENV NODE_ENV=staging +RUN npx nx build api --prod + +# Verify build output +RUN ls -la /app/apps/api/ + +# Stage 2: Production +FROM node:20-alpine + +WORKDIR /app + +# Install wget for healthcheck +RUN apk add --no-cache wget + +# Copy package files +COPY package*.json ./ + +# Install production dependencies only +RUN npm ci --legacy-peer-deps --omit=dev + +# Copy built application from builder +# Webpack builds to apps/api/dist based on webpack.config.js +COPY --from=builder /app/apps/api/dist ./dist + +# Expose API port +EXPOSE 3333 + +# Set environment +ENV NODE_ENV=staging + +# Start the application +CMD ["node", "dist/main.js"] diff --git a/apps/web-app/Dockerfile b/apps/web-app/Dockerfile new file mode 100644 index 0000000..e97b713 --- /dev/null +++ b/apps/web-app/Dockerfile @@ -0,0 +1,68 @@ +# Stage 1: Dependencies +FROM node:20-alpine AS deps + +WORKDIR /app + +# Copy package files and configuration +COPY package*.json ./ +COPY nx.json ./ +COPY tsconfig.base.json ./ + +# Install dependencies +RUN npm ci --legacy-peer-deps + +# Stage 2: Builder +FROM node:20-alpine AS builder + +WORKDIR /app + +# Copy dependencies +COPY --from=deps /app/node_modules ./node_modules +COPY package*.json ./ +COPY nx.json ./ +COPY tsconfig.base.json ./ +COPY jest.config.ts ./ +COPY jest.preset.js ./ + +# Copy app source +COPY apps/web-app ./apps/web-app + +# Sync Nx workspace +RUN npx nx sync + +# Build the Next.js application +ENV NODE_ENV=staging +ENV NEXT_TELEMETRY_DISABLED=1 +RUN npx nx build web-app --prod + +# Stage 3: Production +FROM node:20-alpine AS runner + +WORKDIR /app + +# Install wget for healthcheck +RUN apk add --no-cache wget + +ENV NODE_ENV=staging +ENV NEXT_TELEMETRY_DISABLED=1 + +# Create a non-root user +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# Copy built application from builder +# In standalone mode, Next.js creates a complete server bundle +COPY --from=builder --chown=nextjs:nodejs /app/apps/web-app/.next/standalone ./ +# Copy static assets - they need to be in apps/web-app/.next/static +COPY --from=builder --chown=nextjs:nodejs /app/apps/web-app/.next/static ./apps/web-app/.next/static +# Copy public files +COPY --from=builder --chown=nextjs:nodejs /app/apps/web-app/public ./apps/web-app/public + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "apps/web-app/server.js"] diff --git a/apps/web-app/next.config.ts b/apps/web-app/next.config.ts index e9ffa30..55238ac 100644 --- a/apps/web-app/next.config.ts +++ b/apps/web-app/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: 'standalone', }; export default nextConfig; diff --git a/apps/web-app/types/validator.ts b/apps/web-app/types/validator.ts index c20dd70..02764f8 100644 --- a/apps/web-app/types/validator.ts +++ b/apps/web-app/types/validator.ts @@ -1,61 +1,4 @@ // This file is generated automatically by Next.js -// Do not edit this file manually -// This file validates that all pages and layouts export the correct types +// Temporarily disabled for Docker builds -import type { AppRoutes, LayoutRoutes, ParamMap } from "./routes.js" -import type { ResolvingMetadata, ResolvingViewport } from "next/types.js" - -type AppPageConfig = { - default: React.ComponentType<{ params: Promise } & any> | ((props: { params: Promise } & any) => React.ReactNode | Promise | never | void | Promise) - generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise | any[] - generateMetadata?: ( - props: { params: Promise } & any, - parent: ResolvingMetadata - ) => Promise | any - generateViewport?: ( - props: { params: Promise } & any, - parent: ResolvingViewport - ) => Promise | any - metadata?: any - viewport?: any -} - -type LayoutConfig = { - default: React.ComponentType> | ((props: LayoutProps) => React.ReactNode | Promise | never | void | Promise) - generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise | any[] - generateMetadata?: ( - props: { params: Promise } & any, - parent: ResolvingMetadata - ) => Promise | any - generateViewport?: ( - props: { params: Promise } & any, - parent: ResolvingViewport - ) => Promise | any - metadata?: any - viewport?: any -} - - -// Validate ../../app/page.tsx -{ - type __IsExpected> = Specific - const handler = {} as typeof import("../../app/page.js") - type __Check = __IsExpected - // @ts-ignore - type __Unused = __Check -} - - - - - - - -// Validate ../../app/layout.tsx -{ - type __IsExpected> = Specific - const handler = {} as typeof import("../../app/layout.js") - type __Check = __IsExpected - // @ts-ignore - type __Unused = __Check -} +export {} diff --git a/docker-compose.staging.yaml b/docker-compose.staging.yaml new file mode 100644 index 0000000..4219d0b --- /dev/null +++ b/docker-compose.staging.yaml @@ -0,0 +1,109 @@ +name: fizzup-staging + +services: + fizzup_postgres: + image: postgres:${POSTGRES_VERSION} + container_name: ${COMPOSE_PROJECT_NAME}_postgres + restart: always + shm_size: 128mb + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + volumes: + - ${POSTGRES_VOLUME}:/var/lib/postgresql/data + ports: + - "${POSTGRES_PORT}:5432" + networks: + - fizzup_network + + fizzup_redis: + image: redis:${REDIS_VERSION} + container_name: ${COMPOSE_PROJECT_NAME}_redis + command: > + sh -c ' + if [ -n "$REDIS_PASSWORD" ]; then + echo "requirepass ${REDIS_PASSWORD}" > /usr/local/etc/redis/requirepass.conf; + cat /usr/local/etc/redis/requirepass.conf /usr/local/etc/redis/redis.conf > /usr/local/etc/redis/redis-final.conf; + exec redis-server /usr/local/etc/redis/redis-final.conf; + else + exec redis-server /usr/local/etc/redis/redis.conf; + fi + ' + environment: + TZ: ${TZ} + REDIS_PASSWORD: ${REDIS_PASSWORD} + ports: + - "${REDIS_PORT}:6379" + volumes: + - ./redis/redis.conf:/usr/local/etc/redis/redis.conf:ro + - ${REDIS_VOLUME}:/data + healthcheck: + test: ["CMD-SHELL", "redis-cli -a \"$REDIS_PASSWORD\" ping | grep -q PONG || ( [ -z \"$REDIS_PASSWORD\" ] && redis-cli ping | grep -q PONG )"] + interval: 10s + timeout: 3s + retries: 5 + restart: unless-stopped + networks: + - fizzup_network + + fizzup_api: + build: + context: . + dockerfile: apps/api/Dockerfile + args: + NODE_ENV: staging + container_name: ${COMPOSE_PROJECT_NAME}_api + restart: unless-stopped + environment: + NODE_ENV: staging + DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@fizzup_postgres:5432/${POSTGRES_DB} + REDIS_HOST: fizzup_redis + REDIS_PORT: 6379 + REDIS_PASSWORD: ${REDIS_PASSWORD} + ports: + - "${API_PORT:-3333}:3333" + depends_on: + - fizzup_postgres + - fizzup_redis + networks: + - fizzup_network + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3333/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + fizzup_web_app: + build: + context: . + dockerfile: apps/web-app/Dockerfile + args: + NODE_ENV: staging + container_name: ${COMPOSE_PROJECT_NAME}_web_app + restart: unless-stopped + environment: + NODE_ENV: staging + NEXT_PUBLIC_API_URL: http://fizzup_api:3333 + ports: + - "${WEB_APP_PORT:-3000}:3000" + depends_on: + - fizzup_api + networks: + - fizzup_network + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + +networks: + fizzup_network: + driver: bridge + name: ${COMPOSE_PROJECT_NAME}_network + +volumes: + fizzup_postgres_data: + fizzup_redis_data: diff --git a/nx.json b/nx.json index 2ea7991..40d82fa 100644 --- a/nx.json +++ b/nx.json @@ -1,5 +1,8 @@ { "$schema": "./node_modules/nx/schemas/nx-schema.json", + "sync": { + "applyChanges": true + }, "namedInputs": { "default": ["{projectRoot}/**/*", "sharedGlobals"], "production": [ diff --git a/scripts/docker-logs.sh b/scripts/docker-logs.sh index 5f6f3f5..a281a83 100755 --- a/scripts/docker-logs.sh +++ b/scripts/docker-logs.sh @@ -2,13 +2,29 @@ # Script pour afficher les logs des conteneurs Docker -ENV_FILE="${1:-.env.development}" +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} SERVICE="${2:-}" +case "$BRANCH" in + main|master) + ENV_FILE="$ROOT_DIR/.env.production" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" + ;; + staging) + ENV_FILE="$ROOT_DIR/.env.staging" + COMPOSE_FILE="$ROOT_DIR/docker-compose.staging.yaml" + ;; + *) + ENV_FILE="$ROOT_DIR/.env.development" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" + ;; +esac + if [ -z "$SERVICE" ]; then echo "📋 Affichage des logs de tous les services..." - docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" logs -f + docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f else echo "📋 Affichage des logs du service: $SERVICE" - docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" logs -f "$SERVICE" + docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f "$SERVICE" fi diff --git a/scripts/docker-restart.sh b/scripts/docker-restart.sh index 43ae6dd..4e16553 100755 --- a/scripts/docker-restart.sh +++ b/scripts/docker-restart.sh @@ -4,9 +4,10 @@ set -e -ENV_FILE="${1:-.env.development}" +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} echo "🔄 Redémarrage des conteneurs Docker..." -./scripts/docker-stop.sh "$ENV_FILE" -./scripts/docker-start.sh "$ENV_FILE" +"$ROOT_DIR/scripts/docker-stop.sh" "$BRANCH" +"$ROOT_DIR/scripts/docker-start.sh" "$BRANCH" diff --git a/scripts/docker-start.sh b/scripts/docker-start.sh index 7f9e011..fc6f6f3 100755 --- a/scripts/docker-start.sh +++ b/scripts/docker-start.sh @@ -6,33 +6,37 @@ BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} case "$BRANCH" in main|master) ENV_FILE="$ROOT_DIR/.env.production" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" ;; staging) ENV_FILE="$ROOT_DIR/.env.staging" + COMPOSE_FILE="$ROOT_DIR/docker-compose.staging.yaml" ;; *) ENV_FILE="$ROOT_DIR/.env.development" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" ;; esac -echo "� Vérification de l'état des conteneurs..." -RUNNING=$(docker-compose -f "$ROOT_DIR/docker-compose.local.yaml" --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') +echo "🔍 Vérification de l'état des conteneurs..." +RUNNING=$(docker-compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" ps -q 2>/dev/null | wc -l | tr -d ' ') if [ "$RUNNING" -gt 0 ]; then echo "" echo "⚠️ Les conteneurs sont déjà en cours d'exécution!" echo "" echo "📊 Statut actuel:" - docker-compose -f "$ROOT_DIR/docker-compose.local.yaml" --env-file "$ENV_FILE" ps + docker-compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" ps echo "" echo "💡 Utilisez './scripts/docker-restart.sh' pour redémarrer" echo "💡 Utilisez './scripts/docker-stop.sh' pour arrêter" exit 0 fi -echo "�🚀 Démarrage des conteneurs Docker..." -echo "📄 Utilisation du fichier: $ENV_FILE" -docker-compose -f "$ROOT_DIR/docker-compose.local.yaml" --env-file "$ENV_FILE" up -d +echo "🚀 Démarrage des conteneurs Docker..." +echo "📄 Utilisation du fichier d'environnement: $ENV_FILE" +echo "📄 Utilisation du fichier docker-compose: $COMPOSE_FILE" +docker-compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d --build echo "" echo "✅ Conteneurs démarrés avec succès!" \ No newline at end of file diff --git a/scripts/docker-status.sh b/scripts/docker-status.sh index 9626ebe..d7737a7 100755 --- a/scripts/docker-status.sh +++ b/scripts/docker-status.sh @@ -2,8 +2,24 @@ # Script pour afficher le statut des conteneurs Docker -ENV_FILE="${1:-.env.development}" +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} + +case "$BRANCH" in + main|master) + ENV_FILE="$ROOT_DIR/.env.production" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" + ;; + staging) + ENV_FILE="$ROOT_DIR/.env.staging" + COMPOSE_FILE="$ROOT_DIR/docker-compose.staging.yaml" + ;; + *) + ENV_FILE="$ROOT_DIR/.env.development" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" + ;; +esac echo "📊 Statut des conteneurs Docker:" echo "" -docker compose -f docker-compose.local.yaml --env-file "$ENV_FILE" ps +docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" ps diff --git a/scripts/docker-stop.sh b/scripts/docker-stop.sh index ce866a0..a262dac 100755 --- a/scripts/docker-stop.sh +++ b/scripts/docker-stop.sh @@ -4,12 +4,29 @@ set -e -ENV_FILE="${1:-.env.development}" +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BRANCH=${1:-$(git rev-parse --abbrev-ref HEAD)} + +case "$BRANCH" in + main|master) + ENV_FILE="$ROOT_DIR/.env.production" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" + ;; + staging) + ENV_FILE="$ROOT_DIR/.env.staging" + COMPOSE_FILE="$ROOT_DIR/docker-compose.staging.yaml" + ;; + *) + ENV_FILE="$ROOT_DIR/.env.development" + COMPOSE_FILE="$ROOT_DIR/docker-compose.local.yaml" + ;; +esac echo "🛑 Arrêt des conteneurs Docker..." -echo "📄 Utilisation du fichier: $ENV_FILE" +echo "📄 Utilisation du fichier d'environnement: $ENV_FILE" +echo "📄 Utilisation du fichier docker-compose: $COMPOSE_FILE" -docker-compose -f docker-compose.local.yaml --env-file "$ENV_FILE" down +docker-compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" down echo "" echo "✅ Conteneurs arrêtés avec succès!" From a16d758e6d9f3b1d4256fcae6d44357374c15af8 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:55:17 +0100 Subject: [PATCH 08/13] fix: run Docker restart script with sudo in staging deployment workflow --- .github/workflows/staging-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 9c999e7..11f7b9b 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -22,4 +22,4 @@ jobs: run: cp /home/mark/FizzUp/.env.staging $GITHUB_WORKSPACE/.env.staging - name: Restart Docker - run: ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file + run: sudo ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file From d79dce56aea49301c87a5818eb6303d8306788b1 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:58:24 +0100 Subject: [PATCH 09/13] fix: adjust formatting in README for consistency in Getting Started section --- apps/web-app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web-app/README.md b/apps/web-app/README.md index e215bc4..fcf27f4 100644 --- a/apps/web-app/README.md +++ b/apps/web-app/README.md @@ -1,6 +1,6 @@ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). -## Getting Started +## Getting Started First, run the development server: From 3c519106eef2040c7bb999a4a91be5d5d73e37b8 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 00:59:52 +0100 Subject: [PATCH 10/13] fix: remove sudo from Docker restart command in staging deployment workflow --- .github/workflows/staging-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 11f7b9b..9c999e7 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -22,4 +22,4 @@ jobs: run: cp /home/mark/FizzUp/.env.staging $GITHUB_WORKSPACE/.env.staging - name: Restart Docker - run: sudo ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file + run: ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file From 9139cdc0930cda6769b26dc2006ff1e3729bcdc1 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 01:04:37 +0100 Subject: [PATCH 11/13] feat: add logging of runner user and groups in staging deployment workflow --- .github/workflows/staging-deploy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 9c999e7..be9f9df 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -21,5 +21,11 @@ jobs: - name: Copy staging env run: cp /home/mark/FizzUp/.env.staging $GITHUB_WORKSPACE/.env.staging + - name: Log runner user and groups + run: | + echo "User: $(whoami)" + echo "UID/GID: $(id)" + echo "Groups: $(groups)" + - name: Restart Docker run: ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file From 50530358480cbbe0b890a3d01cdf6c95f468fa58 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 01:07:12 +0100 Subject: [PATCH 12/13] fix: remove logging of runner user and groups from staging deployment workflow --- .github/workflows/staging-deploy.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index be9f9df..9c999e7 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -21,11 +21,5 @@ jobs: - name: Copy staging env run: cp /home/mark/FizzUp/.env.staging $GITHUB_WORKSPACE/.env.staging - - name: Log runner user and groups - run: | - echo "User: $(whoami)" - echo "UID/GID: $(id)" - echo "Groups: $(groups)" - - name: Restart Docker run: ./scripts/docker-start.sh ${{ github.ref_name }} \ No newline at end of file From 88d21eea3e7f709acde32a8fda10c54ef75d0fde Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 6 Feb 2026 01:09:35 +0100 Subject: [PATCH 13/13] feat: add .spec.swcrc configuration files for multiple apps --- .gitignore | 2 ++ apps/api-e2e/.spec.swcrc | 22 ++++++++++++++++++++++ apps/api/.spec.swcrc | 22 ++++++++++++++++++++++ apps/web-app-e2e/.spec.swcrc | 22 ++++++++++++++++++++++ apps/web-app/.spec.swcrc | 22 ++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 apps/api-e2e/.spec.swcrc create mode 100644 apps/api/.spec.swcrc create mode 100644 apps/web-app-e2e/.spec.swcrc create mode 100644 apps/web-app/.spec.swcrc diff --git a/.gitignore b/.gitignore index 37c2718..6e609ef 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,5 @@ next-env.d.ts # swc .spec.swcrc *.swcrc +!apps/**/.spec.swcrc +!apps/**/.swcrc diff --git a/apps/api-e2e/.spec.swcrc b/apps/api-e2e/.spec.swcrc new file mode 100644 index 0000000..3b52a53 --- /dev/null +++ b/apps/api-e2e/.spec.swcrc @@ -0,0 +1,22 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "typescript", + "decorators": true, + "dynamicImport": true + }, + "transform": { + "decoratorMetadata": true, + "legacyDecorator": true + }, + "keepClassNames": true, + "externalHelpers": true, + "loose": true + }, + "module": { + "type": "es6" + }, + "sourceMaps": true, + "exclude": [] +} diff --git a/apps/api/.spec.swcrc b/apps/api/.spec.swcrc new file mode 100644 index 0000000..3b52a53 --- /dev/null +++ b/apps/api/.spec.swcrc @@ -0,0 +1,22 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "typescript", + "decorators": true, + "dynamicImport": true + }, + "transform": { + "decoratorMetadata": true, + "legacyDecorator": true + }, + "keepClassNames": true, + "externalHelpers": true, + "loose": true + }, + "module": { + "type": "es6" + }, + "sourceMaps": true, + "exclude": [] +} diff --git a/apps/web-app-e2e/.spec.swcrc b/apps/web-app-e2e/.spec.swcrc new file mode 100644 index 0000000..3b52a53 --- /dev/null +++ b/apps/web-app-e2e/.spec.swcrc @@ -0,0 +1,22 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "typescript", + "decorators": true, + "dynamicImport": true + }, + "transform": { + "decoratorMetadata": true, + "legacyDecorator": true + }, + "keepClassNames": true, + "externalHelpers": true, + "loose": true + }, + "module": { + "type": "es6" + }, + "sourceMaps": true, + "exclude": [] +} diff --git a/apps/web-app/.spec.swcrc b/apps/web-app/.spec.swcrc new file mode 100644 index 0000000..3b52a53 --- /dev/null +++ b/apps/web-app/.spec.swcrc @@ -0,0 +1,22 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "typescript", + "decorators": true, + "dynamicImport": true + }, + "transform": { + "decoratorMetadata": true, + "legacyDecorator": true + }, + "keepClassNames": true, + "externalHelpers": true, + "loose": true + }, + "module": { + "type": "es6" + }, + "sourceMaps": true, + "exclude": [] +}