Skip to content

Commit

Permalink
downsize webhook image.
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed Dec 7, 2016
1 parent 4ad5411 commit 04171ce
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pipeline:
- make lint
- make test
- make build
# build binary for docker hub
- make docker_build
# build binary for docker image
- make static_build
when:
event: [ push, tag, pull_request ]

Expand Down Expand Up @@ -52,7 +52,7 @@ pipeline:
image: plugins/docker
repo: appleboy/drone-line-webhook
tags: [ '${DRONE_TAG}' ]
dockerfile: example/Dockerfile
dockerfile: example/Dockerfile.webhook
when:
event: [ tag ]
branch: [ refs/tags/* ]
Expand All @@ -61,7 +61,7 @@ pipeline:
image: plugins/docker
repo: appleboy/drone-line-webhook
tags: [ 'latest' ]
dockerfile: example/Dockerfile
dockerfile: example/Dockerfile.webhook
when:
event: [ push ]
branch: [ master ]
Expand Down
2 changes: 1 addition & 1 deletion .drone.yml.sig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9zcnYvYXBwCiAgcGF0aDogc3JjL2dpdGh1Yi5jb20vYXBwbGVib3kvZHJvbmUtbGluZQoKcGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBhcHBsZWJveS9nb2xhbmctdGVzdGluZwogICAgcHVsbDogdHJ1ZQogICAgZW52aXJvbm1lbnQ6CiAgICAgIFRBR1M6IG5ldGdvCiAgICAgIEdPUEFUSDogL3Nydi9hcHAKICAgIGNvbW1hbmRzOgogICAgICAtIG1ha2UgZGVwX2luc3RhbGwKICAgICAgLSBtYWtlIHZldAogICAgICAtIG1ha2UgbGludAogICAgICAtIG1ha2UgdGVzdAogICAgICAtIG1ha2UgYnVpbGQKICAgICAgIyBidWlsZCBiaW5hcnkgZm9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29sYW5nLXRlc3RpbmcKICAgIHB1bGw6IHRydWUKICAgIGVudmlyb25tZW50OgogICAgICBUQUdTOiBuZXRnbwogICAgICBHT1BBVEg6IC9zcnYvYXBwCiAgICBjb21tYW5kczoKICAgICAgLSBtYWtlIHJlbGVhc2UKICAgIHdoZW46CiAgICAgIGV2ZW50OiBbIHRhZyBdCiAgICAgIGJyYW5jaDogWyByZWZzL3RhZ3MvKiBdCgogIGRvY2tlcjoKICAgIGltYWdlOiBwbHVnaW5zL2RvY2tlcgogICAgcmVwbzogYXBwbGVib3kvZHJvbmUtbGluZQogICAgdGFnczogWyAnJHtEUk9ORV9UQUd9JyBdCiAgICB3aGVuOgogICAgICBldmVudDogWyB0YWcgXQogICAgICBicmFuY2g6IFsgcmVmcy90YWdzLyogXQoKICBkb2NrZXI6CiAgICBpbWFnZTogcGx1Z2lucy9kb2NrZXIKICAgIHJlcG86IGFwcGxlYm95L2Ryb25lLWxpbmUKICAgIHRhZ3M6IFsgJ2xhdGVzdCcgXQogICAgd2hlbjoKICAgICAgZXZlbnQ6IFsgcHVzaCBdCiAgICAgIGJyYW5jaDogWyBtYXN0ZXIgXQoKICBkb2NrZXJfd2ViaG9vazoKICAgIGltYWdlOiBwbHVnaW5zL2RvY2tlcgogICAgcmVwbzogYXBwbGVib3kvZHJvbmUtbGluZS13ZWJob29rCiAgICB0YWdzOiBbICcke0RST05FX1RBR30nIF0KICAgIGRvY2tlcmZpbGU6IGV4YW1wbGUvRG9ja2VyZmlsZS53ZWJob29rCiAgICB3aGVuOgogICAgICBldmVudDogWyB0YWcgXQogICAgICBicmFuY2g6IFsgcmVmcy90YWdzLyogXQoKICBkb2NrZXJfd2ViaG9vazoKICAgIGltYWdlOiBwbHVnaW5zL2RvY2tlcgogICAgcmVwbzogYXBwbGVib3kvZHJvbmUtbGluZS13ZWJob29rCiAgICB0YWdzOiBbICdsYXRlc3QnIF0KICAgIGRvY2tlcmZpbGU6IGV4YW1wbGUvRG9ja2VyZmlsZS53ZWJob29rCiAgICB3aGVuOgogICAgICBldmVudDogWyBwdXNoIF0KICAgICAgYnJhbmNoOiBbIG1hc3RlciBdCgogIGdpdGh1YjoKICAgIGltYWdlOiBwbHVnaW5zL2dpdGh1Yi1yZWxlYXNlCiAgICBmaWxlczoKICAgICAgLSBkaXN0L3JlbGVhc2UvKgogICAgd2hlbjoKICAgICAgZXZlbnQ6IFsgdGFnIF0KICAgICAgYnJhbmNoOiBbIHJlZnMvdGFncy8qIF0K.6NbdKGSKRdjO3x0rl0pfF7LvIi0jTHxtne_h9vzNQnc
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ drone-line
coverage.txt
.env
dist
drone-line-webhook
27 changes: 13 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
sudo: required
language: go

services:
- docker
# services:
# - docker

go:
- 1.6.4
- 1.7.4
- tip

env:
global:
- DOCKER_CACHE_FILE=${HOME}/docker/cache.tar.gz
# env:
# global:
# - DOCKER_CACHE_FILE=${HOME}/docker/cache.tar.gz

cache:
directories:
- vendor
- ${HOME}/.glide
- ${HOME}/docker
# - ${HOME}/docker

before_install:
- mkdir -p $GOPATH/bin
- curl https://glide.sh/get | sh
- if [ -f ${DOCKER_CACHE_FILE} ]; then gunzip -c ${DOCKER_CACHE_FILE} | docker load; fi
# - if [ -f ${DOCKER_CACHE_FILE} ]; then gunzip -c ${DOCKER_CACHE_FILE} | docker load; fi

install:
- export GO15VENDOREXPERIMENT=1
- make clean
- make dep_install

script:
- make vet
- make lint
- make test
- make build
- make docker
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
mkdir -p $(dirname ${DOCKER_CACHE_FILE});
docker save $(docker history -q $TRAVIS_REPO_SLUG:latest | grep -v '<missing>') | gzip > ${DOCKER_CACHE_FILE};
fi
# - make build
# - make docker
# - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
# mkdir -p $(dirname ${DOCKER_CACHE_FILE});
# docker save $(docker history -q $TRAVIS_REPO_SLUG:latest | grep -v '<missing>') | gzip > ${DOCKER_CACHE_FILE};
# fi

after_success:
# ignore main.go coverage
Expand Down
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ DIST := dist
EXECUTABLE := drone-line

# for dockerhub
DEPLOY_ACCOUNT := "appleboy"
DEPLOY_ACCOUNT := appleboy
DEPLOY_IMAGE := $(EXECUTABLE)
DEPLOY_WEBHOOK_IMAGE := "$(EXECUTABLE)-webhook"
DEPLOY_WEBHOOK_IMAGE := $(EXECUTABLE)-webhook

SHA := $(shell git rev-parse --short HEAD)
TARGETS ?= linux/*,darwin/*
Expand Down Expand Up @@ -88,16 +88,22 @@ release-copy:
release-check:
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)

docker_build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '$(LDFLAGS)'
# for docker.
static_build: line_build line_webhook_build

line_build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $(DEPLOY_IMAGE)

line_webhook_build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $(DEPLOY_WEBHOOK_IMAGE) example/server.go

docker_image:
docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) .

docker_webhook_image:
docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_WEBHOOK_IMAGE) -f example/Dockerfile .
docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_WEBHOOK_IMAGE) -f example/Dockerfile.webhook .

docker: docker_build docker_image docker_webhook_image
docker: static_build docker_image docker_webhook_image

docker_deploy:
ifeq ($(tag),)
Expand All @@ -113,7 +119,7 @@ endif

clean:
go clean -x -i ./...
rm -rf coverage.txt $(EXECUTABLE) $(DIST) vendor
rm -rf coverage.txt $(EXECUTABLE) $(DIST) vendor $(DEPLOY_WEBHOOK_IMAGE)

version:
@echo $(VERSION)
9 changes: 9 additions & 0 deletions example/Dockerfile.webhook
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM centurylink/ca-certs

ENV PORT 8089

ADD drone-line-webhook /

EXPOSE $PORT

ENTRYPOINT ["/drone-line-webhook"]

0 comments on commit 04171ce

Please sign in to comment.