-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Document usage of official Docker image #2741
base: master
Are you sure you want to change the base?
Conversation
It would be good if we could test the commands and functionality for each operating system.
Note that one of the documented prerequisites, at least on Linux, is creation of the Hugo cache directory. When testing locally on Linux, if
Command to create the Hugo cache directory:
TestingThe site that we are using tests these these features and capabilities:
Commands for testing on each operating system: BSD
Linux
macOS
Windows (use Powershell to run these commands)
Footnotes
|
987ac24
to
1663ed5
Compare
@bep If you have the time and inclination, I would appreciate a review and testing of the Docker instructions for macOS: As noted in my previous comment, the Linux and Windows instructions work great. I have no interest in firing up a BSD VM, so that information will be published untested. |
1663ed5
to
02a6421
Compare
Your test site fails on my ARM64 MacBook (I'm pretty sure I tested a site with Dart Sass on ...). The error message is clear and simple to understand, though. I have created a new milestone and will try to fix this/these soon: https://github.com/gohugoio/hugo/milestone/313 Edit in:
|
OK, the image in 0.136.2 looks good to me on MacOS (ARM64) for the test site above. Note that both of these now work:
|
I haven't looked at the latest Dockerfile, but why would I use the second one (no persistent cache). |
I wouldn't, but for small/simple blogs it does not make much difference in build speed ... As to documentation I would just document the |
02a6421
to
fdfb55e
Compare
On hold pending resolution of gohugoio/hugo#12970 and gohugoio/hugo#12971. Once resolved, test all operating systems without creating the cacheDir to see if that step is still required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using a volume instead of a bind mount for the hugo cache:
docker volume create hugo_cache
docker run -v hugo_cache:/cache ...
You generally don't want to mix cache/dependencies for host and containers since they might run different OSes, which can cause problems.
The same is true for node_modules. Mounting node_modules from the host to a container can easily result in errors, and likewise if you generate node_modules in a container with a bind mount, those node_modules files probably won't work if you try to run hugo directly on the host.
It would probably be good to show how to extend the Hugo image to install node dependencies with a Dockerfile.
FROM ghcr.io/gohugoio/hugo:latest
COPY --chown=hugo:hugo package*.json .
RUN npm ci
And instead of docker run
, we could use a compose file:
services:
server:
build:
context: .
ports:
- 1313:1313
command: ["server", "--bind", "0.0.0.0"]
volumes:
- ".:/project"
- "/project/node_modules" # ignore node_modules
- "hugo_cache:/cache" # persistent cache volume
volumes:
hugo_cache:
@dvdksn @bep Latest test results... LinuxWith or without a pre-existing cache directory, this works:
Without a pre-existing cache directory, this fails:
log
Use "hugo server [command] --help" for more information about a command. Error: command error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: go: github.com/jmooring/[email protected]: mkdir /cache/modules: permission denied
WindowsWith a pre-existing cache directory, this fails:
log
Without a pre-existing cache directory, this also fails:
log
|
For the Linux case, where the directory is created automatically by The On Docker Desktop, that is not an issue, because the directories are created wiht UID and GID mapping configured. So The Windows issue I'm not sure about... I don't have a Windows machine that I can test with and I can't reproduce it otherwise. Are |
@dvdksn I ran these commands on Windows. On the host neither the cacheDir nor node_modules existed before running the test. Note that I removed the cache mount from the docker command.
log
|
The Windows test started passing again, and I'm not sure what changed. |
Closes #2727
Previews: