Skip to content

Commit

Permalink
feat: publish go docker image (#105)
Browse files Browse the repository at this point in the history
* feat: publish go docker image
  • Loading branch information
shwetha-manvinkurke authored Jul 27, 2021
1 parent ea2f299 commit 98e6404
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ script:
- if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
make cluster-test;
fi
deploy:
- provider: script
script: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
&& make docker-build && make docker-push
skip_cleanup: true
on:
tags: true
go: '1.16'
notifications:
slack:
if: branch = main
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.16

RUN mkdir /twilio
WORKDIR /twilio

COPY client ./client
COPY rest ./rest
COPY twilio.go .
COPY twilio_test.go .

# Fetch dependencies
COPY go.mod .
COPY go.sum .
RUN go mod download
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: githooks install test goimports govet golint
.PHONY: githooks install test goimports govet golint docker-build docker-push

githooks:
ln -sf ../../githooks/pre-commit .git/hooks/pre-commit
Expand All @@ -23,3 +23,16 @@ golint: govet
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39.0
golangci-lint run
go mod tidy

API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5)
docker-build:
docker build -t twilio/twilio-go .
docker tag twilio/twilio-go twilio/twilio-go:${TRAVIS_TAG}
docker tag twilio/twilio-go twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA}
docker tag twilio/twilio-go twilio/twilio-go:latest

docker-push:
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
docker push twilio/twilio-go:${TRAVIS_TAG}
docker push twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA}
docker push twilio/twilio-go:latest

0 comments on commit 98e6404

Please sign in to comment.