1
0
mirror of https://github.com/cloudflare/gortr.git synced 2024-05-19 06:50:10 +00:00

Merge pull request #22 from cloudflare/feature/travis-update

Packaging GoRTR
This commit is contained in:
lspgn
2019-07-31 12:58:48 -07:00
committed by GitHub
8 changed files with 176 additions and 10 deletions

View File

@ -1,6 +1,42 @@
language: go
go:
- "1.10.x"
- "1.11.x"
- master
jobs:
include:
# Test
- stage: test
os: linux
language: go
env:
GO111MODULE=on
script:
- make vet
# Compile
- stage: compile
os: linux
language: go
env:
GO111MODULE=on
BUILDINFOSDET=-travis
before_install:
- sudo apt-get update
- sudo apt-get install -y rpm ruby ruby-dev
- sudo gem install fpm
script:
- make dist-key
- GOOS=linux make build-gortr
- GOOS=darwin make build-gortr
- GOOS=windows EXTENSION=.exe make build-gortr
- make package-deb-gortr package-rpm-gortr
deploy:
provider: releases
api_key:
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=
file_glob: true
file: dist/*
skip_cleanup: true
on:
tags: true
repo: cloudflare/gortr
- dist: trusty
services:
- docker
script:
- make docker-gortr

68
Makefile Normal file
View File

@ -0,0 +1,68 @@
EXTENSION ?=
DIST_DIR ?= dist/
GOOS ?= linux
ARCH ?= $(shell uname -m)
BUILDINFOSDET ?=
GORTR_NAME := gortr
GORTR_VERSION := $(shell git describe --tags $(git rev-list --tags --max-count=1))
VERSION_PKG := $(shell echo $(GORTR_VERSION) | sed 's/^v//g')
ARCH := x86_64
LICENSE := BSD-3
URL := https://github.com/cloudflare/gortr
DESCRIPTION := GoRTR: a RPKI-to-Router server
BUILDINFOS := ($(shell date +%FT%T%z)$(BUILDINFOSDET))
LDFLAGS := '-X main.version=$(GORTR_VERSION) -X main.buildinfos=$(BUILDINFOS)'
OUTPUT_GORTR := $(DIST_DIR)gortr-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
.PHONY: vet
vet:
go vet cmd/gortr/gortr.go
.PHONY: prepare
prepare:
mkdir -p $(DIST_DIR)
.PHONY: clean
clean:
rm -rf $(DIST_DIR)
.PHONY: dist-key
dist-key: prepare
cp cmd/gortr/cf.pub $(DIST_DIR)
.PHONY: build-gortr
build-gortr: prepare
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GORTR) cmd/gortr/gortr.go
.PHONY: docker-gortr
docker-gortr:
docker build -t $(GORTR_NAME):$(GORTR_VERSION) -f Dockerfile.gortr .
.PHONY: package-deb-gortr
package-deb-gortr: prepare
fpm -s dir -t deb -n $(GORTR_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE)" \
--deb-no-default-config-files \
--package $(DIST_DIR) \
$(OUTPUT_GORTR)=/usr/bin/gortr \
package/gortr.service=/lib/systemd/system/gortr.service \
package/gortr.env=/etc/default/gortr \
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub
.PHONY: package-rpm-gortr
package-rpm-gortr: prepare
fpm -s dir -t rpm -n $(GORTR_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE) "\
--package $(DIST_DIR) \
$(OUTPUT_GORTR)=/usr/bin/gortr \
package/gortr.service=/lib/systemd/system/gortr.service \
package/gortr.env=/etc/default/gortr \
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub

View File

@ -78,12 +78,30 @@ $ docker run -ti -v $PWD/mynewkey.pem:/private.pem cloudflare/gortr -ssh.bind :8
## Install it
There are a few solutions to install it.
Go can directly fetch it from the source
```bash
$ go get github.com/cloudflare/gortr/cmd/gortr
```
Copy `cf.pub` to your local directory if you want to use Cloudflare's signed JSON file.
You can use the Makefile (by default it will be compiled for Linux, add `GOOS=darwin` for Mac)
```bash
$ make dist-key build-gortr
```
The compiled file will be in `/dist`.
Or you can use a package (or binary) file from the [Releases page](https://github.com/cloudflare/gortr/releases):
```bash
$ sudo dpkg -i gortr[...].deb
$ sudo systemctl start gortr
```
If you want to sign your list of prefixes, generate an ECDSA key.
Then generate the public key to be used in GoRTR.
You will have to setup your validator to use this key or have another
@ -95,8 +113,7 @@ $ openssl ec -in private.pem -pubout -outform pem > public.pem
## Run it
Once you have a binary, from either the `~/go/bin/` (if you did `go get` or `go build`)
or the [Releases page](https://github.com/cloudflare/gortr/releases):
Once you have a binary:
```bash
$ ./gortr -tls.bind 127.0.0.1:8282
@ -104,6 +121,16 @@ $ ./gortr -tls.bind 127.0.0.1:8282
Make sure cf.pub is in the current directory. Or pass `-verify.key=path/to/cf.pub`
## Package it
If you want to package it (deb/rpm), you can use the pre-built docker-compose file.
```bash
$ docker-compose -f docker-compose-pkg.yml up
```
You can find both files in the `dist/` directory.
### With SSL
You can run GoRTR and listen for TLS connections only (just pass `-bind ""`).

View File

@ -32,8 +32,6 @@ import (
)
const (
AppVersion = "GoRTR 0.11.0"
ENV_SSH_PASSWORD = "RTR_SSH_PASSWORD"
ENV_SSH_KEY = "GORTR_SSH_AUTHORIZEDKEYS"
@ -43,6 +41,10 @@ const (
)
var (
version = ""
buildinfos = ""
AppVersion = "GoRTR " + version + " " + buildinfos
MetricsAddr = flag.String("metrics.addr", ":8080", "Metrics address")
MetricsPath = flag.String("metrics.path", "/metrics", "Metrics path")
RTRVersion = flag.Int("protocol", 1, "RTR protocol version")

11
docker-compose-pkg.yml Normal file
View File

@ -0,0 +1,11 @@
version: '3'
services:
packager:
build: package
entrypoint: make
command:
- build-gortr
- package-deb-gortr
- package-rpm-gortr
volumes:
- ./:/work/

9
package/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM ruby
RUN apt-get update && \
apt-get install -y git make rpm golang && \
gem install fpm
WORKDIR /work
ENTRYPOINT [ "/bin/bash" ]

1
package/gortr.env Normal file
View File

@ -0,0 +1 @@
GORTR_ARGS=

12
package/gortr.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=GoRTR
After=network.target
[Service]
Type=simple
EnvironmentFile=/etc/default/gortr
WorkingDirectory=/usr/share/gortr
ExecStart=/usr/bin/gortr $GORTR_ARGS
[Install]
WantedBy=multi-user.target