hugomods / .github

0 stars 0 forks source link

Docker container "hugo [...]" commands not working #9

Closed quinlanharsch closed 3 months ago

quinlanharsch commented 3 months ago

Discussed in https://github.com/orgs/hugomods/discussions/8

Originally posted by **quinlanharsch** July 27, 2024 Hello! I don't usually ask questions on forums like this, but I've hit a wall and can't find information on this anywhere :/ I'm running a small home server for myself and want to host my blog on it. It's running Debian, with every utility on it as its own docker container. Everything is reachable from my domain via cloudflared and nginx proxy managers, both containerized. I was able to pull the `std` image and everything is working well enough. I'm having trouble where the base url is still localhost, and I was hoping to be able to resolve that by adding a `--baseURL ` flag. My issue is I'm having the **opposite** problem as the Troubleshooting page on the docs. This support article describes how the `server` command might not work, but `hugo server` will. `hugo server`, `npm i`, `server --baseURL [...]`, and a couple others I've tried don't work. Just `server` **does**. https://docker.hugomods.com/docs/troubleshooting/#unknow-command-or-module Here is my compose file ```yml name: festive_signe services: main_app: cpu_shares: 10 command: - hugo server container_name: Hugo deploy: resources: limits: memory: 256M hostname: Hugo image: hugomods/hugo:latest labels: icon: https://icon.casaos.io/main/all/hugo.png ports: - target: 1313 published: "1313" protocol: tcp restart: unless-stopped volumes: - type: bind source: /media/devmon/sdb1-usb-Realtek_RTL9210B/DATA/Documents/quinlan-site target: /src - type: bind source: /media/devmon/sdb1-usb-Realtek_RTL9210B/DATA/AppData/hugo/hugo_cache target: /tmp/hugo_cache devices: [] cap_add: [] environment: [] network_mode: bridge privileged: false ``` Error log ```log Node.js v22.4.1 node:internal/modules/cjs/loader:1222  throw err; ^ Error: Cannot find module '/src/hugo server' at Module._resolveFilename (node:internal/modules/cjs/loader:1219:15) at Module._load (node:internal/modules/cjs/loader:1045:27) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:215:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5) at node:internal/main/run_main_module:30:49 { code: 'MODULE_NOT_FOUND', requireStack: [] } ```
razonyang commented 3 months ago

If you're declaring command as an array, then separate args and their values by new lines.

services:
  main_app:
    # ...
    # command: hugo server --bind 0.0.0.0
    command:
      - hugo
      - server
      - --bind
      - 0.0.0.0
    # ...

See https://docs.docker.com/compose/compose-file/05-services/#command for details.

quinlanharsch commented 3 months ago

Thank you so much. This was the problem. I think the real issue is I needed to host it on an actual webserver. I pulled an Apache httpd image and have it running on that, and can use this to build the image.

Appreciate you showing me this though in case I need it going forward. You rock!

quinlanharsch commented 3 months ago

:)