Knowledge-Graphs-Book / HTML-Book

Other
36 stars 7 forks source link

Migrate kgbook.org hosting to Github pages #36

Closed aidhog closed 1 year ago

aidhog commented 1 year ago

Currently the kgbook.org web server is a machine in the University of Chile, but it might be more convenient to just host the site on Github pages? That way, edits to the HTML will go live directly after a minute or two.

The downside is that Github works for static content, with no support for PHP. But we're mainly using PHP to statically compile the HTML in any case.

If we want to migrate, the first step would be to rename the HTML-Book repo to Knowledge-Graphs-Book (the same as the org). Github should redirect anything from the old name to the new one. Then the book will appear at https://knowledge-graphs-book.github.io/. We then need to do a few configs to send kgbook.org there, and set up HTTPS.

What do you think?

miselico commented 1 year ago

We should be able to use a github runner to run the PHP code. I think the renaming of the repository is no longer necessary on github. Also https is done transparantly by changing the setting on github.

aidhog commented 1 year ago

Seems that I don't have access to the settings of the repo to check this out, so it might require @Antoine-Zimmermann to set it up if we decide to go ahead.

Antoine-Zimmermann commented 1 year ago

I looked at how runners work and it needs to be self hosted by the one who creates it. I won't host the runner myself. So I added Aidan as maintainer of this repo. I suppose this should allow him to add a self-hosted runner on his machine and connect it to this repo.

miselico commented 1 year ago

I do not think a self hosted runner is needed, the ones at gihub should suffice. Because this is a public repository, it should also not take from your runner budget. I will give it a try in a fork later this week.

Antoine-Zimmermann commented 1 year ago

I do not know how runners work, but at least from the Settings, section "Runners", I can only create self-hosted runners.

miselico commented 1 year ago

I am partially there. Working on https://github.com/miselico/HTML-Book

Could you tell how the php is exactly compiled? I should be something like

php book.php > index.html

Are there some other arguments needed? Also, are there more dependencies not included in the repository?

miselico commented 1 year ago

The workflow seems functional now. The only thing still needed are the steps to build. I would need:

  1. The dependencies for PHP.
  2. The steps executed to create the index.html
Antoine-Zimmermann commented 1 year ago

