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