aboutsummaryrefslogtreecommitdiffhomepage
path: root/docker
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-12-06 19:06:33 +0900
committernsfisis <nsfisis@gmail.com>2025-12-06 19:24:07 +0900
commit39deb471d976d863d2ec803f908025a2366f1486 (patch)
tree5aee9cc44b21d92a0d4a7c9f33fe487acc732d92 /docker
parentc65609278df8a95ad82acc852e224607069859b4 (diff)
downloadkioku-39deb471d976d863d2ec803f908025a2366f1486.tar.gz
kioku-39deb471d976d863d2ec803f908025a2366f1486.tar.zst
kioku-39deb471d976d863d2ec803f908025a2366f1486.zip
build(server): add Dockerfiles
Add build pipeline with esbuild for production bundling. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'docker')
-rw-r--r--docker/client/Dockerfile35
-rw-r--r--docker/server/Dockerfile51
2 files changed, 86 insertions, 0 deletions
diff --git a/docker/client/Dockerfile b/docker/client/Dockerfile
new file mode 100644
index 0000000..4647124
--- /dev/null
+++ b/docker/client/Dockerfile
@@ -0,0 +1,35 @@
+# Build stage
+FROM node:22-slim AS builder
+
+WORKDIR /app
+
+# Enable corepack for pnpm
+RUN corepack enable && corepack prepare pnpm@10.23.0 --activate
+
+# Copy package files
+COPY package.json pnpm-lock.yaml ./
+
+# Install all dependencies (including devDependencies for build)
+RUN pnpm install --frozen-lockfile
+
+# Copy source files needed for client build
+COPY tsconfig.json vite.config.ts index.html ./
+COPY src/client ./src/client
+
+# Build the client
+RUN pnpm build:client
+
+# Production stage - nginx for static file serving
+FROM nginx:stable AS production
+
+# Copy built client from builder stage
+COPY --from=builder /app/dist/client /usr/share/nginx/html
+
+# Copy nginx configuration
+COPY nginx.conf /etc/nginx/conf.d/default.conf
+
+# Expose the port
+EXPOSE 80
+
+# Start nginx
+CMD ["nginx", "-g", "daemon off;"]
diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile
new file mode 100644
index 0000000..ffb2c29
--- /dev/null
+++ b/docker/server/Dockerfile
@@ -0,0 +1,51 @@
+# Build stage
+FROM node:22-slim AS builder
+
+WORKDIR /app
+
+# Enable corepack for pnpm
+RUN corepack enable && corepack prepare pnpm@10.23.0 --activate
+
+# Copy package files
+COPY package.json pnpm-lock.yaml ./
+
+# Install all dependencies (including devDependencies for build)
+RUN pnpm install --frozen-lockfile
+
+# Copy source files
+COPY tsconfig.json esbuild.mjs ./
+COPY src/server ./src/server
+
+# Build the server
+RUN pnpm build:server
+
+# Production stage
+FROM node:22-slim AS production
+
+WORKDIR /app
+
+# Enable corepack for pnpm
+RUN corepack enable && corepack prepare pnpm@10.23.0 --activate
+
+# Copy package files
+COPY package.json pnpm-lock.yaml ./
+
+# Install production dependencies only
+RUN pnpm install --frozen-lockfile --prod
+
+# Copy built server from builder stage
+COPY --from=builder /app/dist/server ./dist/server
+
+# Copy drizzle migrations for database setup
+COPY drizzle ./drizzle
+COPY drizzle.config.ts ./
+
+# Expose the port
+EXPOSE 3000
+
+# Set environment variables
+ENV NODE_ENV=production
+ENV PORT=3000
+
+# Run migrations and start the server
+CMD ["sh", "-c", "pnpm db:migrate && node dist/server/index.js"]