-
Notifications
You must be signed in to change notification settings - Fork 73
/
Dockerfile.local
139 lines (99 loc) · 4.44 KB
/
Dockerfile.local
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
FROM arm64v8/ubuntu:20.04 as initial
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ARG SNOOTY_PARSER_VERSION=0.18.8
ARG SNOOTY_FRONTEND_VERSION=0.18.12
ARG MUT_VERSION=0.11.4
ARG REDOC_CLI_VERSION=1.3.4
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ARG WORK_DIRECTORY=/home/docsworker-xlarge
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR ${WORK_DIRECTORY}
# helper libraries for docs builds
RUN apt-get update && apt-get install -y vim git unzip zip chromium-browser rsync
# get node 18
# https://gist.github.com/RinatMullayanov/89687a102e696b1d4cab
RUN apt-get install --yes curl
RUN curl --location https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
RUN apt-get install --yes python3-pip libxml2-dev libxslt-dev python-dev pkg-config
RUN python3 -m pip install poetry
# install snooty parser
RUN git clone -b v${SNOOTY_PARSER_VERSION} --depth 1 https://github.com/mongodb/snooty-parser.git \
&& cd snooty-parser \
&& python3 -m poetry install \
&& make package \
&& mv dist/snooty /opt/
# install mut
RUN git clone -b v${MUT_VERSION} --depth 1 https://github.com/mongodb/mut.git \
&& cd mut \
&& python3 -m poetry install \
&& make package \
&& mv dist/mut /opt/
ENV PATH="${PATH}:/opt/snooty:/opt/mut:/${WORK_DIRECTORY}/.local/bin"
# setup user and root directory
RUN useradd -ms /bin/bash docsworker-xlarge
RUN chmod 755 -R ${WORK_DIRECTORY}
RUN chown -Rv docsworker-xlarge ${WORK_DIRECTORY}
USER docsworker-xlarge
# Get Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN chmod -R 777 ${WORK_DIRECTORY}/.cargo/bin
ENV PATH="${WORK_DIRECTORY}/.cargo/bin:${PATH}"
RUN echo ${WORK_DIRECTORY}
# install snooty frontend and docs-tools
RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \
&& cd snooty \
&& npm ci --legacy-peer-deps \
&& cd component-factory-transformer \
&& cargo build \
&& rustup target add wasm32-wasi \
&& npm run prepublishOnly
RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk
RUN git clone -b @dop/redoc-cli@${REDOC_CLI_VERSION} --depth 1 https://github.com/mongodb-forks/redoc.git redoc \
# Install dependencies for Redoc CLI
&& cd redoc/ \
&& npm ci --prefix cli/ --omit=dev
FROM initial as persistence
RUN mkdir -p modules/persistence && chmod 755 modules/persistence
COPY modules/persistence/package*.json ./modules/persistence/
RUN cd ./modules/persistence \
&& npm ci --legacy-peer-deps
# Build persistence module
COPY --chown=docsworker-xlarge modules/persistence/tsconfig*.json ./modules/persistence
COPY --chown=docsworker-xlarge modules/persistence/src ./modules/persistence/src/
COPY --chown=docsworker-xlarge modules/persistence/index.ts ./modules/persistence
RUN cd ./modules/persistence \
&& npm run build:esbuild
FROM initial as oas
RUN mkdir -p modules/oas-page-builder && chmod 755 modules/oas-page-builder
COPY modules/oas-page-builder/package*.json ./modules/oas-page-builder/
RUN cd ./modules/oas-page-builder \
&& npm ci --legacy-peer-deps
# Build modules
# OAS Page Builder
COPY --chown=docsworker-xlarge modules/oas-page-builder/tsconfig*.json ./modules/oas-page-builder
COPY --chown=docsworker-xlarge modules/oas-page-builder/src ./modules/oas-page-builder/src/
COPY --chown=docsworker-xlarge modules/oas-page-builder/index.ts ./modules/oas-page-builder
RUN cd ./modules/oas-page-builder \
&& npm run build:esbuild
FROM initial as root
COPY --from=persistence --chown=docsworker-xlarge ${WORK_DIRECTORY}/modules/persistence/dist/ ./modules/persistence
COPY --from=oas --chown=docsworker-xlarge ${WORK_DIRECTORY}/modules/oas-page-builder/dist/ ./modules/oas-page-builder
# Root project build
COPY package*.json ./
RUN npm ci --legacy-peer-deps
COPY tsconfig*.json ./
COPY config config/
COPY api api/
COPY src src/
RUN npm run build:esbuild
ENV PERSISTENCE_MODULE_PATH=${WORK_DIRECTORY}/modules/persistence/index.js
ENV OAS_MODULE_PATH=${WORK_DIRECTORY}/modules/oas-page-builder/index.js
ENV REDOC_PATH=${WORK_DIRECTORY}/redoc/cli/index.js
RUN mkdir -p modules/persistence && chmod 755 modules/persistence
RUN mkdir repos && chmod 755 repos
EXPOSE 3000
CMD ["node", "--inspect-brk=0.0.0.0", "--enable-source-maps", "dist/entrypoints/onDemandApp.js"]