Skip to content

Commit

Permalink
build: only build translations in production (set via docker arg)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotFriend committed Dec 18, 2024
1 parent 5875566 commit c73eb82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ RUN apt-get update && apt-get install --no-install-recommends -y gpg curl git ma

COPY . /app/
ARG CROWDIN_PERSONAL_TOKEN
ARG BUILD_TRANSLATIONS="False"

RUN yarn install
RUN yarn rpcspec:build
RUN yarn stellar-cli:build
# TODO: This takes a bit of time, we should probably make sure it's only done
# for production builds
# See: https://docusaurus.io/docs/3.4.0/i18n/crowdin#automate-with-ci
RUN CROWDIN_PERSONAL_TOKEN=${CROWDIN_PERSONAL_TOKEN} yarn crowdin:sync
RUN yarn crowdin:fix
# TODO: It's actually this part that is more time-consuming. The best way to
# speed this up is to generate the preview for only `--locale en`
RUN NODE_OPTIONS="--max-old-space-size=4096" yarn build

ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN if [ "$BUILD_TRANSLATIONS" = "True" ]; then \
CROWDIN_PERSONAL_TOKEN=${CROWDIN_PERSONAL_TOKEN} yarn build:production; \
else \
# In the preview build, we only want to build for English. Much quicker
yarn build; \
fi

FROM nginx:1.27

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ LABEL ?= $(shell git rev-parse --short HEAD)$(and $(shell git status -s),-dirty-
TAG ?= stellar/stellar-docs:$(LABEL)
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
BUILD_DATE := $(shell date -u +%FT%TZ)
# If we're not in production, don't build translations
BUILD_TRANSLATIONS ?= "False"

docker-build:
$(SUDO) docker build --no-cache --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) . --build-arg CROWDIN_PERSONAL_TOKEN=${CROWDIN_PERSONAL_TOKEN}
$(SUDO) docker build --no-cache --pull --label org.opencontainers.image.created="$(BUILD_DATE)" -t $(TAG) . --build-arg CROWDIN_PERSONAL_TOKEN=${CROWDIN_PERSONAL_TOKEN} --build-arg BUILD_TRANSLATIONS=${BUILD_TRANSLATIONS}

docker-push:
$(SUDO) docker push $(TAG)
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"build": "docusaurus build --locale en",
"build:production": "yarn crowdin:sync && yarn crowdin:fix && yarn build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand All @@ -30,7 +31,7 @@
"stellar-cli:build": "node scripts/stellar_cli.mjs",
"crowdin": "crowdin",
"crowdin:fix": "node scripts/copyIgnoredFiles.mjs && ./scripts/fix_translations.sh",
"crowdin:sync": "docusaurus write-translations && crowdin upload --delete-obsolete --no-progress && crowdin download --no-progress",
"crowdin:sync": "docusaurus write-translations && crowdin upload --no-progress && crowdin download --no-progress",
"ap:versions:clean": "docusaurus clean-api-docs:version -p ap-apis ap_platform:all && docusaurus clean-api-docs:version -p ap-apis ap_callbacks:all && docusaurus clean-api-docs:version -p ap-apis ap_custody:all",
"ap:versions:gen": "docusaurus gen-api-docs:version -p ap-apis ap_platform:all && docusaurus gen-api-docs:version -p ap-apis ap_callbacks:all && docusaurus gen-api-docs:version -p ap-apis ap_custody:all && rm ap_versioned_docs/version-*/api-reference/{callbacks,custody,platform/transactions}/*.info.mdx",
"ap:versions:regen": "yarn ap:versions:clean && yarn ap:versions:gen",
Expand Down

0 comments on commit c73eb82

Please sign in to comment.