Commit graph

38 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
4c3347a77f
Upgrade to latest Go version + Some Docker image improvements (note)
* Rename /site to /project
* Add ldflags
* Add go and node to the default image
* Add Dart Sass to the default image
* Build the extended version by default
* Add "npm i" install support with custom entry script override
* Adjust cache logic to speed up CGO rebuilds

Closes #12920
See #12885
2024-10-11 15:01:08 +02:00
David Karlsson
a3a00016fb
ci: Build multi-platform image with cross-compilation
The previous build workflow used emulation to build the Docker image,
which results in a somewhat complicated push-by-digest and merge
workflow to create a multi-platform image.

This commit changes the Docker build to use cross-compilation instead,
resulting in a faster and more straightforward build.

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-10-09 11:25:45 +02:00
Aymen Rachdi
ae3815898f Update Dockerfile 2024-09-02 21:56:33 +02:00
michalbiesek
8a08f91d5b
dockerfile: Update Docker images
- `golang:1.21-alpine`
- `alpine:3.18`
2023-08-23 18:06:52 +02:00
Steffen Windoffer
6275aad9e2
Update Go and Alpine version in Dockerfile 2022-10-19 19:58:25 +02:00
Anthony Fok
8309a2b1c1 Dockerfile: Make it build with Go 1.18 2022-03-21 21:01:24 -06:00
hitzhangjie
8a005538db
Fix Dockerfile
Mage uses git, so we should install git before run mage.

Closes #9261
2021-12-12 14:45:08 +01:00
Systemkern
5afcae7e0b #8210 Upgrade golang version for Dockerfile
https://github.com/gohugoio/hugo/issues/8210
relates to: #8210
2021-02-28 14:14:06 +01:00
Eric Hagman
f465c5c307
build: Allow optional "nodeploy" tag to exclude deploy command from bin
Fixes #7826
2020-10-23 09:03:41 +02:00
Daniel Sutton
f5ea359dd3
docker: Update to Go 1.15 and Alpine 3.12 2020-10-12 22:51:08 +02:00
Jaymo Kang
75c3787fc2
Add git to Dockerfile
Needed for GitInfo.
2020-02-14 16:49:20 +01:00
Remco de Man
aa4ccb8a1e Update alpine base image in Dockerfile to 3.11
When building the extended version of Hugo using the Dockerfile and
`--build-arg HUGO_BUILD_TAGS=extended`, the obtained Docker container is
broken, because the source is build under alpine 3.11 and the compiled
binary is copied to an image based on alpine 3.10. This problem was most
likely introduced due to an update of the golang base image.

This commit changes the base image from alpine:3.10 to alpine:3.11,
fixing extended version builds.
2019-12-30 13:56:58 +01:00
Jake Jarvis
ed2682325a Dockerfile: Switch to mage builds, various optimizations
- Use Alpine for both stages for consistency.
- Switch to mage from go install as dictated in the latest docs.
- Easy switch to building Hugo Extended by directly setting HUGO_BUILD_TAGS flag at image build time: `docker build --build-arg HUGO_BUILD_TAGS=extended .`
- Update to Go 1.13 and Alpine 3.10.
- The only possibly breaking change: Moved the `hugo` binary in the final stage from /hugo to /usr/bin/hugo so one can simply run `hugo` without having to search around for its location.
2019-10-31 09:53:49 +01:00
Brian 'Redbeard' Harrington
41974303f3 dockerfile: Switch base image for final build
Switching the base image for the final build to alpine as it still
provides a minimal interface, but has a mechanism for easily including
relevant CA certificates.  This is currently pinned to a tagged version,
though since none of the underlying mechanisms are used this should
balance both remaining stable, supported for a period of time, and
providing usable functionality.

Resolves #5970
Affects #5056
2019-05-23 12:49:13 -06:00
Anthony Metzidis
075b17ee1d
Support Docker args TAGS, WORKDIR, CGO; speed up repetitive builds 2019-02-22 11:53:17 -08:00
zyfdegh
bcbe57c6e9 Update Dockerfile to Go 1.11
Fixes #5145
2018-08-31 09:05:52 +02:00
Bjørn Erik Pedersen
dea71670c0
Add Hugo Piper with SCSS support and much more
Before this commit, you would have to use page bundles to do image processing etc. in Hugo.

This commit adds

* A new `/assets` top-level project or theme dir (configurable via `assetDir`)
* A new template func, `resources.Get` which can be used to "get a resource" that can be further processed.

This means that you can now do this in your templates (or shortcodes):

```bash
{{ $sunset := (resources.Get "images/sunset.jpg").Fill "300x200" }}
```

This also adds a new `extended` build tag that enables powerful SCSS/SASS support with source maps. To compile this from source, you will also need a C compiler installed:

```
HUGO_BUILD_TAGS=extended mage install
```

Note that you can use output of the SCSS processing later in a non-SCSSS-enabled Hugo.

The `SCSS` processor is a _Resource transformation step_ and it can be chained with the many others in a pipeline:

