-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b4bdc1
commit f3db53f
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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 apify/actor-node-playwright-chrome:18 AS builder | ||
|
||
# Copy just package.json and package-lock.json | ||
# to speed up the build using Docker layer cache. | ||
COPY --chown=myuser package*.json ./ | ||
|
||
# Install all dependencies. Don't audit to speed up the installation. | ||
RUN npm install --include=dev --audit=false | ||
|
||
# Next, copy the source files using the user set | ||
# in the base image. | ||
COPY --chown=myuser . ./ | ||
|
||
# Install all dependencies and build the project. | ||
# Don't audit to speed up the installation. | ||
RUN npm run build | ||
|
||
# Create final image | ||
FROM apify/actor-node-playwright-chrome:18 | ||
|
||
# Copy only built JS files from builder image | ||
COPY --from=builder --chown=myuser /home/myuser/dist ./dist | ||
|
||
# Copy just package.json and package-lock.json | ||
# to speed up the build using Docker layer cache. | ||
COPY --chown=myuser package*.json ./ | ||
|
||
# Install NPM packages, skip optional and development dependencies to | ||
# keep the image small. Avoid logging too much and print the dependency | ||
# tree for debugging | ||
RUN npm --quiet set progress=false \ | ||
&& npm install --omit=dev --omit=optional \ | ||
&& echo "Installed NPM packages:" \ | ||
&& (npm list --omit=dev --all || true) \ | ||
&& echo "Node.js version:" \ | ||
&& node --version \ | ||
&& echo "NPM version:" \ | ||
&& npm --version | ||
|
||
# Next, 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 --chown=myuser . ./ | ||
|
||
|
||
# Run the image. If you know you won't need headful browsers, | ||
# you can remove the XVFB start script for a micro perf gain. | ||
CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent |