Updating build flags and docker build instructions in readme.

This commit is contained in:
Nick Gerakines 2020-04-03 17:53:27 -04:00
parent a55bac91ee
commit 33233646cd
No known key found for this signature in database
GPG Key ID: 33D43D854F96B2E4
4 changed files with 24 additions and 1 deletions

View File

@ -5,6 +5,9 @@ COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go generate -tags prod ./...
ARG GIT_COMMIT
ARG RELEASE_CODE
ARG BUILD_TIME
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -ldflags "-w -s -extldflags '-static' -X main.GitCommit=$GIT_COMMIT -X main.ReleaseCode=$RELEASE_CODE -X 'main.BuildTime=$BUILD_TIME'" github.com/ngerakines/tavern/...
FROM alpine:3.11 as tavern

View File

@ -30,6 +30,13 @@ The build and release process involves code generation in a few ways that aren't
The `-tags prod` argument can be used to indicate prod vs non-prod sources. When the `prod` flag **is not** present, asset packages will load content from disk, but will still contain file path references. In other words, whenever you create or delete files including templates, migrations, or translations, you must run `go generate ./...`.
## Docker Builds
$ export TAVERN_RELEASE_CODE=$(git describe --always)
$ export TAVERN_GIT_COMMIT=$(git log --format="%H" -n 1)
$ export TAVERN_BUILD_TIME=$(date --rfc-3339=seconds)
$ docker build --build-arg=GIT_COMMIT=$TAVERN_GIT_COMMIT --build-arg=RELEASE_CODE=$TAVERN_RELEASE_CODE --build-arg=BUILD_TIME="$TAVERN_BUILD_TIME" -t ngerakines/tavern:latest --target=tavern .
# License
MIT License

View File

@ -25,7 +25,7 @@ var GitCommit string
var BuildTime string
func main() {
compiledAt, err := time.Parse(time.RFC822Z, BuildTime)
compiledAt, err := time.Parse(time.RFC3339, BuildTime)
if err != nil {
compiledAt = time.Now()
}

View File

@ -244,10 +244,23 @@ func serverCommandAction(cliCtx *cli.Context) error {
assetQueue := common.NewStringQueue()
registry := prometheus.NewRegistry()
if err = registry.Register(prometheus.NewGoCollector()); err != nil {
return err
}
fact := promauto.With(registry)
{
tavernInfoG := fact.NewGauge(prometheus.GaugeOpts{
Namespace: "tavern",
Subsystem: "web",
Name: "info",
Help: "",
ConstLabels: map[string]string{"buildtime": g.BuildTime, "version": g.Version(), "ua": g.UserAgent()},
})
tavernInfoG.Set(1)
}
httpClient := common.InstrumentedDefaultHTTPClient(fact, "web", "client")
var svgConv SVGConverter