Skip to content

Add Dockerfile for client + fixes - #24

Open
andrasbacsai wants to merge 2 commits into
catalinpit:mainfrom
andrasbacsai:main
Open

Add Dockerfile for client + fixes#24
andrasbacsai wants to merge 2 commits into
catalinpit:mainfrom
andrasbacsai:main

Conversation

@andrasbacsai

@andrasbacsai andrasbacsai commented Dec 1, 2025

Copy link
Copy Markdown
  • Prisma generated stuffs does not needs to be on git (commit)
  • Added Dockerfile + .env + nginx configuration to serve the client (commit)

You can try it out with bun run docker:build:client command.

Note: if you serve the client with a reverse proxy, probably gzip is not required in nginx.conf, but on the reverse proxy.

Summary by CodeRabbit

  • Chores
    • Implemented Docker containerization for the client application with multi-stage build configuration for optimized deployments.
    • Configured web server with security headers, gzip compression, and optimized caching strategies for static assets.
    • Introduced environment configuration files for managing build-time variables.
    • Added npm script to streamline Docker image builds.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 1, 2025

Copy link
Copy Markdown

Walkthrough

This pull request introduces Docker containerization infrastructure for the client application, including a multi-stage Dockerfile build process, nginx web server configuration, environment configuration examples, and a corresponding build script in the root package.json.

Changes

Cohort / File(s) Summary
Docker & web server infrastructure
apps/client/Dockerfile, apps/client/nginx.conf
Introduces multi-stage Dockerfile for building and serving the client app via nginx:alpine with gzip compression, security headers, static asset caching, and SPA fallback routing. Adds nginx.conf with health check endpoint and long-term caching for assets.
Configuration & build tooling
apps/client/.env.example, package.json
Adds .env.example documenting Vite build-time variables (VITE_API_URL, VITE_APP_URL, VITE_BETTER_AUTH_URL) for local development and Docker builds. Adds docker:build:client npm script to build the client Docker image.
VCS configuration
.gitignore
Adds prisma/generated/ to ignored paths with explanatory comment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • The Dockerfile follows standard multi-stage build patterns; verify base image versions and build arguments align with development workflow
  • The nginx.conf applies common SPA configuration patterns; confirm security headers and caching directives match project requirements
  • Cross-file coordination: ensure environment variable names in .env.example match those referenced in Dockerfile ARG/ENV declarations

Poem

🐰 A Docker image takes shape with care,
Nginx serves the client in the air,
Environment variables set just right,
Build scripts glow in morning light,
The platform grows with every delight! 🚀

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Dockerfile for client + fixes' directly corresponds to the main changes: adding a Dockerfile, nginx configuration, and environment file for the client application, plus related fixes like updating .gitignore and adding npm scripts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
package.json (1)

9-11: Optionally wire common VITE_ build args into the script*

The script correctly builds from the monorepo root against apps/client/Dockerfile. For smoother DX, you might consider passing the common VITE_API_URL, VITE_APP_URL, and VITE_BETTER_AUTH_URL values here via --build-arg so bun run docker:build:client produces a fully configured image without extra flags, mirroring the values in .env.example.

apps/client/nginx.conf (1)

29-34: Make /health response type explicitly text/plain

If you want /health to reliably return text/plain (rather than nginx’s default MIME type), consider using default_type instead of add_header Content-Type:

 location /health {
-    access_log off;
-    return 200 "healthy\n";
-    add_header Content-Type text/plain;
+    access_log off;
+    default_type text/plain;
+    return 200 "healthy\n";
 }

This makes the intent explicit and avoids relying on header overrides for the content type.

apps/client/Dockerfile (1)

7-11: Consider pinning the Bun base image/tag and hardening package install

Using oven/bun:latest plus apt-get ties you to both the upstream image’s distro choice and whatever “latest” becomes over time. If the base image ever switches away from a Debian-like distro, apt-get will break; and unpinned “latest” can yield non-reproducible builds.

You may want to:

  • Pin to a specific Bun tag that you test against (e.g., a versioned Debian-based image).
  • Add --no-install-recommends to the apt-get install to keep the base layer small.

For example:

-FROM oven/bun:latest AS base
+FROM oven/bun:<known-good-tag> AS base
 ...
-RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
+RUN apt-get update -y \
+    && apt-get install -y --no-install-recommends openssl \
+    && rm -rf /var/lib/apt/lists/*
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef0ffcd and f76cebc.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • apps/client/.env.example (1 hunks)
  • apps/client/Dockerfile (1 hunks)
  • apps/client/nginx.conf (1 hunks)
  • package.json (1 hunks)
🔇 Additional comments (2)
.gitignore (1)

31-32: Fix typo in comment.

Line 31 has a minor grammatical error: "dont" should be "don't".

-# We dont need generated Prisma files
+# We don't need generated Prisma files
 prisma/generated/

Otherwise, the addition correctly excludes Prisma-generated artifacts from version control, which aligns with the PR objective.

apps/client/.env.example (1)

1-8: Env example is clear and consistent

Example values and comments are consistent with the Vite/Docker build-time model and provide sensible local defaults; no changes needed here.

Comment thread apps/client/Dockerfile
Comment thread apps/client/Dockerfile
Comment on lines +29 to +37
# Set build-time environment variables (can be overridden during build)
ARG VITE_API_URL
ARG VITE_APP_URL
ARG VITE_BETTER_AUTH_URL

ENV VITE_API_URL=${VITE_API_URL}
ENV VITE_APP_URL=${VITE_APP_URL}
ENV VITE_BETTER_AUTH_URL=${VITE_BETTER_AUTH_URL}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Provide defaults for VITE_ build ARGs to avoid empty config in builds*

Right now the ARG values default to empty, so running docker build ... (or bun run docker:build:client) without explicit --build-arg flags will bake empty VITE_API_URL, VITE_APP_URL, and VITE_BETTER_AUTH_URL into the client build.

You can make the image usable out of the box by giving these ARGs sane defaults that match .env.example, while still allowing overrides:

-# Set build-time environment variables (can be overridden during build)
-ARG VITE_API_URL
-ARG VITE_APP_URL
-ARG VITE_BETTER_AUTH_URL
-
-ENV VITE_API_URL=${VITE_API_URL}
-ENV VITE_APP_URL=${VITE_APP_URL}
-ENV VITE_BETTER_AUTH_URL=${VITE_BETTER_AUTH_URL}
+# Set build-time environment variables (can be overridden during build)
+ARG VITE_API_URL=http://localhost:9999
+ARG VITE_APP_URL=http://localhost:80
+ARG VITE_BETTER_AUTH_URL=http://localhost:9999/api/auth
+
+ENV VITE_API_URL=${VITE_API_URL}
+ENV VITE_APP_URL=${VITE_APP_URL}
+ENV VITE_BETTER_AUTH_URL=${VITE_BETTER_AUTH_URL}

This matches the documented defaults and reduces surprises when building locally.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Set build-time environment variables (can be overridden during build)
ARG VITE_API_URL
ARG VITE_APP_URL
ARG VITE_BETTER_AUTH_URL
ENV VITE_API_URL=${VITE_API_URL}
ENV VITE_APP_URL=${VITE_APP_URL}
ENV VITE_BETTER_AUTH_URL=${VITE_BETTER_AUTH_URL}
# Set build-time environment variables (can be overridden during build)
ARG VITE_API_URL=http://localhost:9999
ARG VITE_APP_URL=http://localhost:80
ARG VITE_BETTER_AUTH_URL=http://localhost:9999/api/auth
ENV VITE_API_URL=${VITE_API_URL}
ENV VITE_APP_URL=${VITE_APP_URL}
ENV VITE_BETTER_AUTH_URL=${VITE_BETTER_AUTH_URL}
🤖 Prompt for AI Agents
In apps/client/Dockerfile around lines 29–37, the ARGs VITE_API_URL,
VITE_APP_URL and VITE_BETTER_AUTH_URL are declared without defaults so builds
without --build-arg produce empty baked-in values; update each ARG declaration
to include the sensible default values from .env.example (for example the
documented local/dev defaults) so the ENV lines continue to pick up those ARGs
while still allowing overrides via --build-arg.

@catalinpit

Copy link
Copy Markdown
Owner

Thanks for the PR! Will have a look asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants