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

Closed
wants to merge 5 commits into from
Closed

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; also relevant to issue #44002

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
Copy link

netlify bot commented Nov 14, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 8dfe869
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/673ba4effcb7a90008d47324
😎 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.

Makefile Outdated
@@ -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

package.json Outdated
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",

Dockerfile Outdated

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 <lperkins@linuxfoundation.org>"
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"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure of the original intent, but typically people want the build output kept. This doesn't look like it would do that.

@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

@sftim
Copy link
Contributor Author

sftim commented Nov 16, 2024

That sounds like what I'd intended to do anyway. I'll try that.

@chalin
Copy link
Contributor

chalin commented Nov 16, 2024

Here's something along the lines of my last proposal, though it would need to be adapted to be used here:

If/once this gets merged, then we can see how it fits in the context of the Docsy upgrade.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2024
@sftim sftim force-pushed the 20241102_docsy_zero_four branch from 5a0e00e to f78b4d8 Compare November 18, 2024 14:05
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2024
@k8s-ci-robot k8s-ci-robot requested a review from Arhell November 18, 2024 14:05
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 18, 2024
@sftim sftim force-pushed the 20241102_docsy_zero_four branch from f78b4d8 to f31dc26 Compare November 18, 2024 14:16
@sftim sftim force-pushed the 20241102_docsy_zero_four branch from f31dc26 to a643668 Compare November 18, 2024 14:22
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2024
@sftim sftim force-pushed the 20241102_docsy_zero_four branch from a643668 to 8dfe869 Compare November 18, 2024 20:34
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2024
@chalin
Copy link
Contributor

chalin commented Nov 20, 2024

@sftim - will gladly take another look once this gets rebased to pick up merge of 0.3 and the container-build fix.

@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2024
@sftim
Copy link
Contributor Author

sftim commented Nov 20, 2024

Hmm, I think this needs a new approach.
/close

I hope to get time to revisit it.

@k8s-ci-robot
Copy link
Contributor

@sftim: Closed this PR.

In response to this:

Hmm, I think this needs a new approach.
/close

I hope to get time to revisit it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@chalin
Copy link
Contributor

chalin commented Nov 20, 2024

Hmm, I think this needs a new approach. /close

I hope to get time to revisit it.

@sftim - would you like for me to give it a try (for 0.4.x), or shall I wait for your next version of this PR. Either way, if it's this week, I'll find time to help.

@sftim
Copy link
Contributor Author

sftim commented Nov 21, 2024

@chalin it's a busy time at work - feel free to help, I'd / we'd appreciate it
You are welcome to cherry pick any of these commits, of course

@chalin chalin mentioned this pull request Nov 22, 2024
5 tasks
@chalin
Copy link
Contributor

chalin commented Nov 22, 2024

Great! FYI, I'll be working on:

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/L Denotes a PR that changes 100-499 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