-
Notifications
You must be signed in to change notification settings - Fork 60.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass auth to Docker & clone needed repos at build time (#53618)
- Loading branch information
1 parent
b4523d2
commit e634991
Showing
7 changed files
with
285 additions
and
67 deletions.
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
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
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,6 @@ | ||
# Deployments | ||
|
||
Documentation and build files for our deployments. | ||
|
||
- For production deploys: [src/deployments/production](./production/) | ||
- For staging deploys (includes review servers): [src/deployments/staging](./staging/) |
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,31 @@ | ||
# Production deploys | ||
|
||
For internal Docs relating to our production deploys see [TODO Docs-Engineering URL] | ||
|
||
## Auto deploys | ||
|
||
Pushing to `main` on `docs-internal` will automatically kick off a deploy to production. | ||
|
||
The status of deployments are posted in the `#docs-ops` Slack channel. | ||
|
||
## Building & running the production image locally | ||
|
||
Build the production Docker image locally, | ||
|
||
```bash | ||
docker build -t docs:latest . --secret id=DOCS_BOT_PAT_READPUBLICKEY,src=<(echo "<your GH PAT value>") | ||
``` | ||
|
||
Where `<your GH PAT value>` must be a PAT with `contents: read` access to: | ||
|
||
1. `docs-internal.<lang>` for every `<lang>` translation repo | ||
2. `docs-early-access` | ||
|
||
Run the built image, | ||
|
||
```bash | ||
docker run -p 4000:4000 docs:latest | ||
``` | ||
|
||
> [!NOTE] | ||
> We require `DOCKER_BUILDKIT=1` to support passing `--secret` to the Dockerfile which allows us to clone private repos at build time. This is done in Moda via the `docker-build-env-secrets` argument in the [.github/workflows/moda-ci.yaml](../../.github/workflows/moda-ci.yaml) workflow. |
37 changes: 37 additions & 0 deletions
37
src/deployments/production/build-scripts/clone-or-use-cached-repo.sh
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,37 @@ | ||
set -e | ||
|
||
# We use this function to use the cached version of the repo if it exists from | ||
# a previous Dockerfile build. Otherwise, we clone the repo and check out the | ||
# specified branch/SHA. | ||
# Arguments: | ||
# $1 - Repository name (for directory naming) | ||
# $2 - Repository URL | ||
# $3 - Branch to clone | ||
clone_or_use_cached_repo() { | ||
repo_name="$1" | ||
repo_url="$2" | ||
branch="$3" | ||
|
||
echo "Processing repository '$repo_name'..." | ||
|
||
if [ -d "$repo_name/.git" ]; then | ||
echo "Repository '$repo_name' already exists. Fetching updates..." | ||
cd "$repo_name" | ||
|
||
# Fetch latest changes | ||
git fetch origin "$branch" | ||
git checkout "$branch" | ||
git pull origin "$branch" | ||
|
||
echo "Updated repository '$repo_name' with the latest changes from $branch." | ||
|
||
cd .. | ||
else | ||
echo "Cloning repository '$repo_name' from branch '$branch'..." | ||
|
||
# We only need the most recent change for production deploys, so we use --depth 1 | ||
git clone --depth 1 --branch "$branch" "https://${GITHUB_TOKEN}@github.com/github/$repo_url.git" "$repo_name" | ||
fi | ||
|
||
echo "Repository '$repo_name' is up to date." | ||
} |
Oops, something went wrong.