Code Monkey home page Code Monkey logo

docker-hugo's Introduction

Hugo Docker Image

Docker Automated build Docker Build Status Docker Pulls Image Info

Hugo is a fast and flexible static site generator, written in Go. Hugo flexibly works with many formats and is ideal for blogs, docs, portfolios and much more. Hugo’s speed fosters creativity and makes building a website fun again.

This Lightweight Docker Image is based on Alpine, and comes with rsync for Continuous Deployment.

Get Started

Print Hugo Help:

docker run --rm -it jguyomard/hugo-builder hugo help

Create a new Hugo managed website:

docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo new site mysite
cd mysite

# Now, you probably want to add a theme (see https://themes.gohugo.io/):
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke;
echo 'theme = "ananke"' >> config.toml

Add some content:

docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo new posts/my-first-post.md

# Now, you can edit this post, add your content and remove "draft" flag:
xdg-open content/posts/my-first-post.md

Build your site:

docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo

Serve your site locally:

docker run --rm -it -v $PWD:/src -p 1313:1313 -u hugo jguyomard/hugo-builder hugo server -w --bind=0.0.0.0

Then open http://localhost:1313/ in your browser.

To go further, read the Hugo documentation.

Bash Alias

For ease of use, you can create a bash alias:

alias hugo='docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo'
alias hugo-server='docker run --rm -it -v $PWD:/src -p 1313:1313 -u hugo jguyomard/hugo-builder hugo server --bind 0.0.0.0'

Now, you can use hugo help, hugo new foo/bar.md, hugo-server -w, etc.

Supported tags

The latest builds are:

A complete list of available tags can be found on the docker store page.

Users

By default, this docker image run as the root user. This makes it easy to use as base image for other Dockerfiles (switching back and forth adds extra layers and is against the current best practices advised by Docker). Most (all official?) base images leave the default user as root.

However, this docker image also define a non-root user hugo (UID 1000, GID 1000) which can be switched on at run time using the --user flag to docker run.

docker run --rm -it -v $PWD:/src --user hugo jguyomard/hugo-builder hugo

You can also change this according your needs, by setting another UID/GID. For instance, to run hugo with user www-data:www-data (UID 33, GID 33) :

docker run --rm -it -v $PWD:/src -u 33:33 jguyomard/hugo-builder hugo

Extras

The extras tag adds additional tools and packages:

  • py-pygments

To use this version:

docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder:extras hugo

Continuous Deployment

I use this Docker image for Continuous Deployment. You can find some CI config examples in the ci-deploy directory.

This Docker image also comes with:

  • rsync
  • git
  • openssh-client
  • minify

Issues

If you have any problems with or questions about this docker image, please contact me through a GitHub issue. If the issue is related to Hugo itself, please leave an issue on the Hugo official repository.

Contributing

You are invited to contribute new features, fixes or updates to this container, through a Github Pull Request.

docker-hugo's People

Contributors

irgendwr avatar jguyomard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-hugo's Issues

Permissions Error When trying to create new site

Peux m'aider avec cette erreur si dessous? Looks like file permissions on the alpine box...

user@host:~$ docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo new site mysite
2017/01/07 22:00:06 mkdir /src/mysite/: permission denied
panic: mkdir /src/mysite/: permission denied

