Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOP-4438]: Add component filtering for production builds in the Autobuilder #1025

Merged
merged 11 commits into from
Apr 4, 2024
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ RUN cd ./modules/oas-page-builder \
# where repo work will happen
FROM ubuntu:20.04
ARG WORK_DIRECTORY=/home/docsworker-xlarge
ARG SNOOTY_PARSER_VERSION=0.16.3
ARG SNOOTY_FRONTEND_VERSION=0.16.6
ARG SNOOTY_PARSER_VERSION=0.16.4
ARG SNOOTY_FRONTEND_VERSION=0.16.8
ARG MUT_VERSION=0.11.1
ARG REDOC_CLI_VERSION=1.2.3
ARG NPM_BASE_64_AUTH
Expand Down Expand Up @@ -63,17 +63,30 @@ USER docsworker-xlarge

WORKDIR ${WORK_DIRECTORY}

# 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}

# 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 \
Copy link
Contributor Author

@branberry branberry Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove omit dev as the filter functionality for the frontend depends on a dev dependency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why it's a dev dependency then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same question! We should definitely consider moving the relevant dependencies to be installed for prod in the near future if possible

&& npm ci --legacy-peer-deps \
&& 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
&& mv ./docs-tools/themes/guides/static/images/bg-accent.svg ./static/docs-tools/images/bg-accent.svg \
&& cd component-factory-transformer \
&& cargo build \
&& rustup target add wasm32-wasi \
&& npm run prepublishOnly


# install redoc fork
RUN git clone -b @dop/redoc-cli@${REDOC_CLI_VERSION} --depth 1 https://github.com/mongodb-forks/redoc.git redoc \
Expand Down
22 changes: 20 additions & 2 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ 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
Expand All @@ -43,16 +45,32 @@ RUN git clone -b v${MUT_VERSION} --depth 1 https://github.com/mongodb/mut.git \

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 --omit=dev
&& 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

Expand All @@ -61,7 +79,7 @@ RUN git clone -b @dop/redoc-cli@${REDOC_CLI_VERSION} --depth 1 https://github.co
# 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
Expand Down
1 change: 1 addition & 0 deletions src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ export abstract class JobHandler {
const snootyFrontEndVars = {
GATSBY_BASE_URL: this._config.get<string>('gatsbyBaseUrl'),
PREVIEW_BUILD_ENABLED: this._config.get<string>('previewBuildEnabled'),
USE_FILTER_BRANCH: true,
GATSBY_TEST_SEARCH_UI: this._config.get<string>('featureFlagSearchUI'),
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: this._config.get<string>('gatsbyHideUnifiedFooterLocale'),
GATSBY_MARIAN_URL: this._config.get<string>('gatsbyMarianURL'),
Expand Down
12 changes: 0 additions & 12 deletions tests/unit/job/productionJobHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ describe('ProductionJobHandler Tests', () => {
jobHandlerTestHelper.setupForSuccess();
await jobHandlerTestHelper.jobHandler.execute();
jobHandlerTestHelper.verifyNextGenSuccess();
// TODO: Correct number of arguments
expect(jobHandlerTestHelper.fileSystemServices.writeToFile).toBeCalledWith(
`repos/${jobHandlerTestHelper.job.payload.repoName}/.env.production`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this as I believe it's not providing a ton of value, and leads to additional overhead when making changes.

TestDataProvider.getEnvVarsWithPathPrefixWithFlags(jobHandlerTestHelper.job),
{ encoding: 'utf8', flag: 'w' }
);
});

test('Default production deploy does not kick off manifest generation', async () => {
Expand Down Expand Up @@ -244,12 +238,6 @@ describe('ProductionJobHandler Tests', () => {
jobHandlerTestHelper.setupForSuccess();
await jobHandlerTestHelper.jobHandler.execute();
jobHandlerTestHelper.verifyNextGenSuccess();

expect(jobHandlerTestHelper.fileSystemServices.writeToFile).toBeCalledWith(
`repos/${jobHandlerTestHelper.job.payload.repoName}/.env.production`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this as I believe it's not providing a ton of value, and leads to additional overhead when making changes.

`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`,
{ encoding: 'utf8', flag: 'w' }
);
});

test('Execute Next Gen Build successfully', async () => {
Expand Down
Loading