Skip to content

Commit c43c3a9

Browse files
committed
redesign Dockerfile and Makefile to follow sapcc/swift-drive-autopilot
1 parent 225515c commit c43c3a9

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

Dockerfile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
FROM golang:1.8.3-alpine3.6 as builder
2+
WORKDIR /x/src/github.com/sapcc/swift-http-import/
3+
RUN apk add --no-cache curl make openssl && \
4+
mkdir -p /pkg/bin/ && \
5+
curl -L https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 > /pkg/bin/dumb-init && \
6+
chmod +x /pkg/bin/dumb-init
7+
8+
COPY . .
9+
RUN make install PREFIX=/pkg
10+
11+
################################################################################
12+
113
FROM alpine:latest
214
MAINTAINER "Stefan Majewsky <[email protected]>"
15+
RUN apk add --no-cache ca-certificates
316

4-
# wget(1) is only used to retrieve dumb-init
5-
RUN apk update && \
6-
apk add wget ca-certificates && \
7-
wget -O /bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \
8-
chmod +x /bin/dumb-init && \
9-
apk del wget
10-
11-
ADD swift-http-import /bin/swift-http-import
12-
ENTRYPOINT ["/bin/dumb-init", "--", "/bin/swift-http-import"]
17+
COPY --from=builder /pkg/ /usr/
18+
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/bin/swift-http-import"]

Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
all: swift-http-import
1+
PKG = github.com/sapcc/swift-http-import
2+
PREFIX := /usr
3+
4+
all: build/swift-http-import
25

36
# force people to use golangvend
4-
GOCC := env GOPATH=$(CURDIR)/.gopath go
5-
GOFLAGS := -ldflags '-s -w'
7+
GO := GOPATH=$(CURDIR)/.gopath GOBIN=$(CURDIR)/build go
8+
GO_BUILDFLAGS :=
9+
GO_LDFLAGS := -s -w
610

7-
swift-http-import: *.go
8-
$(GOCC) build $(GOFLAGS) -o $@ github.com/sapcc/swift-http-import
11+
build/swift-http-import: FORCE
12+
$(GO) install $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' '$(PKG)'
913

1014
check: all
1115
bash tests.sh http
1216
bash tests.sh swift
1317
echo -e '\e[1;32mSuccess!\e[0m'
1418

19+
install: FORCE all
20+
install -D -m 0755 build/swift-http-import "$(DESTDIR)$(PREFIX)/bin/swift-http-import"
21+
1522
vendor:
23+
@# vendoring by https://github.com/holocm/golangvend
1624
@golangvend
17-
.PHONY: vendor
25+
26+
.PHONY: FORCE

tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fi
8888

8989
mirror() {
9090
# config file comes from stdin
91-
./swift-http-import /proc/self/fd/0
91+
./build/swift-http-import /proc/self/fd/0
9292
# wait for container listing to get updated
9393
sleep 15
9494
}

0 commit comments

Comments
 (0)