Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit e9408ad

Browse files
authored
Merge pull request #22 from cloudflare/feature/travis-update
Packaging GoRTR
2 parents b67abf1 + ccb697c commit e9408ad

File tree

8 files changed

+176
-10
lines changed

8 files changed

+176
-10
lines changed

.travis.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
1-
language: go
2-
3-
go:
4-
- "1.10.x"
5-
- "1.11.x"
6-
- master
1+
jobs:
2+
include:
3+
# Test
4+
- stage: test
5+
os: linux
6+
language: go
7+
env:
8+
GO111MODULE=on
9+
script:
10+
- make vet
11+
# Compile
12+
- stage: compile
13+
os: linux
14+
language: go
15+
env:
16+
GO111MODULE=on
17+
BUILDINFOSDET=-travis
18+
before_install:
19+
- sudo apt-get update
20+
- sudo apt-get install -y rpm ruby ruby-dev
21+
- sudo gem install fpm
22+
script:
23+
- make dist-key
24+
- GOOS=linux make build-gortr
25+
- GOOS=darwin make build-gortr
26+
- GOOS=windows EXTENSION=.exe make build-gortr
27+
- make package-deb-gortr package-rpm-gortr
28+
deploy:
29+
provider: releases
30+
api_key:
31+
secure: V0/TVQR5gKR/NyHm7BNpyoFny4j1rsE6jSXcKhOo8AEXcvNoGoWys4PrBRFOMGIk9lKZ+yR74vY5qm7bY09DZh0cHPM/NINBQIq+btrc5l3FAia54gWSBa5GaQ+rex2i9xoK+3ueYsG7l4RQQ2CcIB3CkSf7JV9JNpUh5OgaYb12h/7pZW9ik3VJ7lAIGNoJ1KifbjIfh5aJ5yz186gbMJrskrEb9E/WFGdA4fV03eqrGdG+G6oP5QlpR4Xwhpis5+TA9UmJ4gwcEbR7HaMNifr5BQilyJSGpFeFkhGLeX65EFiqsHRgiOoEXR5NLPH5OVgyBPTZ6EN3RSF5GLnKEuAQ0lSIjjRtOPWf+8dEKZrNCvqGZk/5EA2HLItw2b8NeeZLO/i5RxxiXRhFDMLb1R5yo1Xm66M/s/7y5qSUZNc42Opf80M4VvkRMWVOiE4YfpFlnkzrI4FBRB24q7W7erNMm/CthPK6xbVmtZf6tVnUEpeY/wHuDaYihUNs7UW8C+xjiq22ufEU2v5j37IEia5Avpg8Cl+/HFy6H3MXpf3mr+KK/SM5VmMmERoIi5PKVp3xBb0RZuBGdY1sHIdYarDOiNXoXrcIpDiXuIHtN5q/TRfMIYk84qA1RPcfn1sMEn/LB7JCmBs4dUivw3oqPC4A2twnhucjv1A9sWGQY18=
32+
file_glob: true
33+
file: dist/*
34+
skip_cleanup: true
35+
on:
36+
tags: true
37+
repo: cloudflare/gortr
38+
- dist: trusty
39+
services:
40+
- docker
41+
script:
42+
- make docker-gortr

Makefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
EXTENSION ?=
2+
DIST_DIR ?= dist/
3+
GOOS ?= linux
4+
ARCH ?= $(shell uname -m)
5+
BUILDINFOSDET ?=
6+
7+
GORTR_NAME := gortr
8+
GORTR_VERSION := $(shell git describe --tags $(git rev-list --tags --max-count=1))
9+
VERSION_PKG := $(shell echo $(GORTR_VERSION) | sed 's/^v//g')
10+
ARCH := x86_64
11+
LICENSE := BSD-3
12+
URL := https://github.com/cloudflare/gortr
13+
DESCRIPTION := GoRTR: a RPKI-to-Router server
14+
BUILDINFOS := ($(shell date +%FT%T%z)$(BUILDINFOSDET))
15+
LDFLAGS := '-X main.version=$(GORTR_VERSION) -X main.buildinfos=$(BUILDINFOS)'
16+
17+
OUTPUT_GORTR := $(DIST_DIR)gortr-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
18+
19+
.PHONY: vet
20+
vet:
21+
go vet cmd/gortr/gortr.go
22+
23+
.PHONY: prepare
24+
prepare:
25+
mkdir -p $(DIST_DIR)
26+
27+
.PHONY: clean
28+
clean:
29+
rm -rf $(DIST_DIR)
30+
31+
.PHONY: dist-key
32+
dist-key: prepare
33+
cp cmd/gortr/cf.pub $(DIST_DIR)
34+
35+
.PHONY: build-gortr
36+
build-gortr: prepare
37+
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GORTR) cmd/gortr/gortr.go
38+
39+
.PHONY: docker-gortr
40+
docker-gortr:
41+
docker build -t $(GORTR_NAME):$(GORTR_VERSION) -f Dockerfile.gortr .
42+
43+
.PHONY: package-deb-gortr
44+
package-deb-gortr: prepare
45+
fpm -s dir -t deb -n $(GORTR_NAME) -v $(VERSION_PKG) \
46+
--description "$(DESCRIPTION)" \
47+
--url "$(URL)" \
48+
--architecture $(ARCH) \
49+
--license "$(LICENSE)" \
50+
--deb-no-default-config-files \
51+
--package $(DIST_DIR) \
52+
$(OUTPUT_GORTR)=/usr/bin/gortr \
53+
package/gortr.service=/lib/systemd/system/gortr.service \
54+
package/gortr.env=/etc/default/gortr \
55+
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub
56+
57+
.PHONY: package-rpm-gortr
58+
package-rpm-gortr: prepare
59+
fpm -s dir -t rpm -n $(GORTR_NAME) -v $(VERSION_PKG) \
60+
--description "$(DESCRIPTION)" \
61+
--url "$(URL)" \
62+
--architecture $(ARCH) \
63+
--license "$(LICENSE) "\
64+
--package $(DIST_DIR) \
65+
$(OUTPUT_GORTR)=/usr/bin/gortr \
66+
package/gortr.service=/lib/systemd/system/gortr.service \
67+
package/gortr.env=/etc/default/gortr \
68+
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,30 @@ $ docker run -ti -v $PWD/mynewkey.pem:/private.pem cloudflare/gortr -ssh.bind :8
7878

7979
## Install it
8080

81+
There are a few solutions to install it.
82+
83+
Go can directly fetch it from the source
84+
8185
```bash
8286
$ go get github.com/cloudflare/gortr/cmd/gortr
8387
```
8488

8589
Copy `cf.pub` to your local directory if you want to use Cloudflare's signed JSON file.
8690

91+
You can use the Makefile (by default it will be compiled for Linux, add `GOOS=darwin` for Mac)
92+
93+
```bash
94+
$ make dist-key build-gortr
95+
```
96+
97+
The compiled file will be in `/dist`.
98+
99+
Or you can use a package (or binary) file from the [Releases page](https://github.com/cloudflare/gortr/releases):
100+
```bash
101+
$ sudo dpkg -i gortr[...].deb
102+
$ sudo systemctl start gortr
103+
```
104+
87105
If you want to sign your list of prefixes, generate an ECDSA key.
88106
Then generate the public key to be used in GoRTR.
89107
You will have to setup your validator to use this key or have another
@@ -95,15 +113,24 @@ $ openssl ec -in private.pem -pubout -outform pem > public.pem
95113

96114
## Run it
97115

98-
Once you have a binary, from either the `~/go/bin/` (if you did `go get` or `go build`)
99-
or the [Releases page](https://github.com/cloudflare/gortr/releases):
116+
Once you have a binary:
100117

101118
```bash
102119
$ ./gortr -tls.bind 127.0.0.1:8282
103120
```
104121

105122
Make sure cf.pub is in the current directory. Or pass `-verify.key=path/to/cf.pub`
106123

124+
## Package it
125+
126+
If you want to package it (deb/rpm), you can use the pre-built docker-compose file.
127+
128+
```bash
129+
$ docker-compose -f docker-compose-pkg.yml up
130+
```
131+
132+
You can find both files in the `dist/` directory.
133+
107134
### With SSL
108135

109136
You can run GoRTR and listen for TLS connections only (just pass `-bind ""`).

cmd/gortr/gortr.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import (
3232
)
3333

3434
const (
35-
AppVersion = "GoRTR 0.11.0"
36-
3735
ENV_SSH_PASSWORD = "RTR_SSH_PASSWORD"
3836
ENV_SSH_KEY = "GORTR_SSH_AUTHORIZEDKEYS"
3937

@@ -43,6 +41,10 @@ const (
4341
)
4442

4543
var (
44+
version = ""
45+
buildinfos = ""
46+
AppVersion = "GoRTR " + version + " " + buildinfos
47+
4648
MetricsAddr = flag.String("metrics.addr", ":8080", "Metrics address")
4749
MetricsPath = flag.String("metrics.path", "/metrics", "Metrics path")
4850
RTRVersion = flag.Int("protocol", 1, "RTR protocol version")

docker-compose-pkg.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
services:
3+
packager:
4+
build: package
5+
entrypoint: make
6+
command:
7+
- build-gortr
8+
- package-deb-gortr
9+
- package-rpm-gortr
10+
volumes:
11+
- ./:/work/

package/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ruby
2+
3+
RUN apt-get update && \
4+
apt-get install -y git make rpm golang && \
5+
gem install fpm
6+
7+
WORKDIR /work
8+
9+
ENTRYPOINT [ "/bin/bash" ]

package/gortr.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GORTR_ARGS=

package/gortr.service

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=GoRTR
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
EnvironmentFile=/etc/default/gortr
8+
WorkingDirectory=/usr/share/gortr
9+
ExecStart=/usr/bin/gortr $GORTR_ARGS
10+
11+
[Install]
12+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)