-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.beemovr
70 lines (63 loc) · 2.24 KB
/
Dockerfile.beemovr
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
# ---------------------------------------------------------------------
# HOW TO BUILD THIS IMAGE
# @remarks
# Normally, we use Docker Compose to build everything including this,
# but here's how to build this separately just in case you need to.
#
# @example
# cd BeeMovr
# docker build -f ./Dockerfile.beemovr -t beemovr .
#
# HOW TO RUN THIS IMAGE
# @remarks
# Running the example below runs BeeMovr through Node.js at:
# http://localhost
#
# @example
# docker run -p 80:3000 beemovr -v /app/database --name beemovr-database
#
# HOW TO DELETE THIS IMAGE
# @example
# docker image rm beemovr -f
# ---------------------------------------------------------------------
FROM node AS base
LABEL com.beemovr.description="https://github.com/soobinrho/BeeMovr"
LABEL com.beemovr.maintainer="Soobin Rho <soobin@nsustain.com>"
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
# ---------------------------------------------------------------------
# Install dependencies.
# ---------------------------------------------------------------------
FROM base AS deps
WORKDIR /app
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# ---------------------------------------------------------------------
# Run node through pnpm and Next.js
# ---------------------------------------------------------------------
FROM base as runner
WORKDIR /app
COPY . .
COPY ./.env* ./
COPY --from=deps /app/node_modules ./node_modules
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm run build
# Unlike RUN, which runs commands at the build time,
# CMD is what the image runs when we use "docker run ..."
# The difference between CMD and ENTRYPOINT is that
# extra arguments at "docker run <HERE>" override CMD,
# while ENTRYPOINT is still preserved.
# "The best use for ENTRYPOINT is to set the image’s main command,
# allowing that image to be run as though it was that command
# (and then use CMD as the default flags)."
# Example:
# ENTRYPOINT ["s3cmd"]
# CMD ["--help"]
# Source:
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENTRYPOINT ["pnpm"]
CMD ["start"]