Skip to content

Commit

Permalink
now create artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancurrah committed Apr 19, 2020
1 parent 04bf607 commit 2be595c
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
31 changes: 31 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
builds:
- main: ./cmd/gomodguard/main.go
env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
dockers:
- goos: linux
goarch: amd64
binaries:
- gomodguard
image_templates:
- "ryancurrah/gomodguard:latest"
- "ryancurrah/gomodguard:{{.Tag}}"
skip_push: false
dockerfile: Dockerfile.goreleaser
build_flag_templates:
- "--pull"
- "--build-arg=gomodguard_VERSION={{.Version}}"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG GO_VERSION=1.14.2
ARG ALPINE_VERSION=3.11
ARG gomodguard_VERSION=

# ---- Build container
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
WORKDIR /gomodguard
COPY . .
RUN apk add --no-cache git
RUN go build -o gomodguard cmd/gomodguard/main.go

# ---- App container
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION}
WORKDIR /
RUN apk --no-cache add ca-certificates
COPY --from=builder gomodguard/gomodguard /
ENTRYPOINT ./gomodguard
10 changes: 10 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG GO_VERSION=1.14.2
ARG ALPINE_VERSION=3.11
ARG gomodguard_VERSION=

# ---- App container
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION}
WORKDIR /
RUN apk --no-cache add ca-certificates
COPY gomodguard /gomodguard
ENTRYPOINT ./gomodguard
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
current_dir = $(shell pwd)
version = $(shell printf '%s' $$(cat VERSION))

.PHONEY: lint
lint:
golangci-lint run -v --enable-all --disable funlen,gochecknoglobals,lll ./...

.PHONEY: build
build:
go build -o gomodguard cmd/gomodguard/main.go

.PHONEY: dockerbuild
dockerbuild:
docker build --build-arg GOMODGUARD_VERSION=${version} --tag ryancurrah/gomodguard:${version} .

.PHONEY: run
run-basicauth: build
./gomodguard

.PHONEY: dockerrun
dockerrun: dockerbuild
docker run -v "${current_dir}/.gomodguard.yaml:/.gomodguard.yaml" ryancurrah/gomodguard:latest

.PHONEY: release
release:
git tag ${version}
git push --tags
goreleaser --skip-validate --rm-dist

.PHONEY: clean
clean:
rm -rf dist/
rm -f gomodguard

.PHONEY: install-tools-mac
install-tools-mac:
brew install goreleaser/tap/goreleaser
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.3
File renamed without changes.

0 comments on commit 2be595c

Please sign in to comment.