-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdockerfile
41 lines (34 loc) · 1.03 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
ARG DEBIAN_VERSION=bookworm
ARG NODE_VERSION=20
#
# Use a builder to build the Krawler
#
FROM node:${NODE_VERSION}-${DEBIAN_VERSION} AS builder
# Install krawler
COPY . /opt/krawler
WORKDIR /opt/krawler
# Build krawler
RUN yarn
#
# Make a slim image and copy from the build
#
FROM node:${NODE_VERSION}-${DEBIAN_VERSION}-slim
LABEL maintainer="Kalisio <[email protected]>"
# Install Krawler, change owner to 'node' user
COPY --from=builder --chown=node:node /opt/krawler /opt/krawler
WORKDIR /opt/krawler
# Now run operations as 'node' user
USER node
# - Make krawler available for others to link
# - Make it executable, yarn link didn't do it
RUN yarn link && chmod u+x ~/.yarn/bin/krawler
# Put a symlink in /usr/local/bin
# This is a bit of a hack but I couldnt make 'krawler' command available
# using ENV PATH="${PATH}:~/.yarn/bin"
USER root
RUN ln -s /home/node/.yarn/bin/krawler /usr/local/bin
USER node
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s CMD node ./healthcheck.js
# Set command
CMD krawler $ARGS