Skip to content

Commit

Permalink
Fix Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
syberalexis committed Jan 16, 2021
1 parent 5ad9894 commit 393ec1e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
34 changes: 20 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
os: linux
dist: xenial
dist: focal
sudo: false

_go_build: &go_build
language: go
go: 1.14.x
go_import_path: github.com/syberalexis/linky-exporter
script: BUILD_GO111MODULE=on GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} GOARM=${BUILD_GOARM} make clean build
deploy:
provider: releases
api_key: ${GITHUB_TOKEN}
file_glob: true
file: dist/*
skip_cleanup: true
on:
branch: master
tags: true

matrix:
include:
Expand All @@ -30,17 +40,13 @@ matrix:
env: BUILD_GOOS=windows BUILD_GOARCH=arm BUILD_GOARM=7
# Docker build
- script:
- docker build -t syberalexis/linky-exporter .
- make docker
deploy:
provider: script
script: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin ; docker push syberalexis/linky-exporter
on:
branch: master
tags: true

deploy:
- provider: releases
api_key: ${GITHUB_TOKEN}
file_glob: true
file: dist/*
cleanup: true
on:
tags: true
- provider: script
script: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && docker push syberalexis/linky-exporter
on:
tags: true
notifications:
email: false
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ FROM golang:1.14 as builder
RUN mkdir /build
ADD . /build/
WORKDIR /build
RUN CGO_ENABLED=0 GOOS=linux go build -a -o linky-exporter cmd/linky-exporter/main.go
RUN CGO_ENABLED=0 GOOS=linux make build


FROM alpine:3
COPY --from=builder /build/linky-exporter .
ARG VERSION
COPY --from=builder /build/dist/linky-exporter-${VERSION}-linux-amd64 linky-exporter
RUN addgroup -S exporter && adduser -S exporter -G exporter
USER exporter
ENTRYPOINT [ "./linky-exporter" ]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dist:
mkdir $(DIST_FOLDER)

build: dist
go mod vendor
go build -o $(DIST_FOLDER)/$(PROJECT_NAME)-$(VERSION)-$(GOOS)-$(ARCH) -ldflags "-X main.version=$(VERSION)" cmd/$(PROJECT_NAME)/main.go

clean:
Expand All @@ -35,3 +36,9 @@ info:
echo "GOOS = $(GOOS)"
echo "GOARCH = $(GOARCH)"
echo "VERSION = $(VERSION)"

docker:
docker build -t syberalexis/linky-exporter --build-arg VERSION=$(VERSION) .
ifneq ($(VERSION),)
docker tag syberalexis/linky-exporter syberalexis/linky-exporter:$(VERSION)
endif

0 comments on commit 393ec1e

Please sign in to comment.