admin管理员组

文章数量:1404595

I have the following Dockerfile and compose.yaml to build and serve my Zola website:

# Stage 1: Build the site with Zola
FROM ghcr.io/getzola/zola:v0.20.0 AS build
ARG BASE_URL=";
COPY . /project
WORKDIR /project
RUN ["zola", "build", "--base-url", "$BASE_URL"]

# Stage 2: Serve the site with Static Web Server
FROM ghcr.io/static-web-server/static-web-server:2 AS server
WORKDIR /
COPY --from=build /project/public /public
services:
  zola:
    build:
      context: .
      target: server
      args:
        BASE_URL: "http://localhost:8000"
    develop:
      watch:
        - path: .
          action: rebuild
    ports:
      - "8000:80"

When I build with docker compose build --no-cache I see in the log statements:

=> [zola build 4/4] RUN ["zola", "build", "--base-url", "http://localhost:8000"]                   0.1s

This shows that the ARG was read from compose.yaml and used when executing zola build.

However when I go to http://localhost:8000 and inspect anything that uses get_url I see that the base url is the name of the ARG, $BASE_URL. For example, in my base.html I have the following line of code:

<link rel="stylesheet" href="{{ get_url(path="base.css") }}">

When I inspect the contents of the build inside of the Docker container the href has the value "$BASE_URL/base.css" instead of "http://localhost:8000/base.css".

I've tried every combination of ARG and ENV in both theDockerfile and compose.yaml and am unable to have the --base-url parameter work. I am starting to think it has to be an issue witht the Zola image rather than Docker, but would like to confirm I haven't made any mistakes before I create an issue for this.

本文标签: baseurl flag for Zola CLI doesn39t work in DockerStack Overflow