Public | Automated Build

Last pushed: 3 months ago
Short Description
Container that can build a Hugo site from a git repo and push it to a S3 bucket.
Full Description

hugo-s3

Docker container that can build a hugo site from a git repo and push it to a s3 bucket.

Should be useable in build tools such as Bitbucket Pipelines and Werker workflows.

usage

$ docker pull rabidgremlin/hugo-s3
$ docker run rabidgremlin/hugo-s3
Usage:
      docker run rabidgremlin/hugo-s3 <git url> <s3 bucket name> <AWS access key> <AWS secret key>
$ docker run rabidgremlin/hugo-s3 https://github.com/rabidgremlin/hugo-s3-test.git hugo-s3-test AxxxxxxxxxxxxxxxxxxxA jyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyn

Any parameters after the first 4 are passed onto Hugo. For instance to override the baseurl you can pass the -b parameter to Hugo as follows:

$ docker run rabidgremlin/hugo-s3 https://github.com/rabidgremlin/hugo-s3-test.git hugo-s3-test AxxxxxxxxxxxxxxxxxxxA jyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyn -b http://hugo-s3-test.s3xxxxxxxxxxxxxxxxxxxx.amazonaws.com/

using the container in a Bitbucket Pipeline

To use this container in a Bitbucket Pipeline create a file named bitbucket-pipelines.yml in the root of your Hugo source tree with the following contents:

image: rabidgremlin/hugo-s3

pipelines:
  default:
    - step:
        script:          
          - hugo -b $BASE_URL
          - cd public
          - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
          - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
          - aws s3 sync . s3://$S3_BUCKET/ --delete

Then under your project's settings configure _S3BUCKET, _AWS_ACCESS_KEYID, _AWS_SECRET_ACCESSKEY and _BASEURL environment variables. See here for more information. Note the _BASEURL varaible is optional and only needed if you want to override it for your build/branch. You can remove it from the call to hugo in bitbucket-pipelines.yml if you do not need it.

Docker Pull Command
Owner
rabidgremlin
Source Repository