Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,28 @@ RUN --mount=type=secret,id=DOCS_BOT_PAT_BASE,mode=0444 \
. ./build-scripts/fetch-repos.sh

# -----------------------------------------
# DEPENDENCIES STAGE: Install node packages
# PROD_DEPS STAGE: Install production dependencies
# -----------------------------------------
FROM base AS dependencies
FROM base AS prod_deps
USER node:node
WORKDIR $APP_HOME

# Copy what is needed to run npm ci
COPY --chown=node:node package.json package-lock.json ./

RUN npm ci --omit=optional --registry https://registry.npmjs.org/
# Install only production dependencies (skip scripts to avoid husky)
RUN npm ci --omit=dev --ignore-scripts --registry https://registry.npmjs.org/

# -----------------------------------------
# BUILD STAGE: Prepare for production stage
# ALL_DEPS STAGE: Install all dependencies on top of prod deps
# -----------------------------------------
FROM prod_deps AS all_deps

# Install dev dependencies on top of production ones
RUN npm ci --registry https://registry.npmjs.org/

# -----------------------------------------
# BUILD STAGE: Build the application
# -----------------------------------------
FROM base AS build
USER node:node
Expand All @@ -84,14 +93,27 @@ COPY --chown=node:node --from=clones $APP_HOME/assets assets/
COPY --chown=node:node --from=clones $APP_HOME/content content/
COPY --chown=node:node --from=clones $APP_HOME/translations translations/

# From the dependencies stage
COPY --chown=node:node --from=dependencies $APP_HOME/node_modules node_modules/
# From the all_deps stage (need dev deps for build)
COPY --chown=node:node --from=all_deps $APP_HOME/node_modules node_modules/

# Build the application
RUN npm run build

# -----------------------------------------
# WARMUP_CACHE STAGE: Warm up remote JSON cache
# -----------------------------------------
FROM build AS warmup_cache

# Generate remote JSON cache
RUN npm run warmup-remotejson

# Generate build files
RUN npm run build \
&& npm run warmup-remotejson \
&& npm run precompute-pageinfo -- --max-versions 2 \
&& npm prune --production
# -----------------------------------------
# PRECOMPUTE STAGE: Precompute page info
# -----------------------------------------
FROM build AS precompute_stage

# Generate precomputed page info
RUN npm run precompute-pageinfo -- --max-versions 2

# -------------------------------------------------
# PRODUCTION STAGE: What will run on the containers
Expand All @@ -112,13 +134,17 @@ COPY --chown=node:node --from=clones $APP_HOME/assets assets/
COPY --chown=node:node --from=clones $APP_HOME/content content/
COPY --chown=node:node --from=clones $APP_HOME/translations translations/

# From dependencies stage (*modified in build stage)
COPY --chown=node:node --from=build $APP_HOME/node_modules node_modules/
# From prod_deps stage (production-only node_modules)
COPY --chown=node:node --from=prod_deps $APP_HOME/node_modules node_modules/

# From build stage
COPY --chown=node:node --from=build $APP_HOME/.next .next/
COPY --chown=node:node --from=build $APP_HOME/.remotejson-cache ./
COPY --chown=node:node --from=build $APP_HOME/.pageinfo-cache.json.br* ./

# From warmup_cache stage
COPY --chown=node:node --from=warmup_cache $APP_HOME/.remotejson-cache ./

# From precompute_stage
COPY --chown=node:node --from=precompute_stage $APP_HOME/.pageinfo-cache.json.br* ./

# This makes it possible to set `--build-arg BUILD_SHA=abc123`
# and it then becomes available as an environment variable in the docker run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ redirect_from:
> [!IMPORTANT]
> * Billing for premium requests began on June 18, 2025 for all paid {% data variables.product.prodname_copilot_short %} plans, and the request counters were only set to zero for paid plans.
> * {% data reusables.copilot.data-residency-availability %}
> * Premium request counters reset on the 1st of each month. See [AUTOTITLE](/copilot/managing-copilot/understanding-and-managing-copilot-usage/monitoring-your-copilot-usage-and-entitlements).
> * Premium request counters reset on the 1st of each month at 00:00:00 UTC. See [AUTOTITLE](/copilot/managing-copilot/understanding-and-managing-copilot-usage/monitoring-your-copilot-usage-and-entitlements).
> * Certain requests may experience rate limits to accommodate high demand. Rate limits restrict the number of requests that can be made within a specific time period.

## What is a request?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ redirect_from:
You can track your monthly usage of premium requests to help you get the most value from your {% data variables.product.prodname_copilot_short %} plan.

> [!NOTE]
> Premium request counters reset on the 1st of each month.
> Premium request counters reset on the 1st of each month at 00:00:00 UTC.

## Viewing premium request usage

Expand Down
29 changes: 22 additions & 7 deletions src/deployments/production/build-scripts/fetch-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,29 @@ echo "Merging early access..."
mkdir -p translations
cd translations

# Iterate over each language
echo "Fetching translations..."
for lang in "es-es" "ja-jp" "pt-br" "zh-cn" "ru-ru" "fr-fr" "ko-kr" "de-de"
do
translations_repo="docs-internal.$lang"
clone_or_use_cached_repo "$lang" "$translations_repo" "main"
# Temporarily turn off exit-on-error so we can collect all PIDs
set +e

pids=""
for lang in es-es ja-jp pt-br zh-cn ru-ru fr-fr ko-kr de-de; do
clone_or_use_cached_repo "$lang" "docs-internal.$lang" "main" &
pids="$pids $!"
done

failures=0
for pid in $pids; do
wait "$pid" || failures=$((failures+1))
done
echo "Done fetching translations."

# Restore strict mode
set -e

if [ "$failures" -gt 0 ]; then
echo "⚠️ $failures translation repo(s) failed to fetch."
exit 1
else
echo "✅ All translations fetched."
fi

# Go back to the root of the docs-internal repo
cd ..
Expand Down
Loading