Skip to content

Commit

Permalink
Add documentation for KO_DATA_DATE_EPOCH env var
Browse files Browse the repository at this point in the history
  • Loading branch information
skirsten committed Jun 11, 2021
1 parent 3383082 commit 1c1f3b4
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ you can include Git commit information in your image with:
ln -s -r .git/HEAD ./cmd/app/kodata/
```

Also note that `http.FileServer` will not serve the `Last-Modified` header
(or validate `If-Modified-Since` request headers) because `ko` does not embed
timestamps by default.

This can be supported by manually setting the `KO_DATA_DATE_EPOCH` environment
variable during build ([See below](#Why-are-my-images-all-created-in-1970)).

# Kubernetes Integration

You could stop at just building and pushing images.
Expand Down Expand Up @@ -335,25 +342,29 @@ GOFLAGS="-ldflags=-X=main.version=1.2.3" ko publish .
## Why are my images all created in 1970?

In order to support [reproducible builds](https://reproducible-builds.org), `ko`
doesn't embed timestamps in the images it produces by default; however, `ko`
does respect the
[`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/docs/source-date-epoch/)
environment variable.
doesn't embed timestamps in the images it produces by default.

However, `ko` does respect the [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/docs/source-date-epoch/)
environment variable, which will set the container image's timestamp
accordingly.

For example, you can set this to the current timestamp by executing:
Similarly, the `KO_DATA_DATE_EPOCH` environment variable can be used to set
the _modtime_ timestamp of the files in `KO_DATA_PATH`.

For example, you can set the container image's timestamp to the current
timestamp by executing:

```
export SOURCE_DATE_EPOCH=$(date +%s)
```

or to the latest git commit's timestamp with:
or set the timestamp of the files in `KO_DATA_PATH` to the latest git commit's
timestamp with:

```
export SOURCE_DATE_EPOCH=$(git log -1 --format='%ct')
export KO_DATA_DATE_EPOCH=$(git log -1 --format='%ct')
```

The same applies to `KO_DATA_DATE_EPOCH` which sets the last modified time of all files in `kodata`.

## Can I optimize images for [eStargz support](https://github.com/containerd/stargz-snapshotter/blob/v0.2.0/docs/stargz-estargz.md)?

Yes! Set the environment variable `GGCR_EXPERIMENT_ESTARGZ=1` to produce
Expand Down

0 comments on commit 1c1f3b4

Please sign in to comment.