Skip to content
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

Upgrade website to Docsy 0.5.1 #531

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
06c84c8
Upgrade docsy to 0.1.0
SayakMukhopadhyay Sep 20, 2024
502e75e
Upgrade docsy to 0.2.0
SayakMukhopadhyay Sep 20, 2024
f3700f6
Upgrade docsy to 0.3.0
SayakMukhopadhyay Sep 20, 2024
de760a7
Upgrade docsy to 0.4.0
SayakMukhopadhyay Sep 20, 2024
ad8c1db
Upgrade docsy to 0.5.1
SayakMukhopadhyay Sep 20, 2024
381862d
fix: license info in package.json
SayakMukhopadhyay Dec 23, 2024
6517167
feat: add docsy dependency installations as a dependency of build tar…
SayakMukhopadhyay Dec 23, 2024
28ef958
ci: force to use a compatible node version
SayakMukhopadhyay Dec 23, 2024
42b9580
Use docsy recommended way of overriding SCSS variables instead of cop…
SayakMukhopadhyay Dec 23, 2024
60a420c
feat: migrate docsy from using as a submodule to an npm module
SayakMukhopadhyay Dec 24, 2024
472dff6
feat: rework Makefile and Dockerfile to exclude git submodule operations
SayakMukhopadhyay Dec 24, 2024
6f0fe7d
feat: remove unnecessary .gitmodules file
SayakMukhopadhyay Dec 24, 2024
7ad66f9
feat: add `npm ci` as a dependant command for local execution
SayakMukhopadhyay Dec 24, 2024
67237af
fix: make sure that the package files are copied before installing th…
SayakMukhopadhyay Dec 24, 2024
18f03d8
chore: remove taxonomyTerm as a disabled Kind as its deprecated and r…
SayakMukhopadhyay Dec 24, 2024
aa529bb
fix: only mount folders that are needed so as to not shadow `node_mod…
SayakMukhopadhyay Jan 2, 2025
8daa6b9
fix: run the containers without the user flag to ensure it runs as th…
SayakMukhopadhyay Jan 3, 2025
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
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ RUN apk add --no-cache \

WORKDIR /src

# Required for PostCSS
RUN npm install -G \
autoprefixer \
postcss-cli
COPY package*.json ./

RUN npm ci
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will create /src/node_modules, but when the repository is mounted over that, the node modules will be shadowed / hidden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp....that's right. Maybe I should move the npm ci into hack/gen-content.sh.

Seems like k8s/website too has this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, in the website, npm ci is in the Dockerfile (see https://github.com/kubernetes/website/blob/30350f69b1b1f258a4534be4e16f966a641b4f35/Dockerfile#L44). The way this works is that in the Makefile, each directory is mounted explicitly (see https://github.com/kubernetes/website/blob/main/Makefile#L16) and the whole directory isn't mounted as a whole.

So, we have 2 ways to work this.

  1. We can use the website way of doing things.
  2. I can remove the npm ci from the Dockerfile and put it in the Makefile as
container-server: ## Run Hugo locally within a container, available at http://localhost:1313/
	# no build lock to allow for read-only mounts
	$(CONTAINER_RUN) -p 1313:1313 \
		--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
		--read-only \
		--cap-drop=ALL \
		--cap-drop=AUDIT_WRITE \
		$(CONTAINER_IMAGE) \
	bash -c 'cd /src && hack/gen-content.sh --in-container && \
		 cd /tmp/src && \
		 npm ci && \
		hugo server \
		--environment preview \
		--logLevel info \
		--noBuildLock \
		--bind 0.0.0.0 \
		--buildDrafts \
		--buildFuture \
		--disableFastRender \
		--ignoreCache \
		--destination /tmp/hugo \
		--cleanDestinationDir'

(note the npm ci && \).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the website way of doing things.

Let's do that. Otherwise, npm is still running in the host context, and the trust base for our [static site generation website preview] code becomes much larger.


RUN mkdir -p /usr/local/src && \
cd /usr/local/src && \
Expand Down
37 changes: 17 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,42 @@ CONTAINER_ENGINE ?= docker
CONTAINER_RUN := $(CONTAINER_ENGINE) run --user : --rm -it -v "$(CURDIR):/src"
HUGO_VERSION := $(shell grep ^HUGO_VERSION netlify.toml | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
CONTAINER_IMAGE := k8s-contrib-site-hugo
REPO_ROOT :=${CURDIR}

# Fast NONBlOCKING IO to stdout caused by the hack/gen-content.sh script can
# cause Netlify builds to terminate unexpectantly. This forces stdout to block.
# Fast NONBLOCKING IO to stdout caused by the hack/gen-content.sh script can
# cause Netlify builds to terminate unexpectedly. This forces stdout to block.
BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); \
fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);"

.DEFAULT_GOAL := help

.PHONY: targets container-targets
targets: help gen-content render serve clean clean-all sproduction preview-build
targets: help gen-content render server clean clean-all production-build preview-build
container-targets: container-image container-gen-content container-render container-server

help: ## Show this help text.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

dependencies:
npm ci

gen-content: ## Generates content from external sources.
hack/gen-content.sh

render: ## Build the site using Hugo on the host.
git submodule update --init --recursive --depth 1
hugo --verbose --ignoreCache --minify
render: dependencies ## Build the site using Hugo on the host.
hugo --logLevel info --ignoreCache --minify

server: ## Run Hugo locally (if Hugo "extended" is installed locally)
git submodule update --init --recursive --depth 1
server: dependencies ## Run Hugo locally (if Hugo "extended" is installed locally)
hugo server \
--verbose \
--logLevel info \
--buildDrafts \
--buildFuture \
--disableFastRender \
--ignoreCache

docker-image: container-image
docker-image:
@echo -e "**** The use of docker-image is deprecated. Use container-image instead. ****" 1>&2
$(MAKE) container-image

container-image: ## Build container image for use with container-* targets.
$(CONTAINER_ENGINE) build . -t $(CONTAINER_IMAGE) --build-arg HUGO_VERSION=$(HUGO_VERSION)
Expand All @@ -67,16 +68,14 @@ docker-render:
$(MAKE) container-render

container-render: ## Build the site using Hugo within a container (equiv to render).
git submodule update --init --recursive --depth 1
$(CONTAINER_RUN) $(CONTAINER_IMAGE) hugo --verbose --ignoreCache --minify
$(CONTAINER_RUN) $(CONTAINER_IMAGE) hugo --logLevel info --ignoreCache --minify

docker-server:
@echo -e "**** The use of docker-server is deprecated. Use container-server instead. ****" 1>&2
$(MAKE) container-server

container-server: ## Run Hugo locally within a container, available at http://localhost:1313/
# no build lock to allow for read-only mounts
git submodule update --init --recursive --depth 1
$(CONTAINER_RUN) -p 1313:1313 \
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
--read-only \
Expand All @@ -87,7 +86,7 @@ container-server: ## Run Hugo locally within a container, available at http://lo
cd /tmp/src && \
hugo server \
--environment preview \
--verbose \
--logLevel info \
--noBuildLock \
--bind 0.0.0.0 \
--buildDrafts \
Expand All @@ -100,7 +99,7 @@ container-server: ## Run Hugo locally within a container, available at http://lo
clean: ## Cleans build artifacts.
rm -rf public/ resources/ _tmp/

clean-all: ## Cleans both build artifacts and files sycned to content directory
clean-all: ## Cleans both build artifacts and files synced to content directory
rm -rf public/ resources/ _tmp/
rm -f content/en/events/community-meeting.md
rm -f content/en/events/meet-our-contributors.md
Expand Down Expand Up @@ -129,21 +128,19 @@ clean-all: ## Cleans both build artifacts and files sycned to content directory

production-build: ## Builds the production site (this command used only by Netlify).
$(BLOCK_STDOUT_CMD)
git submodule update --init --recursive --depth 1
hack/gen-content.sh
hugo \
--environment production \
--verbose \
--logLevel info \
--ignoreCache \
--minify

preview-build: ## Builds a deploy preview of the site (this command used only by Netlify).
$(BLOCK_STDOUT_CMD)
git submodule update --init --recursive --depth 1
hack/gen-content.sh
hugo \
--environment preview \
--verbose \
--logLevel info \
--baseURL $(DEPLOY_PRIME_URL) \
--buildDrafts \
--buildFuture \
Expand Down
131 changes: 0 additions & 131 deletions assets/scss/_variables.scss

This file was deleted.

2 changes: 2 additions & 0 deletions assets/scss/_variables_project.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$primary: #326ce5;
SayakMukhopadhyay marked this conversation as resolved.
Show resolved Hide resolved
$secondary: #303030;
SayakMukhopadhyay marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ baseURL: 'https://www.kubernetes.dev/'
title: Kubernetes Contributors
theme:
- docsy
themesDir: node_modules
enableRobotsTXT: true
enableGitInfo: false

Expand All @@ -13,7 +14,6 @@ enableMissingTranslationPlaceholders: true

disableKinds:
- taxonomy
- taxonomyTerm

# Highlighting config
pygmentsCodeFences: true
Expand Down Expand Up @@ -140,7 +140,7 @@ params:
# The responses that the user sees after clicking "yes" (the page was helpful) or "no" (the page was not helpful).
# yes = 'Glad to hear it! Please <a href="https://github.com/USERNAME/REPOSITORY/issues/new">tell us how we can improve</a>.'
# no = 'Sorry to hear that. Please <a href="https://github.com/USERNAME/REPOSITORY/issues/new">tell us how we can improve</a>.'

links:
# End user relevant links. These will show up on left side of footer and in the community page if you have one.
user:
Expand Down
15 changes: 10 additions & 5 deletions layouts/calendar/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<head>
{{ partial "head.html" . }}
<link href='{{ .Site.BaseURL }}/css/fullcalendar/main.min.css' rel='stylesheet' />
Expand All @@ -9,17 +9,22 @@
renderCalendar();
</script>
</head>
<body class="td-{{ .Kind }}">
<body class="td-{{ .Kind }}{{ with .Page.Params.body_class }} {{ . }}{{ end }}">
<header>
{{ partial "navbar.html" . }}
</header>
<div class="container-fluid td-outer">
<div class="td-main">
<div class="row flex-xl-nowrap">
<div class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
<aside class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
{{ partial "sidebar.html" . }}
</div>
<main class="col-12 col-md-9 col-xl-9 pl-md-5" role="main">
</aside>
<aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none">
{{ partial "page-meta-links.html" . }}
{{ partial "toc.html" . }}
{{ partial "taxonomy_terms_clouds.html" . }}
</aside>
<main class="col-12 col-md-9 col-xl-8 pl-md-5" role="main">
{{ partial "version-banner.html" . }}
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
{{ block "main" . }}{{ end }}
Expand Down
21 changes: 17 additions & 4 deletions layouts/calendar/list.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
{{ define "main" }}
<div class="td-content">
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
</header>
{{ .Content }}
{{ partial "section-index.html" . }}
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.GoogleAnalytics)) }}
Expand All @@ -15,5 +27,6 @@ <h1>{{ .Title }}</h1>
<br />
{{ partial "disqus-comment.html" . }}
{{ end }}
{{ partial "page-meta-lastmod.html" . }}
</div>
{{ end }}
16 changes: 9 additions & 7 deletions layouts/community/baseof.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<!doctype html>
<html lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<head>
{{ partial "head.html" . }}
</head>
<body class="td-{{ .Kind }}">
<body class="td-{{ .Kind }}{{ with .Page.Params.body_class }} {{ . }}{{ end }}">
<header>
{{ partial "navbar.html" . }}
</header>
<div class="container-fluid td-outer">
<div class="td-main">
<div class="row flex-xl-nowrap">
<div class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
<aside class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
{{ partial "sidebar.html" . }}
</div>
<div class="d-none d-xl-block col-xl-2 td-toc d-print-none">
</aside>
<aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none">
{{ partial "page-meta-links.html" . }}
{{ partial "toc.html" . }}
</div>
{{ partial "taxonomy_terms_clouds.html" . }}
</aside>
<main class="col-12 col-md-9 col-xl-8 pl-md-5" role="main">
{{ partial "version-banner.html" . }}
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
Expand All @@ -27,4 +29,4 @@
</div>
{{ partial "scripts.html" . }}
</body>
</html>
</html>
Loading