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

Netlify build command cleanup #3628

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chalin
Copy link
Contributor

@chalin chalin commented Nov 17, 2023

This PR contains suggested improvements to the site build scripts and config.

  • Simplifies the netlify.toml build commands by using the NPM scripts. E.g., the production build command goes from:
    cd themes/docsy && git submodule update -f --init && npm install && cd ../.. && hugo --gc --minify
    to more the more concise yet equivalent:
    npm run build:production
  • Factors out common env var in netlify.toml
  • Adds NPM scripts that simplify building and serving the site

/cc @nate-double-u

Copy link

@chalin: GitHub didn't allow me to request PR reviews from the following users: nate-double-u.

Note that only kubeflow members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

This PR contains suggested improvements to the site build scripts and config.

  • Simplifies the netlify.toml build commands by using the NPM scripts. E.g., the production build command goes from:
cd themes/docsy && git submodule update -f --init && npm install && cd ../.. && hugo --gc --minify

to more the more concise yet equivalent:

npm run build:production
  • Factors out common env var in netlify.toml
  • Adds NPM scripts that simplify building and serving the site

/cc @nate-double-u

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/test-infra repository.

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chalin
Once this PR has been reviewed and has the lgtm label, please assign zijianjoy for approval. 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

Copy link

Hi @chalin. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.


[context.production.environment]
HUGO_VERSION = "0.119.0"
HUGO_ENV = "production"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting HUGO_ENV is no longer required.

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.

/ok-to-test

@chalin
Copy link
Contributor Author

chalin commented Nov 29, 2023

Anything left to be done here? /cc @thesuperzapper

Comment on lines -14 to -16
[context.branch-deploy.environment]
HUGO_VERSION = "0.119.0"
NODE_VERSION = "18"
Copy link
Member

Choose a reason for hiding this comment

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

@chalin Won't removing this prevent the old branches like https://github.com/kubeflow/kubeflow/tree/v1.7-branch, from being deployed, because we achieve this by using a CNAME record from:

  • v1-7-branch.kubeflow.org -> v1-7-branch--competent-brattain-de2d6d.netlify.app

I don't have access to the Netelify dashboard, so I can't see where those are being deployed from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thesuperzapper - from my understanding of how Netlify works, unless you back port this change to an older v1.x branch, the builds of other branches won't be affected.

For example, v1.7 has it's own netlify.toml file, https://github.com/kubeflow/website/blob/v1.7-branch/netlify.toml, with it's own env var values and commands:

website/netlify.toml

Lines 1 to 16 in b48a664

[build]
publish = "public"
command = "cd themes/docsy && git submodule update -f --init && cd ../.. && hugo --gc --minify"
[context.deploy-preview.environment]
HUGO_VERSION = "0.92.0"
NODE_VERSION = "16"
[context.production.environment]
HUGO_VERSION = "0.92.0"
HUGO_ENV = "production"
NODE_VERSION = "16"
[context.branch-deploy.environment]
HUGO_VERSION = "0.92.0"
NODE_VERSION = "16"

But, I could be wrong.

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 also don't have access to kubeflow.org's Netlify dashboard.

Copy link
Member

Choose a reason for hiding this comment

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

@james-jwu or @zijianjoy do you have access to Netelify for the Kubeflow website, so we can confirm how it is configured?

We probably also need to give access in some way to the CNCF for continuity purposes.

Comment on lines +5 to +6
command = "npm run build:production"
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that using context.production will still work?

I don't have access to the Netelify dashboard, so I can check, but based on Hugo's docs: https://gohugo.io/hosting-and-deployment/hosting-on-netlify/ they seem to suggest that context.production.environment is the right heading.

@james-jwu or @zijianjoy probably have access to Netelify?

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 using similar setups for the OTel and gRPC websites, e.g., see https://github.com/open-telemetry/opentelemetry.io/blob/5df8d080fe6997d1ee514b9f50f6880155276e5b/netlify.toml#L1-L6:

[build]
publish = "public"
command = "npm run seq -- build:preview diff:check"

[context.production]
command = "npm run seq -- build:production diff:check"

The .environment section is for setting environment variables only, not for setting other fields like command.

@thesuperzapper
Copy link
Member

@chalin Also, all our PR/historical branches are getting indexed by Google, we should fix that at the same time as this PR.

The goals would be:

  1. The main www.kubeflow.org site should be indexed
  2. All PR deploy-preview-XXXX--competent-brattain-de2d6d.netlify.app should NOT be indexed
  3. All other v1-7-branch.kubeflow.org sites should be NOT be indexed:
    • (these are just CNAME records pointing to the branch domains like v1-7-branch--competent-brattain-de2d6d.netlify.app)

I believe your changes here achieve 2, because you are setting -e dev in the hugo command, and because this is not "production", docsy adds <meta> no index tags.

We need to be careful about 1. Are you 100% confident that not setting -e production or HUGO_ENV=production is safe?

To achieve 3, we could set the HUGO_ENV from [context.branch-deploy.environment] to dev, but it will probably propagate faster if we use a robots.txt disallow on those domains (otherwise, the <meta> tags will take until Google next indexes each page).

@chalin
Copy link
Contributor Author

chalin commented Dec 5, 2023

I've created a separate issue to track the full extent of the indexing issue, since more work will need to be done outside of the scope of this PR:

@chalin chalin force-pushed the chalin-im-netlify-toml-cleanup-2023-14-17 branch from bebf9e8 to 619d3a1 Compare December 6, 2023 00:01
@chalin
Copy link
Contributor Author

chalin commented Dec 6, 2023

I believe your changes here achieve 2, because you are setting -e dev in the hugo command, and because this is not "production", docsy adds <meta> no index tags.

Correct.

We need to be careful about 1. Are you 100% confident that not setting -e production or HUGO_ENV=production is safe?

For reassurance, see https://discourse.gohugo.io/t/what-does-setting-hugo-env-to-production-do/24669/2. Also, since the site uses hugo.IsProduction, we're good.

To achieve 3, we could set the HUGO_ENV from [context.branch-deploy.environment] to dev, but it will probably propagate faster if we use a robots.txt disallow on those domains (otherwise, the <meta> tags will take until Google next indexes each page).

I'll answer this in #3645.

"devDependencies": {
"autoprefixer": "^10.4.0",
"postcss": "^8.4.1",
"hugo-extended": "^0.119.0",
Copy link
Member

Choose a reason for hiding this comment

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

@chalin are you sure that this is the correct way to set the Hugo version on Netelify?

Because the Netelify website suggests using HUGO_VERSION, which is what we were previously doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what we're using on other sites such as OTel: https://github.com/open-telemetry/opentelemetry.io/blob/299ad7bb24488e39eb17d43393dd05f513321253/package.json#L89

The advantage of using hugo-extended is that you'll never have to worry again about using the right version of Hugo even if (at some point in the future) you work on branches of older versions of the docs since NPM install and the NPM build commands will naturally use the version of Hugo needed for that specific branch/commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants