Skip to content

Commit bc727c7

Browse files
committed
Common iso base and appliance
This creates a common iso base for the appliance and the linux bootstrap. This needs to be reconnciled with the bootstrap approach but I needed something immediate and this sufficed. There is a quirk for some reason extracting the ISO from docker using stdout: $ docker run -it test-iso cat /tmp/iso > binary/appliance.iso $ md5sum binary/appliance.iso 0cf11aa283f3b390e9760fa1c46683ca binary/appliance.iso $ docker run -it test-iso md5sum /tmp/iso b631e1dbb6e1c6178154cb06ba99a5bd /tmp/iso
1 parent ed3edd1 commit bc727c7

27 files changed

+984
-61
lines changed

.drone.sec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.J9nAelahosD21RS7Qw0pysUSXZbajQkFPgH92SiuiMa1vE-TuRhscZE7z8RBtH67cVPC-LbkbzbojsKKR1q6CsVgqTfEuO6AXvWKedoi_OZM1xAXezJ64EH41QMwb04pboavREFUq30zL8jecjXYdSVAUmnpQHempDK_XtP3cCIyqU0JR51U7mGH4WUZyHydT9KO2OOYRp1iJjuhPIYbjMQb0j3Csi72Nsh65zRUZxGBBPPAefL_hTP81cc67PZMvwB-aHKrTXvq16HhjpyoUh60Z5Q-Rgs-p1vNOKEZ-q0AHf3ev5lDgOv4U5-nRJngSbZ7O27_cm_GmnZPSkE1Pw.AklVRBWFoyNKjE9O.ZlMOcN3UeB4Q_INk3KtCcdqUMRqOSfICqzRHfUvvPj6Y3eG9HSd9_bU8mZWIOqf5N-IfYJVjoEmX1VeyIkkGcBcUkf4bNtksy1y2YkYALcWJ2zhmhB8dSAfAiZFmj5OjBiEblFCub6F1rQgYkWGXrS9p5Hgbs7Mdtzs2vGyBzcYDoVJmqArMV6bAwvOiUH9Q4PnukqtBTsf51kDvSOT2OaJJpFOOEx4aBipz4K1lDE8nCULdEWyv5we3LdvOgOhP2cmoor8Pd0Gv9IxlwZtK6A2vTcRFj7vY.Hip-81Mo6BsINphL1R6c5g
1+
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.St23O7dTFvvOhS1L9Ox25cv2GmmCbhDC0tl1AlONuBjGbWubI0ZcUeYybvvhfn_vNypJWMjT4N0vdHWmYS-xhj3bhNz94de_f6tCMz7Rs154snPzUVzrzghorxpo9vgHne0DwaVPg5F_OJxh8sc5HHzkhPQGjXTFl9c9t9CJJ5yJTXx7GPlpv8saqdKJvu-UTcuepL5iqDLXJp1UIhjZjiZ_Gv6MDPwH8cf6ZZbrsK_PrH6T6W3uwPm2ne7EhOMgtRI0IYTPackRq_MjHuBzzz4YeuCnVpVT1RzU0Y0kXrWeGRrbQ_MOwjO-nKffhVYbatzFzHQ2bKCKeHGGbfc1Lw.tqobw_Kn7c5VBX0U.k2MZ1aOCeGhhXvnFul2nb3sYw_rM8hzEsgCk5ZahNt7EMbyaOADohHfXNlkLgEOFUBsdfux5RkMawnodIvZ2oyNJ5YbPkoOD4fK9ZRyPQ-WL6IYOkAIndUPo54NDH5qFiI8uzqqE0razcF1IHu4cIOACVIt-OcHDkfpZpn21QNmbDonxOF3RUBWvwNjurI72QuMzSvzSQ9ncBHoHfK-1bhDud4cMk3noNR9H3taj67w-D_4mLM0YW6DGgu0IckoedXajIbLU3ya1mOoTcwq0lXIbROyCVaX11jVXSp7iQF09AmoPub0mf_YODkUInR1AVhkTOdyT7durPPKAkux7qQwIswXo-XPgpmy3RnUgSDdY-5HGOM33-RefyAqh.oUhZJ0hoLz26PPkChLWEHg

.drone.yml

+50-6
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,71 @@
66
clone:
77
path: github.com/vmware/vic
88
tags: true
9+
910
build:
11+
components:
12+
image: golang:1.6.0
13+
pull: true
14+
environment:
15+
BIN: bin
16+
SHELL: /bin/bash
17+
commands:
18+
- make components
19+
- make install
20+
21+
iso-base:
22+
image: golang:1.6.0
23+
pull: true
24+
environment:
25+
BIN: bin
26+
commands:
27+
- make iso-base
28+
29+
appliance-staging:
30+
image: golang:1.6.0
31+
pull: true
32+
environment:
33+
BIN: bin
34+
commands:
35+
- make appliance-staging
36+
37+
appliance:
38+
image: golang:1.6.0
39+
pull: true
40+
environment:
41+
BIN: bin
42+
INIT: /lib/systemd/systemd
43+
commands:
44+
- make appliance
45+
1046
test:
1147
image: golang:1.6.0
1248
pull: true
1349
environment:
50+
BIN: bin
1451
GOPATH: /drone
1552
SHELL: /bin/bash
1653
DOCKER_API_VERSION: "1.21"
17-
VIC_ESX_TEST_URL: $$VIC_ESX_TEST_URL
1854
volumes:
1955
- "/var/run/docker.sock:/var/run/docker.sock"
2056
commands:
2157
- wget -q https://get.docker.com/builds/Linux/x86_64/docker-latest
2258
- chmod +x docker-latest
2359
- mv docker-latest /usr/local/bin/docker
24-
- make all
2560
- make test
2661
- make integration-tests
62+
when:
63+
success: true
64+
2765
bundle:
2866
image: golang:1.6.0
2967
pull: true
3068
environment:
69+
BIN: bin
3170
GOPATH: /drone
3271
SHELL: /bin/bash
3372
commands:
34-
- make all
35-
- tar -cvf vic_binaries_$$BUILD_NUMBER.tar.gz binary
73+
- tar -cvf $BIN/vic_$$BUILD_NUMBER.tar.gz $BIN/appliance.iso $BIN/install.sh
3674
when:
3775
success: true
3876

@@ -48,15 +86,21 @@ publish:
4886
username: $$BINTRAY_USERNAME
4987
api_key: $$BINTRAY_API_KEY
5088
artifacts:
51-
- file: vic_binaries_$$BUILD_NUMBER.tar.gz
89+
- file: vic_$$BUILD_NUMBER.tar.gz
5290
owner: vmware
5391
type: executable
5492
repository: vic-repo
5593
package: build
5694
version: 0.1
57-
target: vic_binaries_$$BUILD_NUMBER.tar.gz
95+
target: vic_$$BUILD_NUMBER.tar.gz
5896
publish: true
5997
when:
6098
repo: vmware/vic
6199
branch: master
62100
success: true
101+
102+
cache:
103+
mount:
104+
- /drone/bin
105+
- bin
106+

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
binary/
44
vic_binaries*.tar.gz
55
secrets.yml
6+
bin/
67

78
bootstrap/targets/linux/tether/
89
imagec/imagec
910

