migrate
This commit is contained in:
37
Dockerfile
37
Dockerfile
@@ -41,43 +41,6 @@ COPY . .
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# Migration / Seed image
|
|
||||||
#
|
|
||||||
# ใช้ target นี้สำหรับ:
|
|
||||||
# - npm run migrate
|
|
||||||
# - npm run seed:master-data
|
|
||||||
# - npm run seed:super-admin
|
|
||||||
# =========================================================
|
|
||||||
FROM base AS migrator
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
ENV HUSKY=0
|
|
||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
COPY package.json ./
|
|
||||||
|
|
||||||
# Drizzle configuration
|
|
||||||
COPY drizzle.config.* ./
|
|
||||||
|
|
||||||
# Migration files
|
|
||||||
COPY drizzle ./drizzle
|
|
||||||
|
|
||||||
# Database source code ที่ migration/seed scripts อาจ import
|
|
||||||
COPY src ./src
|
|
||||||
COPY scripts ./scripts
|
|
||||||
|
|
||||||
# ถ้าโปรเจกต์ใช้ tsconfig path alias
|
|
||||||
COPY tsconfig.json ./
|
|
||||||
|
|
||||||
# ถ้ามีไฟล์ config อื่นที่ scripts ใช้งาน ให้เปิดใช้ตามจริง
|
|
||||||
# COPY next.config.* ./
|
|
||||||
# COPY env.* ./
|
|
||||||
|
|
||||||
CMD ["npm", "run", "migrate"]
|
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Production Runner
|
# Production Runner
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|||||||
31
Dockerfile.migrator
Normal file
31
Dockerfile.migrator
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
FROM node:20-bookworm-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV HUSKY=0
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
|
RUN npm ci --no-audit --no-fund
|
||||||
|
|
||||||
|
COPY drizzle.config.* ./
|
||||||
|
COPY drizzle ./drizzle
|
||||||
|
COPY src ./src
|
||||||
|
COPY scripts ./scripts
|
||||||
|
COPY tsconfig.json ./
|
||||||
|
|
||||||
|
CMD ["sh", "-c", "\
|
||||||
|
set -e; \
|
||||||
|
echo 'Running database migrations...'; \
|
||||||
|
npm run migrate; \
|
||||||
|
echo 'Running master-data seed...'; \
|
||||||
|
npm run seed:master-data; \
|
||||||
|
echo 'Running super-admin seed...'; \
|
||||||
|
npm run seed:super-admin; \
|
||||||
|
echo 'Migration and seeds completed successfully'; \
|
||||||
|
tail -f /dev/null \
|
||||||
|
"]
|
||||||
Reference in New Issue
Block a user