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

Bump Docsy to 0.4.x #48722

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

sftim
Copy link
Contributor

@sftim sftim commented Nov 14, 2024

This PR upgrades to a newer version of Docsy: 0.4.0 (preview)

Fixes #32905

Importantly, the container image now installs dependencies using NPM, not a Git submodule.
In the testing I've done, I haven't found any different look or behavior that still needs fixing.

/area web-development

This PR incorporates the commits from PR #48721

@k8s-ci-robot k8s-ci-robot added area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 14, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from sftim. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Nov 14, 2024
This was referenced Nov 14, 2024
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 14, 2024
@sftim sftim mentioned this pull request Nov 14, 2024
Copy link

netlify bot commented Nov 14, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 5a0e00e
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/67365eee9ba6c800085c1cfd
😎 Deploy Preview https://deploy-preview-48722--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@Arhell Arhell left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 425988602e055e2c0ebf8c13b2c9ae6e88258acc

Copy link
Contributor

@chalin chalin left a comment

Choose a reason for hiding this comment

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

With the changes suggested below, we can then successfully run both local and container build and serve.

@@ -34,7 +34,7 @@ module-init: ## Initialize required submodules.
all: build ## Build site with production settings and put deliverables in ./public

build: module-check ## Build site with non-production settings and put deliverables in ./public
hugo --cleanDestinationDir --minify --environment development
hugo --cleanDestinationDir --minify --environment development --themesdir node_modules
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
hugo --cleanDestinationDir --minify --environment development --themesdir node_modules
hugo --cleanDestinationDir --minify --environment development --themesDir node_modules

Comment on lines +3 to 7
"dependencies": {
"docsy": "github:google/docsy#v0.4.0"
},
"devDependencies": {
"autoprefixer": "^9.8.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

All are devDependencies:

Suggested change
"dependencies": {
"docsy": "github:google/docsy#v0.4.0"
},
"devDependencies": {
"autoprefixer": "^9.8.4",
"devDependencies": {
"autoprefixer": "^9.8.4",
"docsy": "google/docsy#semver:0.4.0",


FROM docker.io/library/golang:1.23.0-alpine3.20
# was previously based on his Dockerfile at
# https://github.com/jguyomard/docker-hugo/blob/master/Dockerfile.

LABEL maintainer="Luc Perkins <[email protected]>"
Copy link
Contributor

Choose a reason for hiding this comment

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

This line causes an error for me -- I have to comment it out.
Btw, Luc isn't maintainer anymore, and no longer works for the LF/CNCF.

npm && \
npm install -D autoprefixer postcss-cli
WORKDIR /opt/npm
RUN npm install -D -g autoprefixer postcss-cli google/docsy#semver:0.4.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RUN npm install -D -g autoprefixer postcss-cli google/docsy#semver:0.4.0
RUN npm install -g autoprefixer postcss-cli google/docsy#semver:0.4.0

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually found a better way (IMHO), which copies the project's packages files rather that duplicating dependencies here. I'll share that tomorrow, I'm calling it a day.

@@ -97,11 +97,11 @@ docker-push: ## Build a multi-architecture image and push that into the registry
rm Dockerfile.cross

container-build: module-check
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development"
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development --themesDir /usr/local/lib/node_modules"
Copy link
Contributor

Choose a reason for hiding this comment

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

/src is read-only so we can't run npm ci here (and don't need to):

Suggested change
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development --themesDir /usr/local/lib/node_modules"
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "hugo --minify --environment development --destination /tmp/hugo --themesDir /usr/local/lib/node_modules --noBuildLock"

@chalin
Copy link
Contributor

chalin commented Nov 16, 2024

Actually, here's the proposal I made earlier that copies the website's NPM package files for use in the container image; this avoids a global install (which isn't usually a good thing for non CLI packages), and keeps things more DRY:

diff --git a/.dockerignore b/.dockerignore
index 1d085cacc9..be2f2c26c4 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1 +1,3 @@
 **
+!package.json
+!package-lock.json
diff --git a/Dockerfile b/Dockerfile
index 9e07877af0..9cde91c750 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -25,8 +25,11 @@ RUN apt-get update && apt-get install -y \
 
 RUN rm -rf /var/cache/* # partial cleanup
 
-WORKDIR /opt/npm
-RUN npm install -g autoprefixer postcss-cli google/docsy#semver:0.4.0
+RUN mkdir -p /npm-dep
+COPY package.json package-lock.json /npm-dep
+
+WORKDIR /npm-dep
+RUN npm install
 
 RUN useradd -m --user-group -u 60000 -d /var/hugo hugo && \
     chown -R hugo: /var/hugo && \
diff --git a/Makefile b/Makefile
index e5716e1193..c9e52333da 100644
--- a/Makefile
+++ b/Makefile
@@ -101,7 +101,7 @@ container-build: module-check
 
 # no build lock to allow for read-only mounts
 container-serve: module-check ## Boot the development server using container.
-       $(CONTAINER_RUN) --cap-drop=ALL --cap-add=AUDIT_WRITE --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 -p 1313:1313 $(CONTAINER_IMAGE) hugo server --buildFuture --environment development --themesDir /usr/local/lib/node_modules --bind 0.0.0.0 --destination /tmp/hugo --cleanDestinationDir --noBuildLock
+       $(CONTAINER_RUN) --cap-drop=ALL --cap-add=AUDIT_WRITE --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 -p 1313:1313 $(CONTAINER_IMAGE) hugo server --buildFuture --environment development --themesDir /npm-dep/node_modules --bind 0.0.0.0 --destination /tmp/hugo --cleanDestinationDir --noBuildLock
 
 test-examples:
        scripts/test_examples.sh install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bootstrap and Font Awesome (as part of Docsy) are deprecated
4 participants