11+
tests/helpers/bats-assert
12+
tests/helpers/bats-support
13+
1014
apiservers/docker/cmd
1115
apiservers/docker/models
1216
apiservers/docker/restapi/*.go

Dockerfile.integration-tests

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ RUN apt-get update && apt-get upgrade -y
2020
RUN apt-get install -yq jq
2121

2222
# build imagec and port-layer-server
23-
ADD ./ /go/src/github.com/vmware/vic
24-
RUN make -C /go/src/github.com/vmware/vic imagec portlayerapi
23+
ADD ./ $GOPATH/src/github.com/vmware/vic
24+
RUN make -C $GOPATH/src/github.com/vmware/vic imagec portlayerapi
2525

2626
# download and install bats and helpers
2727
RUN git clone https://github.com/sstephenson/bats /tmp/bats && \
28-
git clone https://github.com/ztombol/bats-assert /go/src/github.com/vmware/vic/tests/helpers/bats-assert && \
29-
git clone https://github.com/ztombol/bats-support /go/src/github.com/vmware/vic/tests/helpers/bats-support && \
28+
git clone https://github.com/ztombol/bats-assert $GOPATH/src/github.com/vmware/vic/tests/helpers/bats-assert && \
29+
git clone https://github.com/ztombol/bats-support $GOPATH/src/github.com/vmware/vic/tests/helpers/bats-support && \
3030
/tmp/bats/install.sh /usr/local
3131

3232
# run the actual tests
33-
WORKDIR /go/src/github.com/vmware/vic/tests/
33+
WORKDIR $GOPATH/src/github.com/vmware/vic/tests/
3434
CMD /usr/local/bin/bats -t .

Makefile

+86-25
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,47 @@ ifeq ($(USER),vagrant)
66
BIN_ARCH := -$(OS)
77
endif
88

9+
BASE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
10+
11+
BIN ?= bin
12+
IGNORE := $(shell mkdir -p $(BIN))
913
export GOPATH ?= $(shell echo $(CURDIR) | sed -e 's,/src/.*,,')
1014
SWAGGER ?= $(GOPATH)/bin/swagger$(BIN_ARCH)
1115
GOVET ?= $(GOPATH)/bin/vet$(BIN_ARCH)
1216
GOIMPORTS ?= $(GOPATH)/bin/goimports$(BIN_ARCH)
1317
GOLINT ?= $(GOPATH)/bin/golint$(BIN_ARCH)
1418
GVT ?= $(GOPATH)/bin/gvt$(BIN_ARCH)
1519

16-
1720
.PHONY: all tools clean test check \
1821
goversion govet goimports gvt gopath \
19-
bootstrap apiservers \
20-
22+
isos tethers apiservers
2123

2224
.DEFAULT_GOAL := all
2325

2426

2527
# target aliases - environment variable definition
26-
docker-engine-api := binary/docker-engine-server
27-
28-
portlayerapi := binary/port-layer-server
28+
docker-engine-api := $(BIN)/docker-engine-server
29+
portlayerapi := $(BIN)/port-layer-server
2930
portlayerapi-client := apiservers/portlayer/client/port_layer_client.go
3031
portlayerapi-server := apiservers/portlayer/restapi/server.go
3132

32-
imagec := binary/imagec
33-
vicadmin := binary/vicadmin
34-
rpctool := binary/rpctool
33+
imagec := $(BIN)/imagec
34+
vicadmin := $(BIN)/vicadmin
35+
rpctool := $(BIN)/rpctool
36+
37+
tether-linux := $(BIN)/tether-linux
38+
tether-windows := $(BIN)/tether-windows.exe
39+
40+
appliance := $(BIN)/appliance.iso
41+
appliance-staging := $(BIN)/appliance-staging.tgz
42+
bootstrap := $(BIN)/bootstrap.iso
43+
iso-base := $(BIN)/iso-base.tgz
3544

36-
tether-linux := binary/tether-linux
37-
tether-windows := binary/tether-windows.exe
45+
install := $(BIN)/install.sh
46+
47+
go-lint := $(BIN)/.golint
48+
go-vet := $(BIN)/.govet
49+
go-imports := $(BIN)/.goimports
3850

3951
# target aliases - target mapping
4052
docker-engine-api: $(docker-engine-api)
@@ -49,25 +61,41 @@ rpctool: $(rpctool)
4961
tether-linux: $(tether-linux)
5062
tether-windows: $(tether-windows)
5163

64+
appliance: $(appliance)
65+
appliance-staging: $(appliance-staging)
66+
bootstrap: $(bootstrap)
67+
iso-base: $(iso-base)
68+
69+
install: $(install)
70+
5271
swagger: $(SWAGGER)
5372

73+
golint: $(go-lint)
74+
govet: $(go-vet)
75+
goimports: $(go-imports)
76+
77+
5478
# convenience targets
55-
all: check bootstrap apiservers $(imagec) $(vicadmin)
79+
all: components isos install
5680
tools: $(GOIMPORTS) $(GOVET) $(GVT) $(GOLINT) $(SWAGGER) goversion
5781
check: goversion goimports govet golint
5882
apiservers: $(portlayerapi) $(docker-engine-api)
5983
bootstrap: $(tether-linux) $(tether-windows) $(rpctool)
84+
components: check apiservers $(imagec) $(vicadmin) $(rpctool)
85+
isos: $(appliance) $(bootstrap)
86+
tethers: $(tether-linux) $(tether-windows)
6087

6188

89+
# utility targets
6290
goversion:
6391
@echo checking go version...
6492
@( $(GO) version | grep -q $(GOVERSION) ) || ( echo "Please install $(GOVERSION) (found: $$($(GO) version))" && exit 1 )
6593

66-
$(GOIMPORTS):
94+
$(GOIMPORTS): vendor/manifest
6795
@echo building $(GOIMPORTS)...
6896
$(GO) build -o $(GOIMPORTS) ./vendor/golang.org/x/tools/cmd/goimports
6997

70-
$(GOVET):
98+
$(GOVET): vendor/manifest
7199
@echo building $(GOVET)...
72100
$(GO) build -o $(GOVET) ./vendor/golang.org/x/tools/cmd/vet
73101

@@ -79,16 +107,16 @@ $(GOLINT): vendor/manifest
79107
@echo building $(GOLINT)...
80108
$(GO) build -o $(GOLINT) ./vendor/github.com/golang/lint/golint
81109

82-
$(SWAGGER):
110+
$(SWAGGER): vendor/manifest
83111
@echo building $(SWAGGER)...
84112
@$(GO) build -o $(SWAGGER) ./vendor/github.com/go-swagger/go-swagger/cmd/swagger
85113

86114
# exit 1 if golint complains about anything other than comments
87115
golintf = $(GOLINT) $(1) | sh -c "! grep -v 'should have comment'"
88116

89-
golint: $(GOLINT)
117+
$(go-lint): $(GOLINT)
90118
@echo checking go lint...
91-
@#$(call golintf,github.com/vmware/vic/bootstrap/...) # this is commented out due to number of warnings
119+
@ #$(call golintf,github.com/vmware/vic/bootstrap/...) # this is commented out due to number of warnings
92120
@$(call golintf,github.com/vmware/vic/imagec/...)
93121
@$(call golintf,github.com/vmware/vic/vicadmin/...)
94122
@$(call golintf,github.com/vmware/vic/pkg/...)
@@ -102,21 +130,24 @@ golint: $(GOLINT)
102130
gopath:
103131
@echo -n $(GOPATH)
104132

105-
goimports: $(GOIMPORTS)
133+
$(go-imports): $(GOIMPORTS) $(find . -type f -name '*.go' -not -path "./vendor/*")
106134
@echo checking go imports...
107135
@! $(GOIMPORTS) -d $$(find . -type f -name '*.go' -not -path "./vendor/*") 2>&1 | egrep -v '^$$'
136+
@touch $@
108137

109-
govet: $(GOVET)
138+
$(go-vet): $(GOVET) $(find . -type f -name '*.go' -not -path "./vendor/*")
110139
@echo checking go vet...
111140
@$(GOVET) -all -shadow $$(find . -type f -name '*.go' -not -path "./vendor/*")
141+
@touch $@
112142

113143
vendor: $(GVT)
114144
@echo restoring vendor
115145
$(GOPATH)/bin/gvt restore
116146

117-
integration-tests:
118-
docker build -t imagec_tests -f Dockerfile.integration-tests .
119-
docker run --rm imagec_tests
147+
integration-tests: Dockerfile.integration-tests tests/imagec.bats tests/helpers/helpers.bash components
148+
@echo Running integration tests
149+
@docker build -t imagec_tests -f Dockerfile.integration-tests .
150+
docker run -e BIN=$(BIN) --rm imagec_tests
120151

121152
TEST_DIRS=github.com/vmware/vic/bootstrap/...
122153
TEST_DIRS+=github.com/vmware/vic/imagec
@@ -159,6 +190,7 @@ $(imagec): imagec/*.go $(portlayerapi-client)
159190
@echo building imagec...
160191
@CGO_ENABLED=0 $(GO) build -o ./$@ --ldflags '-extldflags "-static"' ./$(dir $<)
161192

193+
162194
$(docker-engine-api): $(portlayerapi-client) apiservers/engine/server/*.go apiservers/engine/backends/*.go
163195
ifeq ($(OS),linux)
164196
@echo Building docker-engine-api server...
@@ -167,26 +199,52 @@ else
167199
@echo skipping docker-engine-api server, cannot build on non-linux
168200
endif
169201

202+
203+
170204
# Common portlayer dependencies between client and server
171205
PORTLAYER_DEPS ?= apiservers/portlayer/swagger.yml \
172206
apiservers/portlayer/restapi/configure_port_layer.go \
173207
apiservers/portlayer/restapi/options/*.go apiservers/portlayer/restapi/handlers/*.go
174208

175209
$(portlayerapi-client): $(PORTLAYER_DEPS) $(SWAGGER)
176210
@echo regenerating swagger models and operations for Portlayer API client...
177-
@$(SWAGGER) generate client -A PortLayer -t $(dir $<) -f $<
211+
@$(SWAGGER) generate client -A PortLayer -t $(realpath $(dir $<)) -f $<
178212

179213

180214
$(portlayerapi-server): $(PORTLAYER_DEPS) $(SWAGGER)
181215
@echo regenerating swagger models and operations for Portlayer API server...
182-
@$(SWAGGER) generate server -A PortLayer -t $(dir $<) -f $<
216+
@$(SWAGGER) generate server -A PortLayer -t $(realpath $(dir $<)) -f $<
183217

184218
$(portlayerapi): $(portlayerapi-server) $(shell find apiservers/engine/ -name '*.go')
185219
@echo building Portlayer API server...
186220
@$(GO) build -o $@ ./apiservers/portlayer/cmd/port-layer-server
187221

222+
223+
$(iso-base): isos/base.sh isos/base/*.repo isos/base/isolinux/**
224+
@echo building iso-base docker image
225+
@ #docker build -t $@ -f $< $(dir $<)
226+
@$< -p $@
227+
228+
# appliance staging - allows for caching of package install
229+
$(appliance-staging): isos/appliance-staging.sh $(iso-base)
230+
@echo staging for VCH appliance
231+
@$< -p $(iso-base) -o $@
232+
233+
# main appliance target - depends on all top level component targets
234+
$(appliance): isos/appliance.sh $(rpctool) $(vicadmin) $(imagec) $(portlayerapi) $(docker-engine-api) $(appliance-staging)
235+
@echo building VCH appliance ISO
236+
@$< -p $(appliance-staging) -b $(BIN)
237+
238+
# main bootstrap target
239+
$(bootstrap): $(tether-linux) $(rpctool) $(iso-base)
240+
@echo "Placeholder target for bootstrap"
241+
242+
$(install): install/install.sh
243+
@echo Building installer
244+
@cp $< $@
245+
188246
clean:
189-
rm -rf ./binary
247+
rm -rf $(BIN)
190248

191249
@echo removing swagger generated files...
192250
rm -f ./apiservers/portlayer/restapi/doc.go
@@ -196,3 +254,6 @@ clean:
196254
rm -rf ./apiservers/portlayer/cmd/
197255
rm -rf ./apiservers/portlayer/models/
198256
rm -rf ./apiservers/portlayer/restapi/operations/
257+
rm -fr ./tests/helpers/bats-assert/
258+
rm -fr ./tests/helpers/bats-support/
259+

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To build the bootstrap binaries, ensure `GOPATH` is set, then issue the followin
1717
```
1818
$ make all
1919
```
20-
This will install required tools, build the bootstrap binaries `tether-windows`, `tether-linux`, `rpctool` and server binaries `docker-server`, `port-layer-server`. The binaries will be created in the `./binaries` directory.
20+
This will install required tools, build the bootstrap binaries `tether-windows`, `tether-linux`, `rpctool` and server binaries `docker-engine-server`, `port-layer-server`. The binaries will be created in the `./binaries` directory.
2121

2222
To run tests after a successfull build, issue the following:
2323
```
@@ -81,18 +81,18 @@ Ensure that you have Docker 1.6 or higher installed.
8181
Install the Drone command line tools.
8282
From the root directory of the `vic` repository run `drone exec -trusted -e VIC_ESX_TEST_URL=""`
8383

84-
## Starting docker-server
84+
## Starting docker-engine-server
8585

8686
Generate certificate pair
8787

8888
```
8989
go run `go env GOROOT`/src/crypto/tls/generate_cert.go --host localhost
9090
```
9191

92-
Start docker-server
92+
Start docker-engine-server
9393

9494
```
95-
binary/docker-server --port=2376 --tls-certificate=cert.pem --tls-key=key.pem
95+
binary/docker-engine-server --port=2376 --tls-certificate=cert.pem --tls-key=key.pem
9696
```
9797

9898
## Starting port-layer-server

0 commit comments

Comments
 (0)