From 89b419ed5489a1ccc41fb875d39654f8df35115f Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Fri, 14 Nov 2025 08:22:48 +0100 Subject: [PATCH] Fix env variables --- .dockerignore | 5 ++++- apps/api/Dockerfile | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index b0bfd10..337be6f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,7 +17,10 @@ node_modules **/coverage **/.vitest -# Environment files (should be injected at runtime) +# Environment files +# Note: .env files in apps/api are included for container defaults +# Override at runtime with docker run -e or --env-file +!apps/api/.env* **/.env **/.env.* !**/.env.example diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index bd5019a..9625577 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -75,7 +75,9 @@ RUN pnpm install --frozen-lockfile --prod --filter @xtablo/api... # Set working directory to api app WORKDIR /app/apps/api -# Note: Environment variables should be injected at runtime via docker run -e or docker-compose +# Copy .env files from build stage if they exist +RUN --mount=type=bind,from=build,source=/app/apps/api,target=/mnt/api \ + cp /mnt/api/.env* . 2>/dev/null || true # Change ownership to nodejs user RUN chown -R nodejs:nodejs /app @@ -111,7 +113,9 @@ RUN pnpm install --frozen-lockfile --prod --filter @xtablo/api... # Set working directory to api app WORKDIR /app/apps/api -# Note: Environment variables should be injected at runtime via docker run -e or docker-compose +# Copy .env files from build stage if they exist +RUN --mount=type=bind,from=build,source=/app/apps/api,target=/mnt/api \ + cp /mnt/api/.env* . 2>/dev/null || true # Change ownership to nodejs user RUN chown -R nodejs:nodejs /app