Skip to content

Commit

Permalink
build: stop requiring updates to version.go
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Oct 25, 2024
1 parent 2f14940 commit cec6e81
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM golang:alpine as backend
ARG VERSION
WORKDIR /src
COPY . /src
RUN go mod download
RUN CGO_ENABLED=0 go build -o ./bin/server /src/cmd/server
RUN CGO_ENABLED=0 go build -ldflags "-X github.com/moov-io/watchman.Version=${VERSION}" -o ./bin/server /src/cmd/server

FROM node:21-alpine as frontend
ARG VERSION
COPY webui/ /watchman/
WORKDIR /watchman/
RUN npm install --legacy-peer-deps
Expand All @@ -16,8 +18,8 @@ COPY --from=backend /src/bin/server /bin/server
COPY --from=frontend /watchman/build/ /watchman/
ENV WEB_ROOT=/watchman/

# USER moov # TODO(adam): non-root users

EXPOSE 8084
EXPOSE 9094

ENTRYPOINT ["/bin/server"]
3 changes: 2 additions & 1 deletion Dockerfile-openshift
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM quay.io/fedora/fedora:40-x86_64 as builder
ARG VERSION
RUN yum install -y git golang make npm wget glibc
WORKDIR /opt/app-root/src/
COPY . .
RUN go mod download
RUN make build-server
RUN VERSION=${VERSION} make build-server

FROM node:21-bookworm as frontend
COPY webui/ /watchman/
Expand Down
29 changes: 21 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
PLATFORM=$(shell uname -s | tr '[:upper:]' '[:lower:]')
VERSION := $(shell grep -Eo '(v[0-9]+[\.][0-9]+[\.][0-9]+(-[a-zA-Z0-9]*)?)' version.go)

ifndef VERSION
ifndef RELEASE
# If we're not publishing a release, set the dev commit hash
ifndef DEV_TAG_SHA
COMMIT_HASH :=$(shell git rev-parse --short=7 HEAD)
else
COMMIT_HASH :=$(shell echo ${DEV_TAG_SHA} | cut -c 1-7)
endif
VERSION := dev-${COMMIT_HASH}
else
VERSION := $(shell git describe --tags --abbrev=0)
endif
endif

.PHONY: run build build-server docker release check test

Expand All @@ -14,13 +27,13 @@ else
endif

build-server:
CGO_ENABLED=0 go build -o ./bin/server github.com/moov-io/watchman/cmd/server
CGO_ENABLED=0 go build -ldflags "-X github.com/moov-io/watchman.Version=${VERSION}" -o ./bin/server github.com/moov-io/watchman/cmd/server

build-batchsearch:
CGO_ENABLED=0 go build -o ./bin/batchsearch github.com/moov-io/watchman/cmd/batchsearch
CGO_ENABLED=0 go build -ldflags "-X github.com/moov-io/watchman.Version=${VERSION}" -o ./bin/batchsearch github.com/moov-io/watchman/cmd/batchsearch

build-watchmantest:
CGO_ENABLED=0 go build -o ./bin/watchmantest github.com/moov-io/watchman/cmd/watchmantest
CGO_ENABLED=0 go build -ldflags "-X github.com/moov-io/watchman.Version=${VERSION}" -o ./bin/watchmantest github.com/moov-io/watchman/cmd/watchmantest

.PHONY: check
check:
Expand Down Expand Up @@ -71,18 +84,18 @@ endif
docker: clean docker-hub docker-openshift docker-static docker-watchmantest

docker-hub:
docker build --pull -t moov/watchman:$(VERSION) -f Dockerfile .
docker build --pull --build-arg VERSION=${VERSION} -t moov/watchman:$(VERSION) -f Dockerfile .
docker tag moov/watchman:$(VERSION) moov/watchman:latest

docker-openshift:
docker build --pull -t quay.io/moov/watchman:$(VERSION) -f Dockerfile-openshift --build-arg VERSION=$(VERSION) .
docker build --pull --build-arg VERSION=${VERSION} -t quay.io/moov/watchman:$(VERSION) -f Dockerfile-openshift --build-arg VERSION=$(VERSION) .
docker tag quay.io/moov/watchman:$(VERSION) quay.io/moov/watchman:latest

docker-static:
docker build --pull -t moov/watchman:static -f Dockerfile-static .
docker build --pull --build-arg VERSION=${VERSION} -t moov/watchman:static -f Dockerfile-static .

docker-watchmantest:
docker build --pull -t moov/watchmantest:$(VERSION) -f ./cmd/watchmantest/Dockerfile .
docker build --pull --build-arg VERSION=${VERSION} -t moov/watchmantest:$(VERSION) -f ./cmd/watchmantest/Dockerfile .
docker tag moov/watchmantest:$(VERSION) moov/watchmantest:latest

release: docker AUTHORS
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

package watchman

const Version = "v0.30.0"
var Version string

0 comments on commit cec6e81

Please sign in to comment.