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

Commit ccb697c

Browse files
committed
Packaging GoRTR
* Travis-CI now automatically compiles GoRTR for Linux, Mac OS and Windows * Version number inserted at build time based on tag * Packages deb/rpm * Publishes into GitHub Releases
1 parent 3c08cff commit ccb697c

File tree

8 files changed

+176
-10
lines changed

8 files changed

+176
-10
lines changed

.travis.yml

+42-6
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

+68
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

+29-2
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,30 @@ $ docker run -ti -v $PWD/mynewkey.pem:/private.pem cloudflare/gortr -ssh.bind :8
7575

7676
## Install it
7777

78+
There are a few solutions to install it.
79+
80+
Go can directly fetch it from the source
81+
7882
```bash
7983
$ go get github.com/cloudflare/gortr/cmd/gortr
8084
```
8185

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

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

93111
## Run it
94112

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

98115
```bash
99116
$ ./gortr -tls.bind 127.0.0.1:8282
100117
```
101118

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

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

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

cmd/gortr/gortr.go

+4-2
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

+11
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

+9
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GORTR_ARGS=

package/gortr.service

+12
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)