Skip to content

Commit 6c4905e

Browse files
committed
ref(swarm): build deis/swarm image like other components
1 parent 560feeb commit 6c4905e

6 files changed

Lines changed: 97 additions & 20 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ builder/image/bin/get-app-config
3131
builder/image/bin/get-app-values
3232
builder/image/bin/publish-release-controller
3333
builder/image/bin/yaml2json-procfile
34-
cache/image/bin
34+
cache/image/bin/
3535
client/dist/
3636
client/makeself/
3737
contrib/azure/azure-user-data
@@ -50,6 +50,7 @@ logspout/Godeps/
5050
publisher/Godeps/
5151
publisher/image/bin/publisher
5252
router/Godeps/
53+
swarm/image/bin/
5354

5455
# coverage reports
5556
.coverage

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repo_path = github.com/deis/deis
1010
GO_PACKAGES = pkg/time version
1111
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
1212

13-
COMPONENTS=builder cache controller database logger logspout publisher registry router store
13+
COMPONENTS=builder cache controller database logger logspout publisher registry router store swarm
1414
START_ORDER=publisher store logger logspout database cache registry controller builder router
1515
CLIENTS=client deisctl
1616

swarm/Dockerfile

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,8 @@ RUN git clone https://github.com/deis/swarm
55
WORKDIR /go/src/github.com/docker/swarm
66
RUN git fetch origin nodefailover
77
RUN git checkout nodefailover
8+
89
ENV GOPATH /go/src/github.com/docker/swarm/Godeps/_workspace:$GOPATH
9-
RUN CGO_ENABLED=0 go install -v -a -tags netgo -ldflags "-w -X github.com/docker/swarm/version.GITCOMMIT `git rev-parse --short HEAD`"
10-
WORKDIR /go/src/github.com/deis
11-
RUN git clone https://github.com/deis/deis
12-
WORKDIR /go/src/github.com/deis/deis
13-
RUN git fetch origin swarm
14-
RUN git checkout swarm
15-
WORKDIR /go/src/github.com/deis/deis/swarm
16-
RUN mv /go/bin/swarm /bin/deis-swarm
17-
RUN chmod +x /bin/deis-swarm
18-
ENV GOPATH /go/src/github.com/deis/deis/Godeps/_workspace:$GOPATH
19-
RUN CGO_ENABLED=0 go install -v -a "github.com/deis/deis/swarm"
20-
ENV SWARM_HOST :2375
21-
EXPOSE 2375
22-
VOLUME $HOME/.deis-swarm
23-
ENTRYPOINT ["swarm"]
24-
CMD ["--help”]
10+
RUN CGO_ENABLED=0 go build -a -tags netgo -installsuffix cgo \
11+
-ldflags "-s -w -X github.com/docker/swarm/version.GITCOMMIT `git rev-parse --short HEAD`" \
12+
-o deis-swarm

swarm/Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
include ../includes.mk
2+
3+
# the filepath to this repository, relative to $GOPATH/src
4+
repo_path = github.com/deis/deis/swarm
5+
6+
GO_FILES = swarm.go
7+
GO_PACKAGES =
8+
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
9+
10+
COMPONENT = $(notdir $(repo_path))
11+
IMAGE = $(IMAGE_PREFIX)$(COMPONENT):$(BUILD_TAG)
12+
DEV_IMAGE = $(DEV_REGISTRY)/$(IMAGE)
13+
BUILD_IMAGE = $(COMPONENT)-build
14+
BINARY_DEST_DIR = image/bin
15+
16+
build: check-docker
17+
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags '-s' -o $(BINARY_DEST_DIR)/swarm || exit 1
18+
@$(call check-static-binary,$(BINARY_DEST_DIR)/swarm)
19+
docker build -t $(BUILD_IMAGE) .
20+
docker cp `docker run -d $(BUILD_IMAGE)`:/go/src/github.com/docker/swarm/deis-swarm $(BINARY_DEST_DIR)/
21+
@$(call check-static-binary,$(BINARY_DEST_DIR)/deis-swarm)
22+
docker build -t $(IMAGE) image
23+
24+
clean: check-docker check-registry
25+
rm -f $(BINARY_DEST_DIR)/deis-swarm
26+
rm -f $(BINARY_DEST_DIR)/swarm
27+
-docker rmi -f $(BUILD_IMAGE)
28+
-docker rmi -f $(IMAGE)
29+
30+
full-clean: check-docker check-registry
31+
docker images -q $(IMAGE_PREFIX)$(COMPONENT) | xargs docker rmi -f
32+
33+
install: check-deisctl
34+
deisctl install $(COMPONENT)
35+
36+
uninstall: check-deisctl
37+
deisctl uninstall $(COMPONENT)
38+
39+
start: check-deisctl
40+
deisctl start $(COMPONENT)
41+
42+
stop: check-deisctl
43+
deisctl stop $(COMPONENT)
44+
45+
restart: stop start
46+
47+
run: install start
48+
49+
dev-release: push set-image
50+
51+
push: check-registry
52+
docker tag -f $(IMAGE) $(DEV_IMAGE)
53+
docker push $(DEV_IMAGE)
54+
55+
set-image: check-deisctl
56+
deisctl config $(COMPONENT) set image=$(DEV_IMAGE)
57+
58+
release:
59+
docker push $(IMAGE)
60+
61+
deploy: build dev-release restart
62+
63+
test: test-style test-unit test-functional
64+
65+
test-unit:
66+
@echo no unit tests
67+
68+
test-style:
69+
# display output, then check
70+
$(GOFMT) $(GO_PACKAGES) $(GO_FILES)
71+
@$(GOFMT) $(GO_PACKAGES) $(GO_FILES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
72+
$(GOVET) $(repo_path) $(GO_PACKAGES_REPO_PATH)
73+
$(GOLINT) ./...
74+
75+
test-functional:
76+
@echo no functional tests

swarm/image/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM busybox
2+
3+
COPY bin /app/bin/
4+
WORKDIR /app/bin
5+
6+
ENTRYPOINT ["/app/bin/swarm"]
7+
CMD ["--help"]
8+
ENV SWARM_HOST :2375
9+
EXPOSE 2375
10+
VOLUME $HOME/.swarm
11+
12+
ENV DEIS_RELEASE 1.6.0-dev

swarm/swarm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ func main() {
8686
client := etcd.NewClient([]string{"http://" + etcdhost + ":" + etcdport})
8787
switch os.Args[1] {
8888
case "join":
89-
run("deis-swarm join " + addr + " " + etcdproto)
89+
run("./deis-swarm join " + addr + " " + etcdproto)
9090
case "manage":
9191
go publishService(client, etcdhost, uint64(ttl.Seconds()))
92-
run("deis-swarm manage " + etcdproto)
92+
run("./deis-swarm manage " + etcdproto)
9393
}
9494
}

0 commit comments

Comments
 (0)