My workflow is bizarre and I do not explicitly compile the file in this way. I go to the book.php in my browser on my own web space where I cloned the repo. This allows me to check visually that it works, that there is no obvious error in the output (because I don't trust myself when I edit code). Then I save, from my browser, the web page in HTML. I never made the compilation from explicit invocation of the PHP command on my computer.

miselico commented 1 year ago

The hosting on github seems to work fine: http://www.cochez.nl/HTML-Book/

miselico commented 1 year ago

@Antoine-Zimmermann could you privately share me the output of phpinfo() ? Then I can see what is required.

I have to fiddle a bit, but I am pretty sure I can set it up such that if you go to kgbook.org/beta/branchname , then you get the version which is currently in that branch. Or something similar with pull requests.

If that works, then you push to master and the changes get applied on kgbook.org

miselico commented 1 year ago

Also, do you have a bibtexbrowser.local.php file in your local setup?

Antoine-Zimmermann commented 1 year ago

Re. phpinfo(), I can't use it on this server. I may ask for info from the admin. Re. bibtexbrowser.local.php, I don't have such a file.

miselico commented 1 year ago

The main thing I seem to need is the content of $_GET It appears bibtexbrowser expects there to be something, but I cannot figure it out.

For my clarity, is there only one page you request to get the whole thing compiled, including the bibliography?

On Mon, Mar 6, 2023, 23:00 Antoine Zimmermann @.***> wrote:

Re. phpinfo(), I can't use it on this server. I may ask for info from the admin. Re. bibtexbrowser.local.php, I don't have such a file.

— Reply to this email directly, view it on GitHub https://github.com/Knowledge-Graphs-Book/HTML-Book/issues/36#issuecomment-1457073324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5VU255RLJFXFE7LD65FOTW2ZNBFANCNFSM6AAAAAAVPZBCKA . You are receiving this because you commented.Message ID: @.***>

Antoine-Zimmermann commented 1 year ago

bibtexbrowser was originally made to create browsable HTML bibliographies from BibTeX. With $_GET, you can change display parameters in various ways. But I don't use this at all. I created my own way of displaying the bibliography.

Antoine-Zimmermann commented 1 year ago

I made an experiment. I started from a Linux Mint 22.04 that does not have PHP installed. I did sudo apt-get install php, which installed PHP 7.4. I compiled book.php with php book.php > index.html, which did not work. I had to enable the extension mbstring, which I did via sudo apt-get install php-mbstring. Then book.php compiled but a lot of PHP code was not interpreted. In fact, I'm using a lot of inline <? ... ?> instead of <?php ... ?>, which works if you have abbreviated PHP tag enabled. Instead of changing the PHP config, I changed all the <? into <?php. It works. While doing so, I found 2 minor bugs in references.php that I fixed.

Antoine-Zimmermann commented 1 year ago

I will push these changes later, I currently get a Git error but no time to take care of this now.

Antoine-Zimmermann commented 1 year ago

I pushed changes. Many files are affected. It should now compile to HTML very nicely on most PHP processors.

miselico commented 1 year ago

Cool, thank you! If it works from a fresh install, it should work for me as well. I will try it out soon.

miselico commented 1 year ago

It seems to work! A main issue was that I needed to downgrade PHP from 8.2 to 7.4. The 7.4 version is EOL, but I don't think it is a real issue. This is not running as a public facing service, only for the compilation.

miselico commented 1 year ago

As mentioned in the pull request, this is working on my fork now. I have the fork here: https://github.com/miselico/HTML-Book , whenever a push to a branch is made, it compiles and places it in https://github.com/miselico/HTML-Book-staging , for example the green-background branch.

I now hosted them under my own domain in

https://www.cochez.nl/HTML-Book/ https://www.cochez.nl/HTML-Book-staging/green-background/

aidhog commented 1 year ago

Thank you all, for the advances. Should we go ahead then and switch the hosting?

@Antoine-Zimmermann, can you add @miselico as a maintainer of this repo so he can help to configure it? Once it's ready, let me know and I can switch the domain over (if you all agree).

miselico commented 1 year ago

@aidhog @Antoine-Zimmermann wrote me in private that he progressed already. I am now merging the workflow into the repository and make sure it works.

The only missing part is getting the DNS configured, I think.

miselico commented 1 year ago

The workflow works. It built the github pages. When I created the branch https://github.com/Knowledge-Graphs-Book/HTML-Book/tree/test-staging , the compiled version was created in https://github.com/Knowledge-Graphs-Book/HTML-Book-staging

Antoine-Zimmermann commented 1 year ago

Thanks, Michael. There is probably nothing more to configure on this repo regarding this issue, but I added you nonetheless as maintainer.

miselico commented 1 year ago

From what i can see, things look configured correctly. so, I think we should go ahead with the DNS change. @aidhog start from step 5 here: https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#configuring-an-apex-domain

After that we should also consider doing https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/verifying-your-custom-domain-for-github-pages

aidhog commented 1 year ago

Thanks all! I applied the DNS configuration but reached a dead-end in verifying the HTTPS, and visiting the site was blocked by a Privacy error, so I reverted for now to the current hosting.

In order to follow:

https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/verifying-your-custom-domain-for-github-pages

for this organization, I would need to become a maintainer of the Knowledge-Graph-Book organisation itself (I do not have access to the settings to verify a domain) or @Antoine-Zimmermann, you would need to follow the steps indicated there, let me know what TXT record to add to which sub-domain, and then verify once it has been added. But it would probably be easier to add me as maintainer to the org. :)

miselico commented 1 year ago

Can you try again? Most likely this is because the DNS was not yet updated rather than anything else.

aidhog commented 1 year ago

