-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (52 loc) · 2.42 KB
/
Dockerfile
File metadata and controls
75 lines (52 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile をベースに
# (TODO?) 本来は ARG で各種環境変数を記述してビルド時に与えられるようにする必要がある。
# 現在このdockerfileはcoolify上でのビルドのみに使用しており、coolifyが自動的にARG文を挿入するため動作している。
FROM node:lts-slim AS dependencies
WORKDIR /app
COPY package.json package-lock.json ./
COPY packages/jsEval/package.json ./packages/jsEval/
COPY packages/runtime/package.json ./packages/runtime/
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund
# これだけ時間かかるので先に実行する
WORKDIR /app
COPY ./scripts ./scripts
RUN mkdir app && npx tsx ./scripts/removeHinting.ts
FROM node:lts-slim AS builder
# ビルド中にsentryでソースマップをアップロードするのに必要
RUN apt-get update && apt-get install -y ca-certificates
# Set working directory
WORKDIR /app
# Copy project dependencies from dependencies stage
COPY --from=dependencies /app/node_modules ./node_modules
# Copy application source code
COPY . .
COPY --from=dependencies /app/app/m-plus-rounded-1c-nohint ./app/m-plus-rounded-1c-nohint
# Stop if documentation has any change that is not reflected to revisions.yml and database.
RUN npx tsx ./scripts/checkDocs.ts --check-diff
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
# Build Next.js application
RUN --mount=type=cache,target=/app/.next/cache \
npm run build
FROM node:lts-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the run time.
# ENV NEXT_TELEMETRY_DISABLED=1
# Copy production assets
COPY --from=builder --chown=node:node /app/public ./public
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
# Switch to non-root user for security best practices
USER node
# Expose port 3000 to allow HTTP traffic
EXPOSE 3000
# Start Next.js standalone server
CMD ["node", "server.js"]