Giter VIP home page Giter VIP logo

hugo-docker's Introduction

Hugo docker

An alpine docker image with hugo, openssh and git. Used in my CI pipelines.

It comes without the hugo entrypoint.

Usage

To build your hugo site in the default public directory:

docker run -v "${PWD}:/site" alombarte/hugo hugo

Use a different hugo version

Available versions are here. To add another version just build the image passing the desired version, e.g.:

export VERSION=0.55.6 && docker build -t alombarte/hugo:${VERSION} --build-arg VERSION=${VERSION} .

Integration on Gitlab and Github

The following file is an example on how to build a hugo site hosetd on a private repo (Gitlab) and deploy it into a public Github repo (the generated HTML). Yes, you could the whole thing on Gitlab :)

Make sure to set the variables in the configuration:

  • $USERNAME
  • $REPOSITORY
  • $EMAIL
  • $GH_TOKEN (the token provided by github so you can push without your password)
image: alombarte/hugo

stages:
  - build
  - deploy
services:
  - docker:dind

# If you need special NPM builds that cannot be handled through Hugo:
build:
  stage: build
  image: docker:stable
  script:
    - docker run -v $PWD:/app -w /app node:10 npm install
    - docker run -v $PWD:/app -w /app node:10 npm run-script build
  artifacts:
    paths:
    - static/dist/
  only:
    - master

deploy:
  stage: deploy
# variables:
#    GIT_SUBMODULE_STRATEGY: normal
#    GIT_DEPTH: "3"
  dependencies:
    - build
  script:
    - git clone https://github.com/${USERNAME}/${REPOSITORY}.git public
    - rm -fr public/*
    - hugo -d public
    - cd public
    - git remote rm origin
    - git remote add origin https://${USERNAME}:${GH_TOKEN}@github.com/${USERNAME}/${REPOSITORY}.net.git
    - git config --global user.email "${EMAIL}"
    - git config --global user.name "${USERNAME}"
    - git add -A
    - git commit -m "Automatic build from CI $CI_SERVER_NAME $CI_PIPELINE_ID"
    - git push --set-upstream origin master
  artifacts:
    paths:
    - public
  only:
    - master
  before_script:
    - hugo version

hugo-docker's People

Contributors

alombarte avatar apocomilogin avatar

Watchers

James Cloos avatar

Forkers

sgmelayu

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.