-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
48 lines (40 loc) · 1.67 KB
/
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
FROM node:20-alpine AS build
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi
COPY . .
# This is a boolean displaying the "official" Starky
# website (with a direct link to the Discord app
# and our Social Links). This is disabled by default!
ARG NEXT_PUBLIC_STARKY_OFFICIAL
ENV NEXT_PUBLIC_STARKY_OFFICIAL=$NEXT_PUBLIC_STARKY_OFFICIAL
# Next also needs the discord client id at build time to
# display a direct link to the application installation. Same,
# not needed by default.
ARG NEXT_PUBLIC_DISCORD_CLIENT_ID
ENV NEXT_PUBLIC_DISCORD_CLIENT_ID=$NEXT_PUBLIC_DISCORD_CLIENT_ID
ENV NODE_ENV production
RUN yarn build
# Production image, copy all the files and run next
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_OPTIONS=--max_old_space_size=4096
ENV NODE_ENV production
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist-server ./dist-server
COPY --from=build /app/.next ./.next
COPY --from=build /app/public ./public
COPY --from=build /app/docker-entrypoint.sh ./docker-entrypoint.sh
EXPOSE 8080
# Add a swap file to the container if needed
# This is useful for small VPS with low RAM
# Start the app
CMD [ "sh", "docker-entrypoint.sh" ]