-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template
52 lines (37 loc) · 1.48 KB
/
Dockerfile.template
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 apify/actor-node:16 AS pnpm
RUN rm -rf node_modules
ARG PNPM_VERSION=7.27.1
ENV FOLDER={{FOLDER}}
# Install pnpm
RUN npm --no-fund --global install pnpm@${PNPM_VERSION}
# Check PNPM installation
RUN pnpm --version
# Specify the base Docker image. You can read more about
# the available images at https://crawlee.dev/docs/guides/docker-images
# You can also use any other image from Docker Hub.
FROM pnpm AS builder
ENV CI=1
ENV NODE_ENV=development
# Copy the repo
COPY . ./
# Install all dependencies. Don't audit to speed up the installation.
RUN pnpm install --frozen-lockfile --unsafe-perm
# Install all dependencies and build the project.
RUN pnpm run --filter="./packages/${FOLDER}" build
ENV NODE_ENV=production
# Then install only prod dependencies
RUN rm -rf "./packages/${FOLDER}/node_modules"
RUN pnpm install --filter="./packages/${FOLDER}" --virtual-store-dir "./packages/${FOLDER}/node_modules/.pnpm" --prod --no-frozen-lockfile
# Create final image
FROM pnpm
ENV CI=1
# Copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./
# Copy only built JS files from builder image
COPY --from=builder /usr/src/app/packages/${FOLDER}/dist ./packages/${FOLDER}/dist
# Copy node_modules
COPY --from=builder /usr/src/app/packages/${FOLDER}/node_modules ./packages/${FOLDER}/node_modules
# Run the image.
CMD pnpm run --filter="./packages/${FOLDER}" start:prod --silent