Skip to content

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

Notifications You must be signed in to change notification settings

carsonip/hugo-s3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 S3_BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and BASE_URL environment variables. See here for more information. Note the BASE_URL 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.

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 53.1%
  • Shell 46.9%