```bash
{{ $css := resources.Get "styles.scss" | resources.ToCSS | resources.PostCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

The transformation funcs above have aliases, so it can be shortened to:

```bash
{{ $css := resources.Get "styles.scss" | toCSS | postCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

A quick tip would be to avoid the fingerprinting part, and possibly also the not-superfast `postCSS` when you're doing development, as it allows Hugo to be smarter about the rebuilding.

Documentation will follow, but have a look at the demo repo in https://github.com/bep/hugo-sass-test

New functions to create `Resource` objects:

* `resources.Get` (see above)
* `resources.FromString`: Create a Resource from a string.

New `Resource` transformation funcs:

* `resources.ToCSS`: Compile `SCSS` or `SASS` into `CSS`.
* `resources.PostCSS`: Process your CSS with PostCSS. Config file support (project or theme or passed as an option).
* `resources.Minify`: Currently supports `css`, `js`, `json`, `html`, `svg`, `xml`.
* `resources.Fingerprint`: Creates a fingerprinted version of the given Resource with Subresource Integrity..
* `resources.Concat`: Concatenates a list of Resource objects. Think of this as a poor man's bundler.
* `resources.ExecuteAsTemplate`: Parses and executes the given Resource and data context (e.g. .Site) as a Go template.

Fixes #4381
Fixes #4903
Fixes #4858
2018-07-06 11:46:12 +02:00
Anthony Fok
23d5fc82ee
Update to Go 1.9.7 and Go 1.10.3
for Travis CI, Docker and Snap
2018-06-14 15:50:25 -06:00
Ryan Skoblenick
8531ec7ca3 Update Dockerfile to a multi-stage build
- Hugo container is based on SCRATCH to further reduce the footprint
  and the vulnerability surface
- Update Alpine image to 3.7 in the build container
- Update Go Lang to 1.10 in the build container
- Add .dockerignore file per the Docker best practices

Closes #4154, #4155, #4157
2018-06-14 15:47:04 -06:00
Ryan Skoblenick
a34213f0b5 Fix Docker build
The present Dockerfile in master does not build a Hugo container. The
build container prematurely exits because `dep ensure` can not locate
`Gopkg.toml` due to the source files not being copied/added to the
container prior to running this command. The minimal change require
to resolve the issue is merely move the ADD source before the RUN dep.

Fixes #4076
Resolves #4077
2018-01-31 09:16:28 +01:00
Bjørn Erik Pedersen
9ccc958ce7 Update Dockerfile and Snap build to reflect move to dep
See #3988
2017-10-21 19:30:23 +02:00
Thibault Jamet
d9697e275e Split go build in Dockerfile
To maximize the usage of cache, split the govendor get in steps:
- govendor fetch to get the pinned versions of dependencies
- go install to actually build the binary

Doing so allows not to re-download the whole dependencies when changing
lines in hugo repository

The current Dockerfile generates an image of 16.6MB

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
2017-09-25 10:28:13 -06:00
Thibault Jamet
09d960f173 Update Dockerfile to benefit build cache
Docker has recently introduces buikld-stages (as of version 17.05)

Build stages allows to benefit the docker build cache as well as
reducing the size of the resulting image c.f.
https://docs.docker.com/engine/userguide/eng-image/multistage-build/

This change allows to have faster builds when running `docker build`
several times after changing some little code

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
2017-09-25 10:28:13 -06:00
Anthony Fok
9ed48c1c9a Dockerfile: Run go install with -ldflags '-s -w'
This reduce the Docker image size from 27 MB to 20.5 MB.
2017-07-26 03:22:39 -06:00
Maik Ellerbrock
bfe0bfbbd1 Dockerfile: Reduce image size from 277MB to 27MB
"xtrem" awesome container size optimization
by using alpine:3.6 as base image
and by installing Go at build time.

See #3730 and #3738
2017-07-26 00:51:27 -06:00
Maik Ellerbrock
606d6a8c91 Dockerfile: Optimize Docker image size
Reduce Docker image size from 428 MB to 277 MB.

See #3674
2017-07-23 12:30:18 -06:00
Maik Ellerbrock
118f8f7cf2 Dockerfile: Update Dockerfile and add Docker optimizations 2017-06-28 03:35:26 -06:00
digitalcraftsman
7b99fb9f1c Update source path in Dockerfile due to the org transition 2017-06-13 19:34:20 +02:00
Gilbert Gilb's
c7646551be Dockerfile: Remove ENTRYPOINT
It's pointless to set `/bin/sh` as entrypoint. `/bin/sh` is already the default command, and on the top of that, setting `/bin/sh` as entrypoint ignores the command.
2017-05-14 09:56:03 +02:00
Hauke Löffler
831bfd36aa Update Docker file to Go 1.8
* new go-version, switch to alpine (reduce size by 500mb)
* use govendor
2017-02-23 00:17:14 +01:00
Gilbert Gilb's
95a473e7ec Fix Dockerfile 2016-12-28 19:16:12 +01:00
Evan Purkhiser
e0b278205a Fix alignment of go gets in Dockerfile 2016-11-23 10:52:17 +01:00
Andrew Speed
0721a9c730 Update Dockerfile to pull in missing test dependency
Add the missing github.com/fortytw2/leaktest dependency required for
hugo_site_tests.
2016-10-01 13:02:35 +02:00
Cody W. Opel
acbedf6220 Fix urlesc import url in Dockerfile 2016-06-08 01:33:14 -06:00
Bjørn Erik Pedersen
b7513ea6ff Get Dockerfile up-to-date 2016-06-05 11:06:04 +02:00
Anthony Fok
9ddf52021b Update import path of fsnotify
Rename "gopkg.in/fsnotify.v1" to "github.com/fsnotify/fsnotify"
per upstream recommendation.

See https://github.com/fsnotify/fsnotify/issues/108 for rationale.
2016-04-20 22:28:26 +08:00
Ivan Fraixedes
0945673f05 Update Dockerfile to use golang:1.6 base image
Hugo has been confirmed which runs on Golang 1.6, as travis uses 1.6
vesion. Dockerfile must be consistend with it so it has to use golang:1.6
as base image than golang:1.5
2016-03-10 10:59:52 +01:00
Sven Dowideit
7bc5d3663f Use a Docker container to build hugo
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-01-04 12:47:23 -05:00