Skip to content

Commit

Permalink
add build stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Xin Wang committed Jul 21, 2019
1 parent e8d3b77 commit 8ede681
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
language: go
go:
- "1.12"

services:
- docker
before_install:
- docker pull golang:1.12.7-alpine
- docker pull k8s.gcr.io/debian-base:v1.0.0

install:
- ls
- pwd
- go get -u github.com/golang/dep/cmd/dep
- dep ensure -vendor-only
script:
- make
- ls
- pwd
- make disk-container
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@
.PHONY: all disk

DISK_IMAGE_NAME=dockerhub.qingcloud.com/csiplugin/csi-qingcloud
DISK_IMAGE_VERSION=canary
DISK_PLUGIN_NAME=qingcloud-disk-csi-driver
DISK_IMAGE_TAG=canary
ROOT_PATH=$(pwd)
PACKAGE_LIST=./cmd/... ./pkg/...

disk:
if [ ! -d ./vendor ]; then dep ensure; fi
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/${DISK_PLUGIN_NAME} ./cmd/disk
docker build -t ${DISK_IMAGE_NAME}-builder:${DISK_IMAGE_TAG} -f deploy/disk/docker/Dockerfile . --target builder

disk-container: disk
cp _output/${DISK_PLUGIN_NAME} deploy/disk/docker
docker build -t $(DISK_IMAGE_NAME):$(DISK_IMAGE_VERSION) deploy/disk/docker
disk-container:
docker build -t ${DISK_IMAGE_NAME}:${DISK_IMAGE_TAG} -f deploy/disk/docker/Dockerfile .

install-dev:
cp /root/.qingcloud/config.yaml deploy/disk/kubernetes/base/config.yaml
Expand Down Expand Up @@ -60,6 +57,4 @@ sanity-test:
${ROOT_PATH}/csi-sanity --csi.endpoint /var/lib/kubelet/plugins/disk.csi.qingcloud.com/csi.sock --csi.testvolumesize 107374182400

clean:
go clean -r -x
rm -rf ./_output
rm -rf deploy/disk/docker/${DISK_PLUGIN_NAME}
go clean -r -x
9 changes: 6 additions & 3 deletions deploy/disk/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
# | limitations under the License.
# +-------------------------------------------------------------------------

FROM golang:1.12.7-alpine as builder
WORKDIR /go/src/github.com/yunify/qingcloud-csi
COPY . .
RUN go get -u github.com/golang/dep/cmd/dep && dep ensure -vendor-only
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/qingcloud-disk-csi-driver ./cmd/disk

FROM k8s.gcr.io/debian-base:v1.0.0
LABEL maintainers="Yunify"
LABEL description="QingCloud CSI plugin"

RUN clean-install util-linux e2fsprogs xfsprogs mount ca-certificates udev
COPY qingcloud-disk-csi-driver /qingcloud-disk-csi-driver
COPY --from=builder /go/src/github.com/yunify/qingcloud-csi/_output/qingcloud-disk-csi-driver /qingcloud-disk-csi-driver
RUN chmod +x /qingcloud-disk-csi-driver && \
mkdir -p /var/log/qingcloud-disk-csi-driver

ENTRYPOINT ["/qingcloud-disk-csi-driver"]

0 comments on commit 8ede681

Please sign in to comment.