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
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,19 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
FROM golang:latest AS builder

ARG TARGETOS
ARG TARGETARCH

ENV GO111MODULE=on \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
CGO_ENABLED=0

WORKDIR /build
Expand All @@ -11,16 +16,11 @@ COPY go.sum .
RUN go mod download

COPY . .
RUN make build
RUN OS=${TARGETOS} ARCH=${TARGETARCH} make build

WORKDIR /dist

RUN cp /build/cortex-tenant ./cortex-tenant

RUN ldd cortex-tenant | tr -s '[:blank:]' '\n' | grep '^/' | \
xargs -I % sh -c 'mkdir -p $(dirname ./%); cp % ./%;'
RUN mkdir -p lib64 && cp /lib64/ld-linux-x86-64.so.2 lib64/

RUN mkdir /data && cp /build/deploy/cortex-tenant.yml /data/cortex-tenant.yml

FROM scratch
Expand Down
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ RELEASE := 1
GO ?= go
OUT := .out

OS ?= linux
ARCH ?= amd64

all: rpm deb

build:
go test ./... && \
GOARCH=amd64 \
GOOS=linux \
CGO_ENABLED=0 \
export GOARCH=$(ARCH)
export GOOS=$(OS)
export CGO_ENABLED=0
go test ./...
$(GO) build -ldflags "-s -w -extldflags \"-static\" -X main.Version=$(VERSION)"

prepare:
Expand Down Expand Up @@ -47,12 +50,12 @@ build-rpm:
--iteration $(RELEASE) \
--force \
--rpm-compression bzip2 \
--rpm-os linux \
--rpm-os $(OS) \
--url $(URL) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a amd64 \
-a $(ARCH) \
.

build-deb:
Expand All @@ -76,5 +79,5 @@ build-deb:
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a amd64 \
-a $(ARCH) \
.