Skip to content

Commit

Permalink
Merge pull request #9 from vshn/cleanup
Browse files Browse the repository at this point in the history
Repo Cleanup
  • Loading branch information
mhutter authored Oct 10, 2023
2 parents a4a479b + d85281f commit 11a8940
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 85 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!*.go
!go.*
!config.yml
!Makefile
!VERSION
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cortex-tenant
cortex-tenant-ns-label
sink
generate
.out
Expand Down
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN go mod download
COPY . .
RUN make build

FROM busybox
FROM docker.io/library/busybox:latest
COPY --from=builder /build/cortex-tenant-ns-label /
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=docker.io/library/alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
CMD ["/bin/sh", "-c", "/bin/echo \"${CONFIG}\" > /tmp/cortex-tenant.yml; /cortex-tenant-ns-label -config /tmp/cortex-tenant.yml"]
84 changes: 13 additions & 71 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,80 +1,22 @@
NAME := cortex-tenant
MAINTAINER := Igor Novgorodov
DESCRIPTION := Cortex tenant proxy
URL := https://github.com/blind-oracle/cortex-tenant
LICENSE := MPL

NAME := cortex-tenant-ns-label
VERSION := $(shell cat VERSION)
RELEASE := 1
GO_SRC := $(wildcard *.go)

GO ?= go
OUT := .out

all: rpm deb
.PHONY: test
test:
go test ./...

.PHONY: build
build: test $(NAME)

build:
go test ./... && \
$(NAME): $(GO_SRC)
CGO_ENABLED=0 \
GOARCH=amd64 \
GOOS=linux \
$(GO) build -a -tags netgo -ldflags '-s -w -extldflags "-static" -X main.version=$(VERSION)'

prepare:
cd deploy && \
rm -rf $(OUT) && \
mkdir -p $(OUT)/etc $(OUT)/usr/sbin $(OUT)/var/lib/$(NAME) $(OUT)/usr/lib/systemd/system && \
cp $(NAME).yml $(OUT)/etc/$(NAME).yml && \
cp ../$(NAME) $(OUT)/usr/sbin

rpm: build prepare build-rpm
deb: build prepare build-deb

build-rpm:
cd deploy && \
mkdir -p $(OUT)/etc/sysconfig && \
cp $(NAME).env $(OUT)/etc/sysconfig/$(NAME) && \
cp $(NAME).rpm.service $(OUT)/usr/lib/systemd/system/$(NAME).service

fpm \
-s dir \
--config-files etc/$(NAME).yml \
--config-files etc/sysconfig/$(NAME) \
-C deploy/$(OUT)/ \
-t rpm \
--after-install deploy/after_install.sh \
-n $(NAME) \
-v $(VERSION) \
--iteration $(RELEASE) \
--force \
--rpm-compression bzip2 \
--rpm-os linux \
--url $(URL) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a amd64 \
.

build-deb:
cd deploy && \
mkdir -p $(OUT)/etc/default && \
cp $(NAME).env $(OUT)/etc/default/$(NAME) && \
cp $(NAME).deb.service $(OUT)/usr/lib/systemd/system/$(NAME).service
$(GO) build -a -tags netgo -ldflags '-s -w -extldflags "-static" -X main.version=$(VERSION)' -o $@

fpm \
-s dir \
--config-files etc/$(NAME).yml \
--config-files etc/default/$(NAME) \
-C deploy/$(OUT)/ \
-t deb \
--after-install deploy/after_install.sh \
-n $(NAME) \
-v $(VERSION) \
--iteration $(RELEASE) \
--force \
--url $(URL) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a amd64 \
.
.PHONY: clean
clean:
rm -f $(NAME)

0 comments on commit 11a8940

Please sign in to comment.