-
Notifications
You must be signed in to change notification settings - Fork 73
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-4033]: Replicate shared.mk steps within Autobuilder code #917
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
9878242
[DOP-4033]: Add initial commands
branberry 902a357
[DOP-4033]: Create helpers for cli commands
branberry 534084b
[DOP-4033]: Add default args
branberry 8995249
[DOP-4033]: Move directories
branberry 1ccbad7
[DOP-4033]: Update spawn to work async and add code for getPatchId co…
branberry 5281b13
[DOP-4033]: Refactor executeCliCommand
branberry dce8dd7
[DOP-4033]: Wrap up nextgenparse refactor
branberry 7324870
[DOP-4033]: Move commands directory out of enhanced
branberry ab09876
[DOP-4033]: Add next gen html command
branberry 18ff8d8
[DOP-4033]: Use correct arg for createEnvProdFile
branberry 8e03ca2
[DOP-4033]: Add git hash
branberry 3566e9a
[DOP-4033]: Move commands into shared directory
branberry 7d4dca6
[DOP-4033]: Refactor
branberry 43efb54
[DOP-4033]: Create base job for standard builds ie jobs with makefile…
branberry 6a39606
[DOP-4033]: Add the ability to append to file using executeCliCommand
branberry e27bae3
[DOP-4033]: Add logic to write to .env.production file
branberry 6b9df11
[DOP-4033]: Add more logic to write to files and start working creati…
branberry 3ae00e3
[DOP-4033]: Add local testing app and make test build faster
branberry 32f7dc6
[DOP-4033]: Add test code to confirm commands work, and remove base d…
branberry 8b9519d
[DOP-4033]: Add next-gen-stage, and add support for arm64 dockerfile
branberry 4518c13
[DOP-4033]: Remove extra args from dockerfile
branberry a9ae14a
[DOP-4033]: Add oas-page-build and persistence module
branberry c5037fd
[DOP-4033]: Add bundle path for oaspagebuild
branberry 9f3cd88
[DOP-4033]: Work on logic for deploy and ability to pipe output from …
branberry 4b5a432
[DOP-4033]: Work on logic for deploy and ability to pipe output from …
branberry 1a635d1
[DOP-4033]: Work on logic for deploy and ability to pipe output from …
branberry 82872a0
[DOP-4033]: Finish up pipe logic
branberry d6798e3
[DOP-4033]: Add next-gen-deploy
branberry 66bd820
[DOP-4033]: Remove unused imports
branberry dcc7e62
[DOP-4033]: Remove standard job handler
branberry 24b4c00
[DOP-4033]: Add execution helper
branberry c5d6680
[DOP-4033]: Refactor localApp
branberry 17830fb
[DOP-4033]: Add stage job
branberry ff2aeb0
Merge branch 'master' into DOP-4033
branberry d2c6f13
[DOP-4033]: Update persistence module
branberry 4827b01
[DOP-4033]: Add next-gen-deploy
branberry 9b28c5d
Merge branch 'master' into DOP-4033
branberry 5c44115
[DOP-4033]: Update next-gen-deploy to work
branberry 42753cf
[DOP-4033]: Add comments
branberry 6749b66
[DOP-4033]: Add more comments
branberry dc492ac
[DOP-4033]: Remove index.ts
branberry 3adf633
[DOP-4033]: Refactor to use index file
branberry de8ae8c
Merge branch 'master' into DOP-4033
branberry b2bc784
[DOP-4033]: Use correct values for nextgenstage
branberry bdacf2d
[DOP-4033]: Respond to review comments
branberry 1f0328b
[DOP-4033]: Use PATH_PREFIX
branberry f5497f9
[DOP-4033]: Remove param0
branberry fbb0256
[DOP-4033]: Respond to review feedback
branberry 80f4e2f
[DOP-4033]: Respond to review feedback
branberry a06ebe1
[DOP-4033]: Remove extra log
branberry 99ad2e1
[DOP-4033]: Add empty string to join to remove commas
branberry 079fe47
[DOP-4033]: Use console.log
branberry 0d63308
[DOP-4033]: Check array length
branberry 234c843
[DOP-4033]: Add error handling for dependency helper
branberry 759689a
Merge branch 'master' into DOP-4033
branberry e442448
Merge branch 'master' into DOP-4033
branberry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
FROM arm64v8/ubuntu:20.04 | ||
ARG NPM_BASE_64_AUTH | ||
ARG NPM_EMAIL | ||
ARG SNOOTY_PARSER_VERSION=0.14.9 | ||
ARG SNOOTY_FRONTEND_VERSION=0.14.18 | ||
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 | ||
|
||
# helper libraries for docs builds | ||
RUN apt-get update && apt-get install -y vim git unzip zip | ||
|
||
# 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 | ||
RUN apt-get install --yes python3-pip libxml2-dev libxslt-dev python-dev pkg-config | ||
|
||
WORKDIR /app | ||
|
||
RUN python3 -m pip install poetry | ||
|
||
# install snooty parser | ||
RUN git clone -b v${SNOOTY_PARSER_VERSION} --depth 1 https://github.com/mongodb/snooty-parser.git \ | ||
&& cd snooty-parser \ | ||
&& python3 -m poetry install \ | ||
&& make package \ | ||
&& mv dist/snooty /opt/ | ||
|
||
# install mut | ||
|
||
RUN git clone -b v${MUT_VERSION} --depth 1 https://github.com/mongodb/mut.git \ | ||
&& cd mut \ | ||
&& python3 -m poetry install \ | ||
&& make package \ | ||
&& mv dist/mut /opt/ | ||
|
||
RUN curl -L -o redoc.zip https://github.com/mongodb-forks/redoc/archive/refs/tags/v${REDOC_CLI_VERSION}.zip \ | ||
&& unzip redoc.zip \ | ||
&& mv redoc-${REDOC_CLI_VERSION} redoc/ | ||
|
||
ENV PATH="${PATH}:/opt/snooty:/opt/mut:/app/.local/bin" | ||
|
||
# setup user and root directory | ||
RUN useradd -ms /bin/bash docsworker | ||
RUN chmod 755 -R /app | ||
RUN chown -Rv docsworker /app | ||
USER docsworker | ||
|
||
# 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 | ||
|
||
RUN mkdir -p modules/persistence && chmod 755 modules/persistence | ||
COPY modules/persistence/package*.json ./modules/persistence/ | ||
RUN cd ./modules/persistence \ | ||
&& npm ci --legacy-peer-deps | ||
|
||
RUN mkdir -p modules/oas-page-builder && chmod 755 modules/oas-page-builder | ||
COPY modules/oas-page-builder/package*.json ./modules/oas-page-builder/ | ||
RUN cd ./modules/oas-page-builder \ | ||
&& npm ci --legacy-peer-deps | ||
|
||
# Root project build | ||
COPY package*.json ./ | ||
RUN npm ci --legacy-peer-deps | ||
# Build persistence module | ||
|
||
COPY --chown=docsworker modules/persistence/tsconfig*.json ./modules/persistence | ||
COPY --chown=docsworker modules/persistence/src ./modules/persistence/src/ | ||
COPY --chown=docsworker modules/persistence/index.ts ./modules/persistence | ||
|
||
RUN cd ./modules/persistence \ | ||
&& npm run build | ||
|
||
# Build modules | ||
# OAS Page Builder | ||
COPY --chown=docsworker modules/oas-page-builder/tsconfig*.json ./modules/oas-page-builder | ||
COPY --chown=docsworker modules/oas-page-builder/src ./modules/oas-page-builder/src/ | ||
COPY --chown=docsworker modules/oas-page-builder/index.ts ./modules/oas-page-builder | ||
|
||
RUN cd ./modules/oas-page-builder \ | ||
&& npm run build | ||
|
||
COPY tsconfig*.json ./ | ||
COPY config config/ | ||
COPY api api/ | ||
COPY src src/ | ||
|
||
RUN npm run build:esbuild | ||
|
||
RUN mkdir repos && chmod 755 repos | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["node", "--enable-source-maps", "dist/entrypoints/localApp.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"start": "node index.js", | ||
"clean": "node maintain.js", | ||
"build": "tsc", | ||
"build:esbuild": "esbuild src/entrypoints/localApp.ts --bundle --platform=node --outdir=./dist/entrypoints --allow-overwrite --sourcemap", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this to improve the build time of the app for quicker testing. Added sourcemaps for more accurate stack traces. Basically, it will tell the exact line in the TS code where an error occurs. |
||
"format": "npm run prettier -- --check", | ||
"format:fix": "npm run prettier -- --write", | ||
"lint": "eslint --ext .ts .", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { prepareBuildAndGetDependencies } from './src/helpers/dependency-helpers'; | ||
import { nextGenDeploy } from './src/shared/next-gen-deploy'; | ||
import { nextGenHtml } from './src/shared/next-gen-html'; | ||
import { nextGenParse } from './src/shared/next-gen-parse'; | ||
import { nextGenStage } from './src/shared/next-gen-stage'; | ||
import { oasPageBuild } from './src/shared/oas-page-build'; | ||
import { persistenceModule } from './src/shared/persistence-module'; | ||
|
||
export { | ||
nextGenParse, | ||
nextGenHtml, | ||
nextGenStage, | ||
persistenceModule, | ||
oasPageBuild, | ||
nextGenDeploy, | ||
prepareBuildAndGetDependencies, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import { executeCliCommand, getCommitBranch, getCommitHash, getPatchId, getRepoDir } from '.'; | ||
import { promisify } from 'util'; | ||
|
||
const existsAsync = promisify(fs.exists); | ||
const writeFileAsync = promisify(fs.writeFile); | ||
|
||
async function cloneRepo(repoName: string) { | ||
await executeCliCommand({ | ||
command: 'git', | ||
args: ['clone', `https://github.com/mongodb/${repoName}`], | ||
options: { cwd: `${process.cwd()}/repos` }, | ||
}); | ||
} | ||
async function createEnvProdFile(repoDir: string, projectName: string, baseUrl: string, prefix = '') { | ||
const prodFileName = `${process.cwd()}/snooty/.env.production`; | ||
|
||
try { | ||
await writeFileAsync( | ||
prodFileName, | ||
`GATSBY_SITE=${projectName} | ||
GATSBY_MANIFEST_PATH=${repoDir}/bundle.zip | ||
GATSBY_PARSER_USER=${process.env.USER} | ||
GATSBY_BASE_URL=${baseUrl} | ||
PATH_PREFIX=${prefix}`, | ||
'utf8' | ||
); | ||
} catch (e) { | ||
console.error(`ERROR! Could not write to .env.production`); | ||
throw e; | ||
} | ||
} | ||
|
||
export async function prepareBuildAndGetDependencies(repoName: string, projectName: string, baseUrl: string) { | ||
// before we get build dependencies, we need to clone the repo | ||
await cloneRepo(repoName); | ||
|
||
const repoDir = getRepoDir(repoName); | ||
|
||
// doing these in parallel | ||
const commandPromises = [ | ||
getCommitHash(repoDir), | ||
getCommitBranch(repoDir), | ||
getPatchId(repoDir), | ||
existsAsync(path.join(process.cwd(), 'config/redirects')), | ||
createEnvProdFile(repoDir, projectName, baseUrl), | ||
]; | ||
|
||
try { | ||
const dependencies = await Promise.all(commandPromises); | ||
|
||
return { | ||
commitHash: dependencies[0] as string, | ||
commitBranch: dependencies[1] as string, | ||
patchId: dependencies[2] as string | undefined, | ||
hasRedirects: dependencies[3] as boolean, | ||
bundlePath: `${repoDir}/bundle.zip`, | ||
repoDir, | ||
}; | ||
} catch (error) { | ||
console.error('ERROR! Could not get build dependencies'); | ||
throw error; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IGNORE: This is for local testing. This will probably change.