From 8215c5478ae3a0f9af7a283d172d1c34956c1c2c Mon Sep 17 00:00:00 2001 From: Brandon Ly Date: Wed, 7 Feb 2024 09:23:51 -0600 Subject: [PATCH] Remove Dockerfile.enhanced (#978) * Add command to task def container * Remove dockerfile.enhanced * [DOP-4334]: Use npm ci * Remove references to dockerfile.enhanced * Reference main --- .../workflows/deploy-prd-enhanced-cache.yml | 6 +- .../workflows/deploy-stg-enhanced-worker.yml | 3 +- .github/workflows/update-feature-branch.yml | 2 +- Dockerfile | 10 +- Dockerfile.enhanced | 120 ------------------ cdk-infra/README.md | 2 +- .../lib/constructs/worker/worker-construct.ts | 2 +- 7 files changed, 12 insertions(+), 133 deletions(-) delete mode 100644 Dockerfile.enhanced diff --git a/.github/workflows/deploy-prd-enhanced-cache.yml b/.github/workflows/deploy-prd-enhanced-cache.yml index 2990a4d32..15390b971 100644 --- a/.github/workflows/deploy-prd-enhanced-cache.yml +++ b/.github/workflows/deploy-prd-enhanced-cache.yml @@ -20,7 +20,7 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - name: Rebuild Cache if New Snooty Parser Version - uses: mongodb/docs-worker-actions/rebuild-parse-cache@DOP-4294 - env: + uses: mongodb/docs-worker-actions/rebuild-parse-cache@main + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKSPACE: ${{ github.workspace }} \ No newline at end of file + WORKSPACE: ${{ github.workspace }} diff --git a/.github/workflows/deploy-stg-enhanced-worker.yml b/.github/workflows/deploy-stg-enhanced-worker.yml index 4f3fb2d24..c779ff49b 100644 --- a/.github/workflows/deploy-stg-enhanced-worker.yml +++ b/.github/workflows/deploy-stg-enhanced-worker.yml @@ -1,6 +1,6 @@ on: push: - paths: ["src/**", "cdk-infra/lib/constructs/worker/**", "Dockerfile.enhanced", "modules/**"] + paths: ['src/**', 'cdk-infra/lib/constructs/worker/**', 'Dockerfile', 'modules/**'] branches: - 'main' - 'integration' @@ -29,4 +29,3 @@ jobs: npm ci npm run deploy:feature:stack -- -c env=dotcomstg -c customFeatureName=enhancedApp-dotcomstg auto-builder-stack-enhancedApp-dotcomstg-worker npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg auto-builder-stack-enhancedApp-stg-worker - diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index a7a6f534e..b896e751d 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -103,7 +103,7 @@ jobs: worker: - 'src/!(cache-updater/**)/**' - 'cdk-infra/lib/constructs/worker/**' - - 'Dockerfile.enhanced' + - 'Dockerfile' - 'modules/**' - name: Update Worker Stack if: steps.filter.outputs.worker == 'true' diff --git a/Dockerfile b/Dockerfile index f89fd3ebd..01da8ea20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,19 +4,19 @@ WORKDIR /home/docsworker-xlarge COPY config config/ COPY package*.json ./ COPY tsconfig*.json ./ -RUN npm install +RUN npm ci --legacy-peer-deps COPY . ./ RUN npm run build # install persistence module RUN cd ./modules/persistence \ - && npm install \ + && npm ci --legacy-peer-deps \ && npm run build # Build modules # OAS Page Builder RUN cd ./modules/oas-page-builder \ - && npm install \ + && npm ci --legacy-peer-deps \ && npm run build # where repo work will happen @@ -102,14 +102,14 @@ 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 install +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 install +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 diff --git a/Dockerfile.enhanced b/Dockerfile.enhanced deleted file mode 100644 index a01bf9a94..000000000 --- a/Dockerfile.enhanced +++ /dev/null @@ -1,120 +0,0 @@ -# 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.2 -ARG SNOOTY_FRONTEND_VERSION=0.15.7 -ARG MUT_VERSION=0.10.7 -ARG REDOC_CLI_VERSION=1.2.3 -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", "--enable-source-maps", "enhanced/enhancedApp.js"] diff --git a/cdk-infra/README.md b/cdk-infra/README.md index 8ab410c1c..30918f438 100644 --- a/cdk-infra/README.md +++ b/cdk-infra/README.md @@ -71,7 +71,7 @@ To verify the CloudFormation is being generated successfully, you can use the `c npm run cdk synth -- -c enhanced=true -c customFeatureName=enhancedApp > cdk.out/template.yaml ``` -Make sure to update your `~/.aws/credentials` file. The `enhanced` context variable, if set to true, will use the `Dockerfile.enhanced` dockerfile instead of the standard one. The `featureName` context variable is used to provide a different name for a custom stack other than the branch name. In the future for feature branches, the context variable `isFeature` will be used to use the Git branch name and append that to the stack name. +Make sure to update your `~/.aws/credentials` file. The `enhanced` context variable, if set to true, will use the `Dockerfile` dockerfile instead of the standard one. The `featureName` context variable is used to provide a different name for a custom stack other than the branch name. In the future for feature branches, the context variable `isFeature` will be used to use the Git branch name and append that to the stack name. ## MongoDB Enhanced Infrastructure Commands diff --git a/cdk-infra/lib/constructs/worker/worker-construct.ts b/cdk-infra/lib/constructs/worker/worker-construct.ts index 53d75c9fa..8c00607dc 100644 --- a/cdk-infra/lib/constructs/worker/worker-construct.ts +++ b/cdk-infra/lib/constructs/worker/worker-construct.ts @@ -65,7 +65,6 @@ export class WorkerConstruct extends Construct { executionRole.addToPolicy(executionRoleSsmPolicy); const containerProps: AssetImageProps = { - file: isEnhanced() ? 'Dockerfile.enhanced' : undefined, buildArgs: { NPM_BASE_64_AUTH: dockerEnvironment.NPM_BASE_64_AUTH, NPM_EMAIL: dockerEnvironment.NPM_EMAIL, @@ -96,6 +95,7 @@ export class WorkerConstruct extends Construct { taskDefinition.addContainer('workerImage', { image: ContainerImage.fromAsset(path.join(__dirname, '../../../../'), containerProps), environment: dockerEnvironment, + command: ['node', '--enable-source-maps', 'enhanced/enhancedApp.js'], logging: LogDrivers.awsLogs({ streamPrefix: 'autobuilderworker', logGroup: taskDefLogGroup,