github.com/osrg/gobgp/v3@v3.30.0/test/lib/fabfile.py (about) 1 import os 2 from fabric import task 3 from invoke import run as local 4 from base import CmdBuffer 5 6 7 @task 8 def make_gobgp_ctn(ctx, tag='gobgp', 9 local_gobgp_path='', 10 from_image='osrg/quagga'): 11 if local_gobgp_path == '': 12 local_gobgp_path = os.getcwd() 13 14 local('CGO_ENABLED=0 go build "-ldflags=-s -w -buildid=" ./cmd/gobgp') 15 local('CGO_ENABLED=0 go build "-ldflags=-s -w -buildid=" ./cmd/gobgpd') 16 17 c = CmdBuffer() 18 c << 'FROM {0}'.format(from_image) 19 c << 'COPY gobgp/gobgpd /go/bin/gobgpd' 20 c << 'COPY gobgp/gobgp /go/bin/gobgp' 21 22 rindex = local_gobgp_path.rindex('gobgp') 23 if rindex < 0: 24 raise Exception('{0} seems not gobgp dir'.format(local_gobgp_path)) 25 26 workdir = local_gobgp_path[:rindex] 27 os.chdir(workdir) 28 local('echo \'{0}\' > Dockerfile'.format(str(c))) 29 local('docker build -t {0} .'.format(tag)) 30 local('rm Dockerfile')