Skip to content

Commit

Permalink
Merge branch 'main' into DOP-4414
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar authored Apr 10, 2024
2 parents a935da1 + 5aecd9a commit 245cb6a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prd-enhanced-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
aws-region: us-east-2
- name: Deploy Enhanced Infrastructure
run: |
npm ci
cd cdk-infra/
npm ci
npm run deploy:enhanced:worker -- -c env=prd -c customFeatureName=enhancedApp
22 changes: 18 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,31 @@ 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}"


# 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 \
# Need to remove omit dev as the filter functionality for the frontend depends on a dev dependency.
&& 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
26 changes: 22 additions & 4 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM arm64v8/ubuntu:20.04 as initial
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ARG SNOOTY_PARSER_VERSION=0.15.2
ARG SNOOTY_FRONTEND_VERSION=0.15.7
ARG SNOOTY_PARSER_VERSION=0.16.4
ARG SNOOTY_FRONTEND_VERSION=0.16.8
ARG MUT_VERSION=0.10.7
ARG REDOC_CLI_VERSION=1.2.3
ARG NPM_BASE_64_AUTH
Expand All @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Docs Worker Pool

As part of the Docs Tools Next Generation Project, the Docs Worker Pool seeks to make the build process for developers
As part of the Docs Tools Next Generation Project, the Docs Worker Pool seeks to make the build process for developers
both easier and more scalable for developers.

The Docs Worker Pool operates on ECS Fargate. The serverless framework and cloudformation are used to automate
Expand Down
6 changes: 6 additions & 0 deletions src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ export abstract class JobHandler {
envVars += `PATH_PREFIX=${pathPrefix}\n`;
}
const snootyFrontEndVars = {
// Setting this to always be true. It's one less SSM parameter to manage,
// and it doesn't hurt to always do the filtering. The only reason
// it exists here is so that we don't always filter when testing locally.
// This is because the filter functionality updates the ComponentFactory.js file
// which could be accidentally committed if run locally.
USE_FILTER_BRANCH: true,
GATSBY_BASE_URL: this._config.get<string>('gatsbyBaseUrl'),
PREVIEW_BUILD_ENABLED: this._config.get<string>('previewBuildEnabled'),
GATSBY_TEST_SEARCH_UI: this._config.get<string>('featureFlagSearchUI'),
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`,
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`,
`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

0 comments on commit 245cb6a

Please sign in to comment.