Production 환경에서의 DB 자동 Migration 구현

This commit is contained in:
static
2025-01-20 19:15:15 +09:00
parent ce329891ae
commit 803110606b
10 changed files with 58 additions and 23 deletions

View File

@@ -2,6 +2,10 @@
FROM node:22-alpine AS base
WORKDIR /app
RUN apk add --no-cache bash curl && \
curl -o /usr/local/bin/wait-for-it https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && \
chmod +x /usr/local/bin/wait-for-it
RUN npm install -g pnpm@9
COPY pnpm-lock.yaml .
@@ -10,10 +14,9 @@ FROM base AS build
RUN pnpm fetch
COPY . .
RUN pnpm install --offline
RUN pnpm build
RUN sed -i "s/http\.createServer()/http.createServer({ requestTimeout: 0 })/g" ./build/index.js
RUN pnpm install --offline && \
pnpm build && \
sed -i "s/http\.createServer()/http.createServer({ requestTimeout: 0 })/g" ./build/index.js
# Deploy Stage
FROM base
@@ -23,9 +26,7 @@ COPY package.json .
RUN pnpm install --offline --prod
COPY --from=build /app/build ./build
COPY drizzle ./drizzle
EXPOSE 3000
ENV BODY_SIZE_LIMIT=Infinity
CMD ["node", "./build/index.js"]
CMD ["bash", "-c", "wait-for-it ${DATABASE_HOST:-localhost}:${DATABASE_PORT:-5432} -- node ./build/index.js"]