-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
110 lines (80 loc) · 2.82 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
FROM node:21.7-bullseye-slim AS dbinstaller
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update && apt-get install -y apt-utils wget gnupg gnupg2 curl
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
RUN echo "deb https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
RUN apt-get update && apt-get install -y mongodb-org
RUN sed -i "s,\\(^[[:blank:]]*bindIp:\\) .*,\\1 0.0.0.0," /etc/mongod.conf
FROM --platform=$BUILDPLATFORM node:21.7-bullseye-slim AS installer
WORKDIR /usr/src/app
RUN apt-get update && \
apt-get install -y build-essential \
pkg-config \
make \
gcc \
curl \
libssl-dev \
cmake \
protobuf-compiler \
libprotobuf-dev
COPY package*.json yarn.lock ./
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="1" \
MONGOMS_SYSTEM_BINARY="/usr/bin/mongod" \
DISABLE_POSTINSTALL="true"
ENV PATH="/root/.cargo/bin:${PATH}"
RUN yarn
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
RUN rustup update
RUN cargo install website_crawler
FROM node:21.7-bullseye-slim AS builder
WORKDIR /usr/src/app
RUN apt-get update && \
apt-get install -y build-essential \
python3 \
pkg-config \
make \
gcc \
curl
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="1" \
MONGOMS_SYSTEM_BINARY="/usr/bin/mongod" \
DISABLE_POSTINSTALL="true"
COPY --from=installer /usr/src/app/node_modules ./node_modules
COPY . .
RUN yarn build && rm -R ./node_modules && yarn config set network-timeout 300000
RUN yarn install --production
FROM node:21.7-bullseye-slim
WORKDIR /usr/src/app
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
ENV MONGOMS_SYSTEM_BINARY="/usr/bin/mongod" \
MONGO_INITDB_DATABASE="a11ywatch" \
MONGOMS_VERSION="5.0.9" \
DB_URL="mongodb://0.0.0.0:27017" \
REDIS_CLIENT="redis://0.0.0.0:6379" \
REDIS_HOST="0.0.0.0" \
SUPER_MODE="true"
# CHROME_HOST="host.docker.internal"
# required runtime deps
RUN apt-get update && \
apt-get install -y build-essential \
curl \
redis-server
COPY --from=dbinstaller /usr/bin/mongod /usr/bin/mongod
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=installer /root/.cargo/bin/website_crawler /usr/bin/website_crawler
# install chrome and firefox todo: move install at runtime to keep bin small
RUN npx playwright install --with-deps chromium
# npx playwright install --with-deps firefox
# # test
# COPY --from=builder /usr/src/app/__tests__ ./__tests__
# COPY --from=builder /usr/src/app/package*.json ./
EXPOSE 27017
EXPOSE 3280
EXPOSE 50051
RUN mkdir -p /data/db
RUN mkdir ~/log
# set volume
VOLUME "/mongodb" "/data/db"
# wait for fork to finish
CMD mongod --fork --bind_ip 0.0.0.0 --logpath ~/log/mongodb.log && redis-server --daemonize yes && node --no-experimental-fetch ./dist/server.js