Skip to content

Commit 98e6404

Browse files
feat: publish go docker image (#105)
* feat: publish go docker image
1 parent ea2f299 commit 98e6404

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ script:
99
- if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
1010
make cluster-test;
1111
fi
12+
deploy:
13+
- provider: script
14+
script: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
15+
&& make docker-build && make docker-push
16+
skip_cleanup: true
17+
on:
18+
tags: true
19+
go: '1.16'
1220
notifications:
1321
slack:
1422
if: branch = main

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.16
2+
3+
RUN mkdir /twilio
4+
WORKDIR /twilio
5+
6+
COPY client ./client
7+
COPY rest ./rest
8+
COPY twilio.go .
9+
COPY twilio_test.go .
10+
11+
# Fetch dependencies
12+
COPY go.mod .
13+
COPY go.sum .
14+
RUN go mod download

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: githooks install test goimports govet golint
1+
.PHONY: githooks install test goimports govet golint docker-build docker-push
22

33
githooks:
44
ln -sf ../../githooks/pre-commit .git/hooks/pre-commit
@@ -23,3 +23,16 @@ golint: govet
2323
go get github.com/golangci/golangci-lint/cmd/[email protected]
2424
golangci-lint run
2525
go mod tidy
26+
27+
API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5)
28+
docker-build:
29+
docker build -t twilio/twilio-go .
30+
docker tag twilio/twilio-go twilio/twilio-go:${TRAVIS_TAG}
31+
docker tag twilio/twilio-go twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA}
32+
docker tag twilio/twilio-go twilio/twilio-go:latest
33+
34+
docker-push:
35+
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
36+
docker push twilio/twilio-go:${TRAVIS_TAG}
37+
docker push twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA}
38+
docker push twilio/twilio-go:latest

0 commit comments

Comments
 (0)