feat: add Docker configuration and environment setup for backend and frontend
This commit is contained in:
4
k-tv-frontend/.dockerignore
Normal file
4
k-tv-frontend/.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.next
|
||||
node_modules
|
||||
.env*
|
||||
*.md
|
||||
46
k-tv-frontend/Dockerfile
Normal file
46
k-tv-frontend/Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
# ── Stage 1: Install dependencies ────────────────────────────────────────────
|
||||
FROM oven/bun:1 AS deps
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json bun.lock ./
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# ── Stage 2: Build ────────────────────────────────────────────────────────────
|
||||
FROM oven/bun:1 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# NEXT_PUBLIC_* vars are baked into the client bundle at build time.
|
||||
# Pass the public backend URL via --build-arg (see compose.yml).
|
||||
ARG NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
|
||||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN bun run build
|
||||
|
||||
# ── Stage 3: Production runner ────────────────────────────────────────────────
|
||||
FROM node:22-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs \
|
||||
&& adduser --system --uid 1001 nextjs
|
||||
|
||||
# standalone output + static assets
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3001
|
||||
ENV PORT=3001
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user