Skip to content

Commit 72eaf67

Browse files
Distribute connect-kafka
1 parent 802c0db commit 72eaf67

File tree

5 files changed

+126
-5
lines changed

5 files changed

+126
-5
lines changed

Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM ubuntu
2+
3+
COPY target/connect-kafka-linux-amd64 /connect-kafka
4+
5+
ENTRYPOINT ["/connect-kafka"]

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ build: main.go
55
clean:
66
@rm -rf target
77

8-
.PHONY: clean
8+
docker:
9+
@./package.sh linux > /dev/null
10+
@docker build -t segment/connect-kafka . > /dev/null
11+
12+
docker-push: docker
13+
@docker push segment/connect-kafka
14+
15+
.PHONY: clean docker

README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Release: `ALPHA`
1111

1212
- Easily forward web, mobile, server analytics events to your Kafka instance
1313
- Deploys in your infrastructure
14-
- Supports any Kafka cluster
14+
- Supports any Kafka cluster
1515
- Built with [Heroku Kafka](https://www.heroku.com/kafka) support in mind (with public/private space support)
1616
- Deploys in 5 minutes
1717
- Allows SSL (or not) connections
@@ -24,11 +24,26 @@ Release: `ALPHA`
2424

2525
### Connect to Kafka
2626

27+
Download `connect-kafka` using curl:
28+
29+
```bash
30+
curl -s https://connect.segment.com.s3-us-west-2.amazonaws.com/connect-kafka-install.sh | sh
2731
```
28-
go get -u github.com/segment-integrations/connect-kafka
32+
33+
If you just want the binary and install it yourself:
34+
35+
```bash
36+
https://connect.segment.com.s3-us-west-2.amazonaws.com/connect-kafka-darwin-amd64
37+
```
38+
39+
You can also use Docker:
40+
41+
```bash
42+
make docker
43+
docker run segment/connect-kafka [...]
2944
```
3045

31-
You can connect to any internal Kafka deployment.
46+
You can connect to any internal Kafka deployment.
3247

3348
```
3449
$ connect-kafka -h
@@ -84,7 +99,7 @@ connect-kafka \
8499

85100
### via localtunnel
86101

87-
You can open up a localtunnel on your local machine while you're testing:
102+
You can open up a localtunnel on your local machine while you're testing:
88103

89104
```
90105
npm install -g localtunnel

install.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Install Script
2+
# Usage: curl -s $addr | sh
3+
4+
platform='unknown'
5+
host='https://connect.segment.com.s3-us-west-2.amazonaws.com'
6+
binary='connect-kafka'
7+
install_dir='/usr/local/bin'
8+
arch='amd64'
9+
10+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
11+
platform='linux'
12+
elif [[ "$OSTYPE" == "darwin"* ]]; then
13+
platform='darwin'
14+
elif [[ "$OSTYPE" == "cygwin" ]]; then
15+
platform='windows'
16+
elif [[ "$OSTYPE" == "msys" ]]; then
17+
platform='windows'
18+
elif [[ "$OSTYPE" == "win32" ]]; then
19+
echo 'Platform is not supported!'
20+
exit 1
21+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
22+
platform='freebsd'
23+
else
24+
echo 'Platform is not supported!'
25+
exit 1
26+
fi
27+
28+
echo "Installing $binary for $platform/$arch..."
29+
echo "Debug $host/$binary-$platform-$arch"
30+
31+
curl -s "$host/$binary-$platform-$arch" >> "$install_dir/$binary"
32+
chmod +x $install_dir/$binary
33+
34+
size=$(wc -c <"$install_dir/$binary")
35+
36+
echo "Size: $size"
37+
38+
echo "$binary was installed successfully to $install_dir"

package.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# The more popular operating systems that Go supports.
2+
platforms=(darwin openbsd freebsd linux)
3+
arch=amd64
4+
bucket='connect.segment.com'
5+
install="install-connect-kafka.sh"
6+
name="connect-kafka"
7+
host='https://connect.segment.com.s3-us-west-2.amazonaws.com'
8+
9+
if hash gpg 2>/dev/null; then
10+
echo 'gpg was found, skipping...'
11+
else
12+
echo 'gpg is not installed. Using homebrew to install it...'
13+
brew install gpg
14+
fi
15+
16+
17+
build() {
18+
local platform=$1
19+
20+
rm -rf target
21+
mkdir -p target
22+
23+
echo "Building for $platform on $arch"
24+
GOOS=$platform GOARCH=$arch go build -ldflags "-s -w" -o target/$name-$platform-$arch
25+
}
26+
27+
build_all() {
28+
for i in "${platforms[@]}"
29+
do
30+
build $i
31+
done
32+
}
33+
34+
upload() {
35+
echo "Uploading artifacts to s3..."
36+
37+
# Upload the targets to the production S3 bucket.
38+
aws-vault exec production -- aws s3 cp target/ s3://$bucket/ --recursive
39+
aws-vault exec production -- aws s3 cp install.sh s3://$bucket/$install
40+
41+
echo "\n\nInstall script available at $host/$install"
42+
echo "\nTo install, run:"
43+
echo "-------------------------------------------"
44+
echo " $ curl -s $host/$install | sh "
45+
echo "-------------------------------------------"
46+
}
47+
48+
case $1 in
49+
linux)
50+
build 'linux'
51+
;;
52+
*)
53+
build_all
54+
upload
55+
;;
56+
esac

0 commit comments

Comments
 (0)