Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 24ec3e5

Browse files
authored
[DOP-4438]: Add component filtering for production builds in the Autobuilder (#1025)
* [DOP-4438]: Add rust installation * [DOP-4438]: Remove cargo install * [DOP-4438]: revert * [DOP-4438]: add npm ci * [DOP-4438]: Remove unneeded test * [DOP-4438]: Remove unneeded test * [DOP-4438]: Clean up dockerfile * [DOP-4438]: Remove omit dev * [DOP-4438]: Update comments * [DOP-4438]: Remove echo
1 parent b0b3b0e commit 24ec3e5

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ RUN cd ./modules/oas-page-builder \
2222
# where repo work will happen
2323
FROM ubuntu:20.04
2424
ARG WORK_DIRECTORY=/home/docsworker-xlarge
25-
ARG SNOOTY_PARSER_VERSION=0.16.3
26-
ARG SNOOTY_FRONTEND_VERSION=0.16.6
25+
ARG SNOOTY_PARSER_VERSION=0.16.4
26+
ARG SNOOTY_FRONTEND_VERSION=0.16.8
2727
ARG MUT_VERSION=0.11.1
2828
ARG REDOC_CLI_VERSION=1.2.3
2929
ARG NPM_BASE_64_AUTH
@@ -63,17 +63,31 @@ USER docsworker-xlarge
6363

6464
WORKDIR ${WORK_DIRECTORY}
6565

66+
# Get Rust
67+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
68+
69+
RUN chmod -R 777 ${WORK_DIRECTORY}/.cargo/bin
70+
71+
ENV PATH="${WORK_DIRECTORY}/.cargo/bin:${PATH}"
72+
73+
6674
# get shared.mk
6775
RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk
6876

6977
# install snooty frontend and docs-tools
7078
RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \
7179
&& cd snooty \
72-
&& npm ci --legacy-peer-deps --omit=dev \
80+
# Need to remove omit dev as the filter functionality for the frontend depends on a dev dependency.
81+
&& npm ci --legacy-peer-deps \
7382
&& git clone --depth 1 https://github.com/mongodb/docs-tools.git \
7483
&& mkdir -p ./static/images \
7584
&& mv ./docs-tools/themes/mongodb/static ./static/docs-tools \
76-
&& mv ./docs-tools/themes/guides/static/images/bg-accent.svg ./static/docs-tools/images/bg-accent.svg
85+
&& mv ./docs-tools/themes/guides/static/images/bg-accent.svg ./static/docs-tools/images/bg-accent.svg \
86+
&& cd component-factory-transformer \
87+
&& cargo build \
88+
&& rustup target add wasm32-wasi \
89+
&& npm run prepublishOnly
90+
7791

7892
# install redoc fork
7993
RUN git clone -b @dop/redoc-cli@${REDOC_CLI_VERSION} --depth 1 https://github.com/mongodb-forks/redoc.git redoc \

Dockerfile.local

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ RUN apt-get install --yes build-essential
2424
RUN apt-get install --yes python3-pip libxml2-dev libxslt-dev python-dev pkg-config
2525

2626

27+
28+
2729
RUN python3 -m pip install poetry
2830

2931
# install snooty parser
@@ -43,16 +45,32 @@ RUN git clone -b v${MUT_VERSION} --depth 1 https://github.com/mongodb/mut.git \
4345

4446
ENV PATH="${PATH}:/opt/snooty:/opt/mut:/${WORK_DIRECTORY}/.local/bin"
4547

48+
49+
4650
# setup user and root directory
4751
RUN useradd -ms /bin/bash docsworker-xlarge
4852
RUN chmod 755 -R ${WORK_DIRECTORY}
4953
RUN chown -Rv docsworker-xlarge ${WORK_DIRECTORY}
54+
5055
USER docsworker-xlarge
5156

57+
# Get Rust
58+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
59+
60+
RUN chmod -R 777 ${WORK_DIRECTORY}/.cargo/bin
61+
62+
ENV PATH="${WORK_DIRECTORY}/.cargo/bin:${PATH}"
63+
RUN echo ${WORK_DIRECTORY}
64+
65+
5266
# install snooty frontend and docs-tools
5367
RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \
5468
&& cd snooty \
55-
&& npm ci --legacy-peer-deps --omit=dev
69+
&& npm ci --legacy-peer-deps \
70+
&& cd component-factory-transformer \
71+
&& cargo build \
72+
&& rustup target add wasm32-wasi \
73+
&& npm run prepublishOnly
5674

5775
RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk
5876

@@ -61,7 +79,7 @@ RUN git clone -b @dop/redoc-cli@${REDOC_CLI_VERSION} --depth 1 https://github.co
6179
# Install dependencies for Redoc CLI
6280
&& cd redoc/ \
6381
&& npm ci --prefix cli/ --omit=dev
64-
82+
6583
FROM initial as persistence
6684

6785
RUN mkdir -p modules/persistence && chmod 755 modules/persistence

src/job/jobHandler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ export abstract class JobHandler {
401401
envVars += `PATH_PREFIX=${pathPrefix}\n`;
402402
}
403403
const snootyFrontEndVars = {
404+
// Setting this to always be true. It's one less SSM parameter to manage,
405+
// and it doesn't hurt to always do the filtering. The only reason
406+
// it exists here is so that we don't always filter when testing locally.
407+
// This is because the filter functionality updates the ComponentFactory.js file
408+
// which could be accidentally committed if run locally.
409+
USE_FILTER_BRANCH: true,
404410
GATSBY_BASE_URL: this._config.get<string>('gatsbyBaseUrl'),
405411
PREVIEW_BUILD_ENABLED: this._config.get<string>('previewBuildEnabled'),
406412
GATSBY_TEST_SEARCH_UI: this._config.get<string>('featureFlagSearchUI'),

tests/unit/job/productionJobHandler.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,6 @@ describe('ProductionJobHandler Tests', () => {
166166
jobHandlerTestHelper.setupForSuccess();
167167
await jobHandlerTestHelper.jobHandler.execute();
168168
jobHandlerTestHelper.verifyNextGenSuccess();
169-
// TODO: Correct number of arguments
170-
expect(jobHandlerTestHelper.fileSystemServices.writeToFile).toBeCalledWith(
171-
`repos/${jobHandlerTestHelper.job.payload.repoName}/.env.production`,
172-
TestDataProvider.getEnvVarsWithPathPrefixWithFlags(jobHandlerTestHelper.job),
173-
{ encoding: 'utf8', flag: 'w' }
174-
);
175169
});
176170

177171
test('Default production deploy does not kick off manifest generation', async () => {
@@ -244,12 +238,6 @@ describe('ProductionJobHandler Tests', () => {
244238
jobHandlerTestHelper.setupForSuccess();
245239
await jobHandlerTestHelper.jobHandler.execute();
246240
jobHandlerTestHelper.verifyNextGenSuccess();
247-
248-
expect(jobHandlerTestHelper.fileSystemServices.writeToFile).toBeCalledWith(
249-
`repos/${jobHandlerTestHelper.job.payload.repoName}/.env.production`,
250-
`GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${jobHandlerTestHelper.job.payload.branchName}\nPATH_PREFIX=/\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\nGATSBY_MARIAN_URL=test-url\n`,
251-
{ encoding: 'utf8', flag: 'w' }
252-
);
253241
});
254242

255243
test('Execute Next Gen Build successfully', async () => {

0 commit comments

Comments
 (0)