Skip to content

Commit

Permalink
Docker image (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 authored Oct 31, 2021
1 parent cef9bed commit 34a61d8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
env:
# The hostname used to communicate with the PostgreSQL service container
OTF_DATABASE: postgres://postgres:postgres@postgres/postgres
-
name: login to docker hub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u leg100 --password-stdin
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand All @@ -49,3 +52,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OTF_TEST_DATABASE_URL: postgres://postgres:postgres@postgres/postgres

10 changes: 10 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ archives:
- format: zip
files:
- none*
dockers:
- goos: linux
goarch: amd64
ids:
- otfd
image_templates:
- "leg100/otf:latest"
- "leg100/otf:{{ .Version }}"
skip_push: auto
dockerfile: Dockerfile
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
File renamed without changes.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
VERSION = $(shell git describe --tags --dirty --always)
GIT_COMMIT = $(shell git rev-parse HEAD)
RANDOM_SUFFIX := $(shell cat /dev/urandom | tr -dc 'a-z0-9' | head -c5)
IMAGE_NAME = otf
IMAGE_TAG ?= $(VERSION)-$(RANDOM_SUFFIX)
LD_FLAGS = " \
-X '.Version=$(VERSION)' \
-X '.Commit=$(GIT_COMMIT)' \
Expand All @@ -26,7 +29,7 @@ unit:

.PHONY: build
build:
go build -o _build/ -ldflags $(LD_FLAGS) ./...
CGO_ENABLED=0 go build -o _build/ -ldflags $(LD_FLAGS) ./...
chmod -R +x _build/*

.PHONY: install
Expand Down Expand Up @@ -59,3 +62,14 @@ fmt:
.PHONY: vet
vet:
go vet ./...

# Build docker image
.PHONY: image
image: build
docker build -f Dockerfile -t $(IMAGE_NAME):$(IMAGE_TAG) -t $(IMAGE_NAME):latest ./_build

# Push docker image
.PHONY: push
push: image
docker tag $(IMAGE_NAME):latest $(IMAGE_TARGET)
docker push $(IMAGE_TARGET)

0 comments on commit 34a61d8

Please sign in to comment.