goroutine 1 [running]:
panic(0xa19600, 0xc42018ce20)
/usr/local/Cellar/go/1.7.4/libexec/src/runtime/panic.go:500 +0x1a1
log.Panicln(0xc4200317f8, 0x1, 0x1)
/usr/local/Cellar/go/1.7.4/libexec/src/log/log.go:334 +0xc9
github.com/spf13/hugo/vendor/github.com/spf13/afero.WriteReader(0xdfca20, 0xe54d70, 0xc4201035e0, 0x17, 0xdf0c20, 0xc420057b00, 0xdf25a0, 0xc420057bf0)
/Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/afero/util.go:49 +0x272
github.com/spf13/hugo/helpers.WriteToDisk(0xc4201035e0, 0x17, 0xdf0c20, 0xc420057b00, 0xdfca20, 0xe54d70, 0xb, 0x0)
/Users/bep/go/src/github.com/spf13/hugo/helpers/path.go:585 +0x5d
github.com/spf13/hugo/commands.createConfig(0xc42018c890, 0xb, 0xae2f9d, 0x4, 0xdf25a0, 0xc4200578f0)
/Users/bep/go/src/github.com/spf13/hugo/commands/new.go:346 +0x459
github.com/spf13/hugo/commands.doNewSite(0xc42018c890, 0xb, 0x0, 0x0, 0x0)
/Users/bep/go/src/github.com/spf13/hugo/commands/new.go:151 +0x4e1
github.com/spf13/hugo/commands.NewSite(0xe2ecc0, 0xc42018c860, 0x1, 0x1, 0x0, 0x0)
/Users/bep/go/src/github.com/spf13/hugo/commands/new.go:193 +0x2a7
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0xe2ecc0, 0xc42018c7a0, 0x1, 0x1, 0xe2ecc0, 0xc42018c7a0)
/Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:632 +0x23e
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xe2d9a0, 0xb5e1b8, 0xe36ad0, 0x1)
/Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:722 +0x367
github.com/spf13/hugo/commands.Execute()
/Users/bep/go/src/github.com/spf13/hugo/commands/hugo.go:160 +0x6d
main.main()
/Users/bep/go/src/github.com/spf13/hugo/main.go:26 +0x32

Readme: run docker command as current user

The readme is copy-paste friendly. We can optimize it further.
Currently users may have an error like this one.

$ docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo new site mysite
Error: Failed to create dir: mkdir /src/mysite: permission denied

I suggest replacing user hugo with current user $(id -u). For example:

$ docker run --rm -it -v $PWD:/src -u "$(id -u)" jguyomard/hugo-builder hugo new site mysite

Blank site

Thanks for putting this together. I think the README could benefit from one additional snippet about setting up a default template and initial post. When I first spun it up, all I got was a blank page. This is partly due to hugo not having a default template, butI was left wondering if I had messed something up.

Consider adding a "do this to add a template and this to make your first post" couple of lines.

Thanks again for this package!

docker-hugo-extended -> works with debian

Hi,
I had the issue that some features (like SCSS) were not working with your approach.

I noticed that an extended-version of Hugo is required for that. I tried to get it run with alpine-linux but failed. However, I managed to combine your Dockerfile with a debian version I found:

FROM debian:9-slim

ENV HUGO_VERSION='0.49'
ENV HUGO_NAME="hugo_extended_${HUGO_VERSION}_Linux-64bit"
ENV HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_NAME}.deb"
ENV BUILD_DEPS="wget"

RUN apt-get update \
    && apt-get install -y git "${BUILD_DEPS}" \
    && wget "${HUGO_URL}" \
    && apt-get install "./${HUGO_NAME}.deb" \
    && rm -rf "./${HUGO_NAME}.deb" "${HUGO_NAME}" \
    && apt-get remove -y "${BUILD_DEPS}" \
    && apt-get autoremove -y \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && groupadd -g 1000 hugo \
    && useradd -g hugo -u 1000 -m -d /src hugo

WORKDIR /src

EXPOSE 1313

I love your approach and like to share my workaround for a hugo-extended. Maybe you are able to get it running with alpine-linux.

thx & cheers

Hugo image with hugo-coder theme error

Hello, I am trying to build the site with the theme called hugo-coder: https://github.com/luizdepra/hugo-coder
I am getting the error below when hitting: docker run --rm -it -v $PWD:/src -p 1313:1313 jguyomard/hugo-builder hugo server -w --bind=0.0.0.0

Building sites … ERROR 2018/11/05 15:32:11 error: failed to transform resource: TOCSS: failed to transform "style.coder.css" (text/x-scss): this feature is not available in your current Hugo version

Proposal: Use releases instead of branches

Instead of creating a new branch for each release it would be better to create a new release in github.
You can migrate the old releases by deleting the branches and creating a new release targeting a commit.

baseURL resolution

My site seems to be having issues with baseURL resolution.

Design intent is to host a number of nodes on AWS and then reverse proxy to them using nginx, but from the hugo server's perspective, it's always living in localhost, so baseURL and absURL render as such.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.