Changed Dockerfile
This commit is contained in:
@@ -6,6 +6,7 @@ WORKDIR /app
|
||||
# Workspace manifests first for better layer caching.
|
||||
COPY package.json bun.lock ./
|
||||
COPY apps/backend/package.json apps/backend/package.json
|
||||
COPY apps/frontend/package.json apps/frontend/package.json
|
||||
COPY packages/api-contract/package.json packages/api-contract/package.json
|
||||
|
||||
RUN bun install --frozen-lockfile
|
||||
@@ -14,12 +15,23 @@ FROM deps AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY apps/backend apps/backend
|
||||
COPY apps/frontend apps/frontend
|
||||
COPY packages/api-contract packages/api-contract
|
||||
|
||||
# Build-time variables for Vite.
|
||||
ARG VITE_API_BASE_URL
|
||||
ARG VITE_SUPABASE_URL
|
||||
ARG VITE_SUPABASE_ANON_KEY
|
||||
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
|
||||
ENV VITE_SUPABASE_URL=${VITE_SUPABASE_URL}
|
||||
ENV VITE_SUPABASE_ANON_KEY=${VITE_SUPABASE_ANON_KEY}
|
||||
|
||||
# Prisma 7 config resolves DATABASE_URL at generate time.
|
||||
ARG DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
|
||||
ENV DATABASE_URL=${DATABASE_URL}
|
||||
|
||||
RUN bun --filter frontend build
|
||||
RUN mkdir -p apps/backend/public && cp -R apps/frontend/dist/. apps/backend/public/
|
||||
RUN bun --cwd apps/backend run prisma:generate
|
||||
|
||||
FROM oven/bun:1.3-slim AS runner
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { registerApiRoutes } from '@repo/api-contract'
|
||||
import type { Hono } from 'hono'
|
||||
import { serveStatic } from 'hono/bun'
|
||||
import path from 'node:path'
|
||||
import { complexRoutes } from '@/modules/complex/complex.routes'
|
||||
import { courtRoutes } from '@/modules/court/court.routes'
|
||||
import { onboardingRoutes } from '@/modules/onboarding/onboarding.routes'
|
||||
@@ -20,4 +22,23 @@ export function registerRoutes(app: Hono<AppEnv>) {
|
||||
})
|
||||
|
||||
app.route('/api/public-bookings', publicBookingRoutes)
|
||||
|
||||
app.use('*', serveStatic({ root: './public' }))
|
||||
app.get('*', async (c) => {
|
||||
if (c.req.path === '/api' || c.req.path.startsWith('/api/')) {
|
||||
return c.notFound()
|
||||
}
|
||||
|
||||
// Keep real asset URLs as 404s if the file does not exist.
|
||||
if (path.extname(c.req.path)) {
|
||||
return c.notFound()
|
||||
}
|
||||
|
||||
const indexFile = Bun.file('./public/index.html')
|
||||
if (!(await indexFile.exists())) {
|
||||
return c.notFound()
|
||||
}
|
||||
|
||||
return c.html(await indexFile.text())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM oven/bun:1.3 AS deps
|
||||
WORKDIR /app
|
||||
|
||||
# Workspace manifests first for better layer caching.
|
||||
COPY package.json bun.lock ./
|
||||
COPY apps/frontend/package.json apps/frontend/package.json
|
||||
COPY packages/api-contract/package.json packages/api-contract/package.json
|
||||
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
FROM deps AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY apps/frontend apps/frontend
|
||||
COPY packages/api-contract packages/api-contract
|
||||
|
||||
# Build-time variables for Vite.
|
||||
ARG VITE_API_BASE_URL=http://localhost:3000
|
||||
ARG VITE_SUPABASE_URL=
|
||||
ARG VITE_SUPABASE_ANON_KEY=
|
||||
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
|
||||
ENV VITE_SUPABASE_URL=${VITE_SUPABASE_URL}
|
||||
ENV VITE_SUPABASE_ANON_KEY=${VITE_SUPABASE_ANON_KEY}
|
||||
|
||||
RUN bun --filter frontend build
|
||||
|
||||
FROM nginx:1.27-alpine AS runner
|
||||
WORKDIR /usr/share/nginx/html
|
||||
|
||||
COPY apps/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/apps/frontend/dist ./
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -27,7 +27,9 @@ import type {
|
||||
UserProfileResponse,
|
||||
} from '@repo/api-contract'
|
||||
|
||||
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3000'
|
||||
const apiBaseUrl =
|
||||
import.meta.env.VITE_API_BASE_URL?.trim() ||
|
||||
(import.meta.env.DEV ? 'http://localhost:3000' : window.location.origin)
|
||||
let accessToken: string | null = null
|
||||
|
||||
export class ApiClientError extends Error {
|
||||
|
||||
Reference in New Issue
Block a user