diff --git a/Dockerfile b/Dockerfile index 8195efc..d655b76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN pnpm build && pnpm exec emdash init && pnpm exec emdash seed && mkdir -p uploads +RUN pnpm build && pnpm exec emdash init && mkdir -p uploads FROM deps AS runner @@ -26,8 +26,11 @@ ENV HOST=0.0.0.0 COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/dist ./dist -COPY --from=builder /app/data.db ./data.db +COPY --from=builder /app/uploads ./uploads EXPOSE 4321 -CMD ["node", "./dist/server/entry.mjs"] +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..035e2e8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Only seed on first launch (when data.db doesn't exist) +if [ ! -f data.db ]; then + echo "Database missing, running emdash init & seed..." + pnpm exec emdash init + pnpm exec emdash seed +else + echo "Database exists, starting normally..." +fi +exec node ./dist/server/entry.mjs \ No newline at end of file