Skip to content

Fix site URL in links when running locally with docker compose or DevContainer #3029

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

Merged

Conversation

nathanpainchaud
Copy link
Contributor

Fixes #3028.

Removing the overrides makes jekyll default to the serve URL, rather than use the build URL
@rjzupkoii
Copy link
Collaborator

Thanks for this change!

@rjzupkoii rjzupkoii merged commit d4e74ea into academicpages:master May 11, 2025
@nathanpainchaud nathanpainchaud deleted the fix/docker-serve-url branch May 12, 2025 09:03
@msk-nightly
Copy link
Contributor

msk-nightly commented May 21, 2025

For some reason, this change doesn't allow me to load the site properly from localhost:4000 but, rather, I specifically have to go to 0.0.0.0:4000. Also, when I checked separately, this results in the static files generated in the _site directory to all have 0.0.0.0 in the links.

@nathanpainchaud
Copy link
Contributor Author

nathanpainchaud commented May 21, 2025

when I checked separately, this results in the static files generated in the _site directory to all have 0.0.0.0 in the links.

The 0.0.0.0 URL in the links (instead of localhost) is expected, because that's the URL that is configured in the docker commands, i.e. jekyll serve -H 0.0.0.0 -w.

For some reason, this change doesn't allow me to load the site properly from localhost:4000 but, rather, I specifically have to go to 0.0.0.0:4000.

When I manually switch 0.0.0.0 for localhost I am still able to load the expected page. So localhost should still work, it's just not the default URL.

For context, when testing this PR, I tried removing the -H 0.0.0.0 to fallback the default localhost, but in that case I was not able to load the site anymore. I've seen 0.0.0.0 used in many tutorials for setting up Jekyll websites within docker, so I assumed it was common practice to work well with docker. But I didn't have the knowledge/time to understand why the default localhost is not working with docker.

When you say

this change doesn't allow me to load the site properly from localhost:4000

do you mean that you were able to previously? Because in my experience the previous configuration was also serving to 0.0.0.0 (and not localhost), and the links pointed to deployment URL, not any local server.

@msk-nightly
Copy link
Contributor

msk-nightly commented May 22, 2025

Thank you for the prompt response. Yes, I do understand but before the jekyll serve command was added to the docker compose file, I was able to load the site properly (entire UI) from localhost:4000 and 0.0.0.0:4000. Now, it loads properly from 0.0.0.0:4000 only and loads without the proper styling and UI from localhost:4000 (weirdly enough). Could be some other issue. Thank you again for taking the time to check and reply thoroughly.

@nathanpainchaud
Copy link
Contributor Author

Yes, I do understand but before the jekyll serve command was added to the docker compose file [...]

@msk-nightly I think it would help if you could point to a specific commit that worked like you expected. Because this PR did not introduce the jekyll serve command to the docker compose file. jekyll serve was already there, and I've just modified the arguments.

I didn't test the docker integration prior to ef8e08b (the version that I modified), so I can't comment on whether or not serving at localhost worked better before that.

@msk-nightly
Copy link
Contributor

Thank you for your prompt response. I understand. You are correct in mentioning that this PR did not introduce the jekyll serve command to the docker compose file but you introduced it in a previous PR corresponding to the commit 6f5947f. I just mentioned it here because it's the latest one in that series. Also, while I'm not sure what the effect of these two commits is due to my own lack of knowledge regarding Dockerfiles, it worked just fine before - which I know since I've been keeping my repo synced. Thanks again.

@nathanpainchaud
Copy link
Contributor Author

You are correct in mentioning that this PR did not introduce the jekyll serve command to the docker compose file but you introduced it in a previous PR corresponding to the commit 6f5947f.

@msk-nightly The commit you point to IS the commit introduced by the PR... The PR added two commits, 6f5947f with the changes, and d4e74ea which is just a merge commit.
Your way of phrasing things confused me. The changes did not introduce the jekyll serve command, they simply changed the options. But I assume now that's what you mean by "introduce"?

Also, while I'm not sure what the effect of these two commits is due to my own lack of knowledge regarding Dockerfiles, it worked just fine before - which I know since I've been keeping my repo synced.

Tthe PR fixed an issue that WAS there before (detailed in #3028), so things were apparently not working fine for all configurations...

If you want to investigate this further, I'd suggest you open a new issue describing more clearly the issue you're experiencing (what styling is not loading?) and provide details about your setup (e.g. docker, jekyll & ruby versions). Maybe then other people will be able to help. As things stand, I can't replicate your issues with up-to-date docker and jekyll...

@msk-nightly
Copy link
Contributor

msk-nightly commented May 23, 2025

My apologies. It seems you're right. The command was introduced to the docker-compose.yaml file by one Adrian Auer in commit 37a2589 and not you. I mixed things up in checking the commit history. So, things were working fine before that with up-to-date docker and jekyll. I now stand corrected. Thank you for your time and patience in this thread. I'll move this elsewhere, God willing.

Arghyadatta pushed a commit to Arghyadatta/arghyadatta.github.io that referenced this pull request Jun 11, 2025
…-serve-url

Fix site URL in links when running locally with `docker compose` or DevContainer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

URL links when serving with Docker compose or DevContainer use deployment URL
4 participants