Pull request: all: switch to SOURCE_DATE_EPOCH for source date
Closes #4221. Squashed commit of the following: commit c84a5699280cf4c0b1c2ed034a44f05ffc74d30d Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Feb 1 21:13:30 2022 +0300 all: switch to SOURCE_DATE_EPOCH for source date
This commit is contained in:
@@ -90,14 +90,15 @@ Required environment:
|
||||
### `go-build.sh`: Build The Backend
|
||||
|
||||
Optional environment:
|
||||
* `BUILD_TIME`: If set, overrides the build time information. Useful for
|
||||
reproducible builds.
|
||||
* `GOARM`: ARM processor options for the Go compiler.
|
||||
* `GOMIPS`: ARM processor options for the Go compiler.
|
||||
* `GO`: set an alternative name for the Go compiler.
|
||||
* `OUT`: output binary name.
|
||||
* `PARALLELISM`: set the maximum number of concurrently run build commands
|
||||
(that is, compiler, linker, etc.).
|
||||
* `SOURCE_DATE_EPOCH`: the [standardized][repr] environment variable for the
|
||||
Unix epoch time of the latest commit in the repository. If set, overrides
|
||||
the default obtained from Git. Useful for reproducible builds.
|
||||
* `VERBOSE`: verbosity level. `1` shows every command that is run and every
|
||||
Go package that is processed. `2` also shows subcommands and environment.
|
||||
The default value is `0`, don't be verbose.
|
||||
@@ -107,6 +108,8 @@ Optional environment:
|
||||
Required environment:
|
||||
* `CHANNEL`: release channel, see above.
|
||||
|
||||
[repr]: https://reproducible-builds.org/docs/source-date-epoch/
|
||||
|
||||
|
||||
|
||||
### `go-deps.sh`: Install Backend Dependencies
|
||||
|
||||
@@ -5,22 +5,26 @@ FROM alpine:3.13
|
||||
ARG BUILD_DATE
|
||||
ARG VERSION
|
||||
ARG VCS_REF
|
||||
LABEL maintainer="AdGuard Team <devteam@adguard.com>" \
|
||||
org.opencontainers.image.created=$BUILD_DATE \
|
||||
org.opencontainers.image.url="https://adguard.com/adguard-home.html" \
|
||||
org.opencontainers.image.source="https://github.com/AdguardTeam/AdGuardHome" \
|
||||
org.opencontainers.image.version=$VERSION \
|
||||
org.opencontainers.image.revision=$VCS_REF \
|
||||
org.opencontainers.image.vendor="AdGuard" \
|
||||
org.opencontainers.image.title="AdGuard Home" \
|
||||
org.opencontainers.image.description="Network-wide ads & trackers blocking DNS server" \
|
||||
org.opencontainers.image.licenses="GPL-3.0"
|
||||
|
||||
LABEL\
|
||||
maintainer="AdGuard Team <devteam@adguard.com>" \
|
||||
org.opencontainers.image.authors="AdGuard Team <devteam@adguard.com>" \
|
||||
org.opencontainers.image.created=$BUILD_DATE \
|
||||
org.opencontainers.image.description="Network-wide ads & trackers blocking DNS server" \
|
||||
org.opencontainers.image.documentation="https://github.com/AdguardTeam/AdGuardHome/wiki/" \
|
||||
org.opencontainers.image.licenses="GPL-3.0" \
|
||||
org.opencontainers.image.revision=$VCS_REF \
|
||||
org.opencontainers.image.source="https://github.com/AdguardTeam/AdGuardHome" \
|
||||
org.opencontainers.image.title="AdGuard Home" \
|
||||
org.opencontainers.image.url="https://adguard.com/en/adguard-home/overview.html" \
|
||||
org.opencontainers.image.vendor="AdGuard" \
|
||||
org.opencontainers.image.version=$VERSION
|
||||
|
||||
# Update certificates.
|
||||
RUN apk --no-cache --update add ca-certificates libcap tzdata && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
mkdir -p /opt/adguardhome/conf /opt/adguardhome/work && \
|
||||
chown -R nobody: /opt/adguardhome
|
||||
rm -rf /var/cache/apk/* && \
|
||||
mkdir -p /opt/adguardhome/conf /opt/adguardhome/work && \
|
||||
chown -R nobody: /opt/adguardhome
|
||||
|
||||
ARG DIST_DIR
|
||||
ARG TARGETARCH
|
||||
|
||||
@@ -65,9 +65,9 @@ then
|
||||
fi
|
||||
readonly version
|
||||
|
||||
# Set date and time of the current build unless already set.
|
||||
buildtime="${BUILD_TIME:-$( date -u +%FT%TZ%z )}"
|
||||
readonly buildtime
|
||||
# Set date and time of the latest commit unless already set.
|
||||
committime="${SOURCE_DATE_EPOCH:-$( git log -1 --pretty=%ct )}"
|
||||
readonly committime
|
||||
|
||||
# Set the linker flags accordingly: set the release channel and the current
|
||||
# version as well as goarm and gomips variable values, if the variables are set
|
||||
@@ -78,7 +78,7 @@ readonly version_pkg
|
||||
ldflags="-s -w"
|
||||
ldflags="${ldflags} -X ${version_pkg}.version=${version}"
|
||||
ldflags="${ldflags} -X ${version_pkg}.channel=${channel}"
|
||||
ldflags="${ldflags} -X ${version_pkg}.buildtime=${buildtime}"
|
||||
ldflags="${ldflags} -X ${version_pkg}.committime=${committime}"
|
||||
if [ "${GOARM:-}" != '' ]
|
||||
then
|
||||
ldflags="${ldflags} -X ${version_pkg}.goarm=${GOARM}"
|
||||
|
||||
@@ -86,6 +86,7 @@ in
|
||||
# minor release. If the current commit is the new minor release,
|
||||
# num_commits_since_minor is zero.
|
||||
num_commits_since_minor="$( git rev-list "${last_minor_zero}..HEAD" | wc -l )"
|
||||
|
||||
# The output of darwin's implementation of wc needs to be trimmed from
|
||||
# redundant spaces.
|
||||
num_commits_since_minor="$( echo "$num_commits_since_minor" | tr -d '[:space:]' )"
|
||||
|
||||
Reference in New Issue
Block a user