Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alombarte/hugo-docker
Alpine container with hugo, ssh and git to build projects
https://github.com/alombarte/hugo-docker
Last synced: about 1 month ago
JSON representation
Alpine container with hugo, ssh and git to build projects
- Host: GitHub
- URL: https://github.com/alombarte/hugo-docker
- Owner: alombarte
- Created: 2018-10-05T10:20:25.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-23T12:58:23.000Z (4 months ago)
- Last Synced: 2024-07-23T15:08:35.692Z (4 months ago)
- Language: Dockerfile
- Size: 11.7 KB
- Stars: 4
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hugo docker
An alpine docker image with hugo, node (for pipeline functionality), 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](https://hub.docker.com/r/alombarte/hugo/tags). 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
- $GH_TOKEN (the token provided by github so you can push without your password)```
image: alombarte/hugostages:
- 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:
- masterdeploy:
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
```