-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprod.Dockerfile
52 lines (43 loc) · 1.71 KB
/
prod.Dockerfile
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
FROM node:20-alpine
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
# Omit --production flag for TypeScript devDependencies
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i; \
# Allow install without lockfile, so example works even without Node.js installed locally
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
fi
COPY src ./src
COPY public ./public
COPY next.config.mjs .
COPY tsconfig.json .
COPY tailwind.config.js .
COPY postcss.config.mjs .
COPY components.json .
# Environment variables must be present at build time
# https://github.com/vercel/next.js/discussions/14030
ARG TMDB_API_KEY
ENV TMDB_API_KEY=${TMDB_API_KEY}
ARG TMDB_ACCESS_TOKEN
ENV TMDB_ACCESS_TOKEN=${TMDB_ACCESS_TOKEN}
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
# Uncomment the following line to disable telemetry at build time
ENV NEXT_TELEMETRY_DISABLED 1
# Note: Don't expose ports here, Compose will handle that for us
# Build Next.js based on the preferred package manager
RUN \
if [ -f yarn.lock ]; then yarn build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then pnpm build; \
else npm run build; \
fi
# Start Next.js based on the preferred package manager
CMD \
if [ -f yarn.lock ]; then yarn start; \
elif [ -f package-lock.json ]; then npm run start; \
elif [ -f pnpm-lock.yaml ]; then pnpm start; \
else npm run start; \
fi