Remove build time and git tag from binary artifact.

That way it's easy to build a given commit and check whether
it's the same binary than the one published on Github.
This commit is contained in:
Clement Michaud 2020-01-11 12:20:32 +01:00 committed by Clément Michaud
parent 1deb46778c
commit a823b6368a
5 changed files with 6 additions and 15 deletions

View File

@ -21,9 +21,7 @@ COPY internal internal
# Set the build version and time # Set the build version and time
RUN echo "Write tag ${BUILD_TAG} and commit ${BUILD_COMMIT} in binary." && \ RUN echo "Write tag ${BUILD_TAG} and commit ${BUILD_COMMIT} in binary." && \
BUILD_TIME=`date +"%Y-%m-%d %T"` && \ BUILD_TIME=`date +"%Y-%m-%d %T"` && \
sed -i "s/__BUILD_TAG__/${BUILD_TAG}/" cmd/authelia/constants.go && \ sed -i "s/__BUILD_COMMIT__/${BUILD_COMMIT}/" cmd/authelia/constants.go
sed -i "s/__BUILD_COMMIT__/${BUILD_COMMIT}/" cmd/authelia/constants.go && \
sed -i "s/__BUILD_TIME__/${BUILD_TIME}/" cmd/authelia/constants.go
# CGO_ENABLED=1 is mandatory for building go-sqlite3 # CGO_ENABLED=1 is mandatory for building go-sqlite3
RUN cd cmd/authelia && \ RUN cd cmd/authelia && \
@ -59,4 +57,4 @@ EXPOSE 9091
VOLUME /etc/authelia VOLUME /etc/authelia
VOLUME /var/lib/authelia VOLUME /var/lib/authelia
CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"] CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"]

View File

@ -24,9 +24,7 @@ COPY internal internal
# Set the build version and time # Set the build version and time
RUN echo "Write tag ${BUILD_TAG} and commit ${BUILD_COMMIT} in binary." && \ RUN echo "Write tag ${BUILD_TAG} and commit ${BUILD_COMMIT} in binary." && \
BUILD_TIME=`date +"%Y-%m-%d %T"` && \ BUILD_TIME=`date +"%Y-%m-%d %T"` && \
sed -i "s/__BUILD_TAG__/${BUILD_TAG}/" cmd/authelia/constants.go && \ sed -i "s/__BUILD_COMMIT__/${BUILD_COMMIT}/" cmd/authelia/constants.go
sed -i "s/__BUILD_COMMIT__/${BUILD_COMMIT}/" cmd/authelia/constants.go && \
sed -i "s/__BUILD_TIME__/${BUILD_TIME}/" cmd/authelia/constants.go
# CGO_ENABLED=1 is mandatory for building go-sqlite3 # CGO_ENABLED=1 is mandatory for building go-sqlite3
RUN cd cmd/authelia && \ RUN cd cmd/authelia && \
@ -66,4 +64,4 @@ EXPOSE 9091
VOLUME /etc/authelia VOLUME /etc/authelia
VOLUME /var/lib/authelia VOLUME /var/lib/authelia
CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"] CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"]

View File

@ -24,9 +24,7 @@ COPY internal internal
# Set the build version and time # Set the build version and time
RUN echo "Write tag ${BUILD_TAG} and commit ${BUILD_COMMIT} in binary." && \ RUN echo "Write tag ${BUILD_TAG} and commit ${BUILD_COMMIT} in binary." && \
BUILD_TIME=`date +"%Y-%m-%d %T"` && \ BUILD_TIME=`date +"%Y-%m-%d %T"` && \
sed -i "s/__BUILD_TAG__/${BUILD_TAG}/" cmd/authelia/constants.go && \ sed -i "s/__BUILD_COMMIT__/${BUILD_COMMIT}/" cmd/authelia/constants.go
sed -i "s/__BUILD_COMMIT__/${BUILD_COMMIT}/" cmd/authelia/constants.go && \
sed -i "s/__BUILD_TIME__/${BUILD_TIME}/" cmd/authelia/constants.go
# CGO_ENABLED=1 is mandatory for building go-sqlite3 # CGO_ENABLED=1 is mandatory for building go-sqlite3
RUN cd cmd/authelia && \ RUN cd cmd/authelia && \
@ -66,4 +64,4 @@ EXPOSE 9091
VOLUME /etc/authelia VOLUME /etc/authelia
VOLUME /var/lib/authelia VOLUME /var/lib/authelia
CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"] CMD ["./authelia", "--config", "/etc/authelia/configuration.yml"]

View File

@ -2,4 +2,3 @@ package main
var BuildTag = "__BUILD_TAG__" var BuildTag = "__BUILD_TAG__"
var BuildCommit = "__BUILD_COMMIT__" var BuildCommit = "__BUILD_COMMIT__"
var BuildTime = "__BUILD_TIME__"

View File

@ -114,9 +114,7 @@ func main() {
versionCmd := &cobra.Command{ versionCmd := &cobra.Command{
Use: "version", Use: "version",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("build git tag: %s\n", BuildTag)
fmt.Printf("build git commit: %s\n", BuildCommit) fmt.Printf("build git commit: %s\n", BuildCommit)
fmt.Printf("build time: %s\n", BuildTime)
}, },
} }