Ah, I understood that the verification step I could not do was for HTTPS, but I see it's not. How is the HTTPS part configured?

I checked with dig and everything was up to date. But if you're around for a couple of minutes, I can change the domain config again?

miselico commented 1 year ago

Https is configured already. This is done by github.

miselico commented 1 year ago

I am around now, but I also do not have full access. But, I can do some tests.

aidhog commented 1 year ago

Okay, will change now! (I think the problem was probably with my browser having cached something.)

aidhog commented 1 year ago

Okay, changed! DiG seems to be fine.

(I set the www. subdomain with A records rather than a CNAME as https://knowledge-graphs-book.github.io/ 404's.)

miselico commented 1 year ago

Put it anyway with a CNAME

miselico commented 1 year ago

But A records should also work. dig @y.ns.joker.com. kgbook.org. +nostats +nocomments +nocmd gives me the github nameservers.

miselico commented 1 year ago

It seems to work now.

aidhog commented 1 year ago

Changed the www. to CNAME but can change it back.

Still not working for me ("Privacy error"). Maybe still propagating, or something cached in my browser? Will check.

aidhog commented 1 year ago

Not my browser (tried in Edge, shudder), so maybe something still propagating. Still getting a "Privacy error".

Are both kgbook.org and www.kgbook.org working for you? If the latter is not working, could switch back to A records.

miselico commented 1 year ago

I am making a small change to check whether I am really getting the github version. I am using kgbook.org , that is also how github is configured.

aidhog commented 1 year ago

If I ignore the privacy warnings, www.kgbook.org seems to work through CNAME, so that seems fine.

Is the connection showing as secure for you? Still showing as "Not secure" on my end.

miselico commented 1 year ago

It is not secure and it also does not give me the updated version created in the workflow. My DNS is not yet updated, though. I only get the updated IP addresses when I ask the NS directly.

miselico commented 1 year ago

I suggest we wait some time for the DNS to propagate. In the worst case the website is down for a few hours.

aidhog commented 1 year ago

Sounds good! In Edge kgbook.org is now secure for me (though I do not see your github comment in the source from the last commit, a ping gives me a github IP).

Chrome still gives me a privacy error, even in Incognito Mode. Something must be cached somewhere but I can't find it.

www.kgbook.org is still not secure in Edge nor Chrome.

I guess we wait and it should resolve itself eventually, thanks!

Antoine-Zimmermann commented 1 year ago

I got an email related to the Knowledge-Graphs-Book organisation telling me to "Please verify your Pages domain (ACTION NEEDED)". With this, I can verify a domain. But following your discussion, I am not sure if it is still needed. Should I proceed?

miselico commented 1 year ago

@Antoine-Zimmermann
Could you

you may need to remove and re-add your custom domain to your site's repository to trigger the process of enabling HTTPS.

See https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/troubleshooting-custom-domains-and-github-pages

miselico commented 1 year ago

FYI: the DNS works by now, it is only the HTTPS left.

I do get the github version of the page if I skip the HTTPS check.

Antoine-Zimmermann commented 1 year ago

It works for me now. I think we are done with this issue. Thanks a lot, Michael, for the support.

miselico commented 1 year ago

@Antoine-Zimmermann can you also turn github pages on for the staging repository (using github pages, actions is not needed)? Mine looks like this:

Screenshot from 2023-03-12 00-32-33

You should not need to put a URL anywhere, I think it will use kgbook.org by default.

aidhog commented 1 year ago

All seems to be working well here as well, many thanks all!

Let me know if there's some other domain config needed.

Antoine-Zimmermann commented 1 year ago

@miselico, pages setup on the staging repo

miselico commented 1 year ago

This all seems working now. Staging is at https://knowledge-graphs-book.github.io/HTML-Book-staging/<branchname>/ e.g., https://knowledge-graphs-book.github.io/HTML-Book-staging/test-staging/ I suggest we prevent direct pushing to main now. This means people create a branch first and see what it looks like in the staging environment before merging it into the main branch.