floryn90 / docker-hugo

Truly minimal Docker images for Hugo open-source static site generator.
https://hub.docker.com/r/floryn90/hugo
MIT License
31 stars 1 forks source link

`ext-alpine-onbuild` tag does not work with the `enableGitInfo` flag #75

Closed Timmy1e closed 4 months ago

Timmy1e commented 4 months ago

I have the following Docker build stage:

FROM docker.io/floryn90/hugo:ext-alpine-onbuild AS build
ENV HUGO_CMD="--minify --enableGitInfo --verbose"
ENV HUGO_ENV_ARG="production"

The site builds successfully, but it doesn't enable Git info.

I've tried manually adding Git.

RUN apk add --no-cache git

Either way Hugo throws the following warning:

WARNING: current commit information was not captured by the build: git was not found in the system: exec: "git": executable file not found in $PATH
floryn90 commented 4 months ago

hi @Timmy1e ,

Just tested the onbuild on my side using the latest onbuild image and all is working as expected.

Could you please take a look here: https://github.com/floryn90/docker-hugo?tab=readme-ov-file#using-onbuild-image

Also, if possible, could you please share your full dockerfile that you're using to build the website?

Timmy1e commented 4 months ago

This is the Dockerfile for my project. I originally saw this issue on the Gitlab CI for my project.

I just tried it locally, where it didn't print this warning, but it also didn't add the Git info.

Locally I'm using Docker 25.0.3 with Buildx 0.12.1. On Gitlab CI it's using the Docker latest tag.

# Stage 1, build using automated build
FROM docker.io/floryn90/hugo:ext-alpine-onbuild AS build
ENV HUGO_CMD="--minify --enableGitInfo --verbose"
ENV HUGO_ENV_ARG="production"

# Manually install Git?
#RUN apk add --no-cache git

# Stage 2, final
FROM docker.io/nginx:mainline-alpine as final

# Set the work dir
WORKDIR /usr/share/nginx/html/

# Clean the default public folder
RUN rm -fr * .??*

# NGINX configuration
COPY .docker/nginx.conf   /etc/nginx/conf.d/default.conf
EXPOSE 80

# Finally, copy the "target" folder generated by Hugo in the previous stage into the public fold of Nginx
COPY --from=build /target /usr/share/nginx/html
Timmy1e commented 4 months ago

I've uploaded the logs for a Gitlab CI run in this Gist.

Timmy1e commented 4 months ago

So after a bunch of testing and Googling, it's a known issue that Docker in Gitlab CI just sort of prints that message. I also had my theme misconfigured so the Git features weren't showing up.

So the Gitlab CI log lead me down the wrong trail, and there is nothing wrong with the tags. My apologies. I'm closing this issue.