Skip to content

Commit

Permalink
ci: docker build/push
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse0Michael committed Aug 26, 2020
1 parent ad7500c commit c18d7a9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ jobs:
- name: Semantic Release
uses: ridedott/release-me-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Build
run: |
docker build --file ./build/Dockerfile -t docker.pkg.github.com/jesse0michael/go-rest-assured/assured:${REF##*/} .
- name: Push
run: |
docker login docker.pkg.github.com -u Jesse0Michael -p ${{ secrets.PAT }}
docker push docker.pkg.github.com/jesse0michael/go-rest-assured/assured:${REF##*/}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
COVERAGEDIR = .coverage
LDFLAGS = -ldflags '-X main.gitSHA=$(shell git rev-parse HEAD)'
GITSHA = $(shell git rev-parse HEAD)
LDFLAGS = -ldflags '-X main.gitSHA=$(GITSHA)'

all: build test cover
dependencies:
go mod download
build:
if [ ! -d bin ]; then mkdir bin; fi
go build $(LDFLAGS) -v -o bin/go-rest-assured
docker-build:
docker build -f ./build/Dockerfile -t go-rest-assured:$(GITSHA) .
fmt:
go mod tidy
gofmt -w -l -s *.go
Expand Down
34 changes: 34 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM golang:1.14-alpine AS build

# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates

# Copy project files
WORKDIR /go/src
COPY go.mod .
COPY go.sum .
RUN mkdir /dir

# Fetch dependencies
RUN go mod download
COPY . .

# Fetch dependencies (go mod)
RUN go mod download
RUN go mod verify

# Build project
ENV CGO_ENABLED=0
RUN go build -o go-rest-assured ./cmd/go-assured

FROM scratch AS runtime

# Copy dependent files
COPY --from=build /go/src/go-rest-assured ./
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

EXPOSE 8080/tcp

ENTRYPOINT ["./go-rest-assured"]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/jesse0michael/go-rest-assured

go 1.12
go 1.14

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down

0 comments on commit c18d7a9

Please sign in to comment.