forked from mongodb/docs-worker-pool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.enhanced
120 lines (99 loc) · 5.05 KB
/
Dockerfile.enhanced
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
# Build the Typescript app
FROM node:18.16.0-alpine as ts-compiler
WORKDIR /home/docsworker-xlarge
COPY config config/
COPY package*.json ./
COPY tsconfig*.json ./
RUN npm ci --legacy-peer-deps
COPY . ./
RUN npm run build
# install persistence module
RUN cd ./modules/persistence \
&& npm ci --legacy-peer-deps \
&& npm run build
# Build modules
# OAS Page Builder
RUN cd ./modules/oas-page-builder \
&& npm ci --legacy-peer-deps \
&& npm run build
# where repo work will happen
FROM ubuntu:20.04
ARG WORK_DIRECTORY=/home/docsworker-xlarge
ARG SNOOTY_PARSER_VERSION=0.15.1
ARG SNOOTY_FRONTEND_VERSION=0.15.2
ARG MUT_VERSION=0.10.7
ARG REDOC_CLI_VERSION=1.2.2
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ENV DEBIAN_FRONTEND=noninteractive
# install legacy build environment for docs
RUN apt-get -o Acquire::Check-Valid-Until=false update
RUN apt-get -y install libpython2.7-dev python2.7 git rsync unzip curl
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
RUN python2.7 get-pip.py
RUN pip install requests virtualenv virtualenvwrapper py-dateutil
RUN python2.7 -m pip install python-dateutil
RUN virtualenv /venv
RUN /venv/bin/pip install --upgrade --force setuptools
RUN /venv/bin/pip install -r https://raw.githubusercontent.com/mongodb/docs-tools/master/giza/requirements.txt
# helper libraries for docs builds
RUN apt-get update && apt-get install -y vim git
ENV PATH="${PATH}:/opt/snooty:/opt/mut:/home/docsworker-xlarge/.local/bin:/usr/local/lib/python2.7/dist-packages/virtualenv/bin"
# 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
# use npm 8.*
RUN npm install -g npm@8
# install snooty parser
RUN curl -L -o snooty-parser.zip https://github.com/mongodb/snooty-parser/releases/download/v${SNOOTY_PARSER_VERSION}/snooty-v${SNOOTY_PARSER_VERSION}-linux_x86_64.zip \
&& unzip -d /opt/ snooty-parser.zip
# install mut
RUN curl -L -o mut.zip https://github.com/mongodb/mut/releases/download/v${MUT_VERSION}/mut-v${MUT_VERSION}-linux_x86_64.zip \
&& unzip -d /opt/ mut.zip
# 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
WORKDIR ${WORK_DIRECTORY}
# get shared.mk
RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk
# 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 --omit=dev \
&& git clone --depth 1 https://github.com/mongodb/docs-tools.git \
&& mkdir -p ./static/images \
&& mv ./docs-tools/themes/mongodb/static ./static/docs-tools \
&& mv ./docs-tools/themes/guides/static/images/bg-accent.svg ./static/docs-tools/images/bg-accent.svg
# install redoc fork
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
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/package*.json ./
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/config config/
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/build ./
RUN npm install
# Persistence module copy
# Create directory and add permissions to allow node module installation
RUN mkdir -p modules/persistence && chmod 755 modules/persistence
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/modules/persistence/package*.json ./modules/persistence/
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/modules/persistence/dist ./modules/persistence/
ENV PERSISTENCE_MODULE_PATH=${WORK_DIRECTORY}/modules/persistence/index.js
RUN cd ./modules/persistence/ && ls && npm ci --legacy-peer-deps
# OAS Page Builder module copy
# Create directory and add permissions to allow node module installation
RUN mkdir -p modules/oas-page-builder && chmod 755 modules/oas-page-builder
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/modules/oas-page-builder/package*.json ./modules/oas-page-builder/
COPY --from=ts-compiler --chown=docsworker-xlarge /home/docsworker-xlarge/modules/oas-page-builder/dist ./modules/oas-page-builder/
RUN cd ./modules/oas-page-builder/ && npm ci --legacy-peer-deps
# Needed for OAS Page Builder module in shared.mk
ENV REDOC_PATH=${WORK_DIRECTORY}/redoc/cli/index.js
ENV OAS_MODULE_PATH=${WORK_DIRECTORY}/modules/oas-page-builder/index.js
RUN mkdir repos && chmod 755 repos
EXPOSE 3000
CMD ["node", "enhanced/enhancedApp.js"]