diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..f183625 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,25 @@ +kind: pipeline +type: docker +name: build + +steps: +- name: test + image: golang:1.13 + commands: + - go test -test.v -cover `go list ./... | grep -v examples | grep -v internal` + environment: + GOFLAGS: -mod=vendor +- name: lint + image: golangci/golangci-lint:v1.19.1 + commands: + - golangci-lint -v run + environment: + GOFLAGS: -mod=vendor +- name: build + image: plugins/docker + settings: + username: fat0troll + password: + from_secret: registry_password + repo: fat0troll/fwzookeeper + auto_tag: true \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index cd89e8b..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,50 +0,0 @@ -image: lab.wtfteam.pro:4567/containers/golangci-lint - -stages: - - test - - build - - deploy - -before_script: - - go version - - mkdir -p $GOPATH/src/lab.wtfteam.pro/fat0troll/ - - ln -s $(pwd) $GOPATH/src/lab.wtfteam.pro/fat0troll/fw_zookeeper - - cd $GOPATH/src/lab.wtfteam.pro/fat0troll/fw_zookeeper - -lint: - stage: test - script: - - pwd - - golangci-lint run - -test: - stage: test - script: - - pwd - - go test -test.v -cover `go list ./... | grep -v examples | grep -v internal` - -build: - stage: build - script: - - pwd - - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-w -extldflags "-static"' - artifacts: - untracked: true - expire_in: 4 hours - paths: - - fw_zookeeper - -deploy: - stage: deploy - only: - - master - before_script: - - apk add --no-cache openssh-client - - mkdir -p ~/.ssh - - echo "$DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa - - chmod 600 ~/.ssh/id_rsa - - eval "$(ssh-agent -s)" - - ssh-add ~/.ssh/id_rsa - - ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts - script: - - scp fw_zookeeper $DEPLOY_USER@$DEPLOY_HOST:/usr/local/bin/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..82258f5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.13 AS builder + +COPY . /build/ +WORKDIR /build/ + +RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GOFLAGS='-mod=vendor' go build -tags netgo -ldflags '-w -extldflags "-static"' + +FROM scratch + +COPY --from=builder /build/fwzookeeper /usr/local/bin/fwzookeeper + +VOLUME ["/data"] + +ENTRYPOINT [ "/usr/local/bin/fwzookeeper" ] \ No newline at end of file