Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build stage #89

Merged
merged 1 commit into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
language: go
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:
- go get -u github.com/golang/dep/cmd/dep
- dep ensure -vendor-only
script:
- make
- 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
8 changes: 5 additions & 3 deletions deploy/disk/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
# | limitations under the License.
# +-------------------------------------------------------------------------

FROM golang:1.12.7-alpine as builder
WORKDIR /go/src/github.com/yunify/qingcloud-csi
COPY . .
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"]