Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ vendor/
tests/

# Configuration
Makefile
.envrc
*.yaml
*.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.build-meta.outputs.version }}
ROXIE_VERSION=${{ steps.build-meta.outputs.version }}
GIT_COMMIT=${{ steps.build-meta.outputs.git_commit }}
BUILD_DATE=${{ steps.build-meta.outputs.build_date }}
cache-from: |
Expand Down
18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ RUN go mod download
COPY . .

# Build roxie binary with version info and cross-compilation support
ARG VERSION=0.1
ARG GIT_COMMIT=unknown
ARG BUILD_DATE=unknown
RUN echo "Building for ${TARGETOS}/${TARGETARCH}" && \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
-ldflags "-w -s -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT} -X main.buildDate=${BUILD_DATE}" \
-o roxie \
./cmd
ARG ROXIE_VERSION
ARG BUILD_DATE
ARG GIT_COMMIT
RUN CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
ROXIE_VERSION=${ROXIE_VERSION} \
BUILD_DATE=${BUILD_DATE} \
GIT_COMMIT=${GIT_COMMIT} \
make build

# Download gcloud SDK in builder stage to avoid UBI filesystem restrictions
# Latest version including checksums can be found at:
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BUILD_DIR := .
BINARY := $(BUILD_DIR)/$(BINARY_NAME)

# Version information
GIT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
# Convention is that the git tags are of the form
# v<major>.<minor>.<patch>-<build-number>-<commit-hash>[-dirty]
# or v<major>.<minor>.<patch>
Expand All @@ -29,9 +29,9 @@ GIT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
# <major>.<minor>.<patch> or <major>.<minor>.<patch>-<build-number>-<commit-hash>[-dirty]
#
# This will also become the tag of the docker images.
VERSION := $(shell git describe --tags --always --dirty | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-[a-z0-9]+(-dirty)?$$)/\1/')
BUILD_DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildDate=$(BUILD_DATE)
ROXIE_VERSION ?= $(shell git describe --tags --always --dirty | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-[a-z0-9]+(-dirty)?$$)/\1/')
BUILD_DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -X main.version=$(ROXIE_VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildDate=$(BUILD_DATE)

.PHONY: get-build-date
get-build-date:
Expand All @@ -43,7 +43,7 @@ get-commit-hash:

.PHONY: version
version:
@echo $(VERSION)
@echo $(ROXIE_VERSION)

# Build targets
.PHONY: build
Expand Down Expand Up @@ -176,7 +176,7 @@ IMAGE_DEFAULT_REGISTRY := localhost
IMAGE_REGISTRY := $(shell if [ -z "$(IMAGE_REGISTRY)" ]; then echo $(IMAGE_DEFAULT_REGISTRY); else echo $(IMAGE_REGISTRY); fi)
IMAGE_NAME := roxie
IMAGE_LATEST_TAG := $(IMAGE_REGISTRY)/$(IMAGE_NAME):latest
IMAGE_VERSION_TAG := $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(VERSION)
IMAGE_VERSION_TAG := $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(ROXIE_VERSION)
CONTAINER_RUNTIME ?= $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null)

# Multi-architecture support
Expand All @@ -191,7 +191,7 @@ docker-build: ## Build roxie Docker image for current platform
exit 1; \
fi
$(CONTAINER_RUNTIME) build \
--build-arg VERSION=$(VERSION) \
--build-arg ROXIE_VERSION=$(ROXIE_VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_LATEST_TAG) \
Expand All @@ -211,7 +211,7 @@ docker-build-arm64: ## Build roxie Docker image for arm64
fi
$(CONTAINER_RUNTIME) build \
--platform linux/arm64 \
--build-arg VERSION=$(VERSION) \
--build-arg ROXIE_VERSION=$(ROXIE_VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_LATEST_TAG)-arm64 \
Expand All @@ -230,7 +230,7 @@ docker-build-amd64: ## Build roxie Docker image for amd64
fi
$(CONTAINER_RUNTIME) build \
--platform linux/amd64 \
--build-arg VERSION=$(VERSION) \
--build-arg ROXIE_VERSION=$(ROXIE_VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_LATEST_TAG)-amd64 \
Expand Down
Loading