-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add Dockerfile for client + fixes #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,6 @@ lerna-debug.log* | |
| # misc | ||
| .DS_Store | ||
| notes.mdx | ||
|
|
||
| # We dont need generated Prisma files | ||
| prisma/generated/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # API Configuration | ||
| # NOTE: These are build-time variables for Vite | ||
| # They are baked into the static files during build | ||
| # To change them, rebuild the Docker image with --build-arg | ||
|
|
||
| VITE_API_URL=http://localhost:9999 | ||
| VITE_APP_URL=http://localhost:80 | ||
| VITE_BETTER_AUTH_URL=http://localhost:9999/api/auth |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||||||||||||||||||||||||||||||
| # TanStack Start (SSR) Client Dockerfile | ||||||||||||||||||||||||||||||||||||
| # Multi-stage build for optimized production image | ||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||
| # NOTE: This Dockerfile expects to be run from the monorepo root | ||||||||||||||||||||||||||||||||||||
| # Build command: docker build -f apps/client/Dockerfile . | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| FROM oven/bun:latest AS base | ||||||||||||||||||||||||||||||||||||
| WORKDIR /usr/src/app | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Install OpenSSL (required for some dependencies) | ||||||||||||||||||||||||||||||||||||
| RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||||||||||||||||||
| # Build Stage | ||||||||||||||||||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||||||||||||||||||
| FROM base AS builder | ||||||||||||||||||||||||||||||||||||
| WORKDIR /usr/src/app | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Copy root workspace files | ||||||||||||||||||||||||||||||||||||
| COPY package.json bun.lock* ./ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Copy the entire monorepo structure (client needs server types) | ||||||||||||||||||||||||||||||||||||
| COPY apps/server ./apps/server/ | ||||||||||||||||||||||||||||||||||||
| COPY apps/client ./apps/client/ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Install all dependencies from monorepo root | ||||||||||||||||||||||||||||||||||||
| RUN bun install --frozen-lockfile | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # 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} | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provide defaults for VITE_ build ARGs to avoid empty config in builds* Right now the You can make the image usable out of the box by giving these -# 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| # Build the client application | ||||||||||||||||||||||||||||||||||||
| WORKDIR /usr/src/app/apps/client | ||||||||||||||||||||||||||||||||||||
| RUN bun run build | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||||||||||||||||||
| # Production Stage - Nginx | ||||||||||||||||||||||||||||||||||||
| # ============================================ | ||||||||||||||||||||||||||||||||||||
| FROM nginx:alpine AS runner | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Copy built static files to nginx html directory | ||||||||||||||||||||||||||||||||||||
| COPY --from=builder /usr/src/app/apps/client/dist/client /usr/share/nginx/html | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Copy custom nginx configuration | ||||||||||||||||||||||||||||||||||||
| COPY apps/client/nginx.conf /etc/nginx/conf.d/default.conf | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Expose port 80 | ||||||||||||||||||||||||||||||||||||
| EXPOSE 80 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Start nginx | ||||||||||||||||||||||||||||||||||||
| CMD ["nginx", "-g", "daemon off;"] | ||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| server { | ||
| listen 80; | ||
| server_name localhost; | ||
| root /usr/share/nginx/html; | ||
| index index.html; | ||
|
|
||
| # Enable gzip compression | ||
| gzip on; | ||
| gzip_vary on; | ||
| gzip_min_length 1024; | ||
| gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json; | ||
|
|
||
| # Security headers | ||
| add_header X-Frame-Options "SAMEORIGIN" always; | ||
| add_header X-Content-Type-Options "nosniff" always; | ||
| add_header X-XSS-Protection "1; mode=block" always; | ||
|
|
||
| # Cache static assets | ||
| location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { | ||
| expires 1y; | ||
| add_header Cache-Control "public, immutable"; | ||
| } | ||
|
|
||
| # SPA fallback - send all requests to index.html | ||
| location / { | ||
| try_files $uri $uri/ /index.html; | ||
| } | ||
|
|
||
| # Health check endpoint | ||
| location /health { | ||
| access_log off; | ||
| return 200 "healthy\n"; | ||
| add_header Content-Type text/plain; | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.