feat: Add initial Docker setup and development environment documentation.

This commit is contained in:
supalerk-ar66 2026-02-05 11:01:17 +07:00
parent 42b7399868
commit ca65dbff4c
5 changed files with 124 additions and 28 deletions

View file

@ -0,0 +1,11 @@
node_modules
.nuxt
.output
.env
dist
npm-debug.log
.vscode
.git
.gitignore
Dockerfile
.dockerignore

View file

@ -0,0 +1,10 @@
# API Configuration (Nuxt 3 uses NUXT_PUBLIC_ prefix for client-side access)
NUXT_PUBLIC_API_BASE=http://localhost:4000/api
# S3 / MinIO Configuration (If used in frontend later)
# NUXT_PUBLIC_S3_ENDPOINT=http://192.168.1.100:9000
# NUXT_PUBLIC_S3_BUCKET=courses
# App Configuration
PORT=3000
NODE_ENV=development

View file

@ -0,0 +1,38 @@
# --- Build Stage ---
FROM node:20-alpine AS build-stage
# กำหนดโฟลเดอร์ทำงานใน Container
WORKDIR /app
# คัดลอกไฟล์จัดการ dependencies
COPY package*.json ./
# ติดตั้ง dependencies (ใช้ npm ci เพื่อความแม่นยำของเวอร์ชัน)
RUN npm ci
# คัดลอกไฟล์ทั้งหมดในโปรเจกต์
COPY . .
# สั่ง Build โปรเจกต์ Nuxt 3 (จะได้โฟลเดอร์ .output)
RUN npm run build
# --- Production Stage ---
FROM node:20-alpine AS production-stage
# กำหนดโฟลเดอร์ทำงาน
WORKDIR /app
# คัดลอกเฉพาะโฟลเดอร์ .output ที่ได้จากการ build (ประหยัดพื้นที่ Container)
COPY --from=build-stage /app/.output ./.output
# กำหนดตัวแปรสภาพแวดล้อม (Environment Variables) สำหรับ Production
ENV PORT=3000
ENV NODE_ENV=production
# แจ้ง Port ที่ Container จะใช้งาน
EXPOSE 3000
# คำสั่งสำหรับเริ่มการทำงานของ Nuxt 3 Server
# ใช้ node รันไฟล์ entry point ที่สร้างจากการ build
CMD ["node", ".output/server/index.mjs"]

View file

@ -0,0 +1,19 @@
services:
learner-ui:
build: .
container_name: elearning-learner-ui
restart: unless-stopped
ports:
- "3000:3000"
environment:
# URL ของ Backend API (Nuxt 3 จะใช้ NUXT_PUBLIC_ นำหน้า)
- NUXT_PUBLIC_API_BASE=${NUXT_PUBLIC_API_BASE:-http://localhost:4000/api}
# กรณีต้องการระบุ URL อื่นๆ เพิ่มเติม เช่น S3 (ถ้ามีการใช้ในอนาคต)
- NUXT_PUBLIC_S3_ENDPOINT=${NUXT_PUBLIC_S3_ENDPOINT:-http://192.168.1.100:9000}
networks:
- elearning-network
networks:
elearning-network:
external: true