diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..858594f58 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!release/* diff --git a/.drone.yml b/.drone.yml index 2ba127719..3b5e79291 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,8 @@ pipeline: - export PATH=$PATH:$GOPATH/bin - make deps gen - make test test_postgres test_mysql - dist: + + build: image: drone/golang:1.5 environment: - GO15VENDOREXPERIMENT=1 @@ -23,6 +24,14 @@ pipeline: when: event: push + publish: + image: s3 + bucket: downloads.drone.io + source: release/**/*.tar.gz + when: + event: push + branch: master + docker: repo: drone/drone tag: [ "0.5.0", "0.5" ] diff --git a/.drone.yml.sig b/.drone.yml.sig index cb1d5d845..fe4e7531e 100644 --- a/.drone.yml.sig +++ b/.drone.yml.sig @@ -1 +1 @@ -eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9kcm9uZQogIHBhdGg6IHNyYy9naXRodWIuY29tL2Ryb25lL2Ryb25lCgpwaXBlbGluZToKICB0ZXN0OgogICAgaW1hZ2U6IGRyb25lL2dvbGFuZzoxLjUKICAgIGVudmlyb25tZW50OgogICAgICAtIEdPMTVWRU5ET1JFWFBFUklNRU5UPTEKICAgICAgLSBHT1BBVEg9L2Ryb25lCiAgICBjb21tYW5kczoKICAgICAgLSBleHBvcnQgUEFUSD0kUEFUSDokR09QQVRIL2JpbgogICAgICAtIG1ha2UgZGVwcyBnZW4KICAgICAgLSBtYWtlIHRlc3QgdGVzdF9wb3N0Z3JlcyB0ZXN0X215c3FsCiAgZGlzdDoKICAgIGltYWdlOiBkcm9uZS9nb2xhbmc6MS41CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBHTzE1VkVORE9SRVhQRVJJTUVOVD0xCiAgICAgIC0gR09QQVRIPS9kcm9uZQogICAgY29tbWFuZHM6CiAgICAgIC0gZXhwb3J0IFBBVEg9JFBBVEg6JEdPUEFUSC9iaW4KICAgICAgLSBtYWtlIGJ1aWxkCiAgICB3aGVuOgogICAgICBldmVudDogcHVzaAoKICBkb2NrZXI6CiAgICByZXBvOiBkcm9uZS9kcm9uZQogICAgdGFnOiBbICIwLjUuMCIsICIwLjUiIF0KICAgIHN0b3JhZ2VfZHJpdmVyOiBvdmVybGF5CiAgICB3aGVuOgogICAgICBicmFuY2g6IG1hc3RlcgogICAgICBldmVudDogcHVzaAoKc2VydmljZXM6CiAgcG9zdGdyZXM6CiAgICBpbWFnZTogcG9zdGdyZXM6OS40LjUKICAgIGVudmlyb25tZW50OgogICAgICAtIFBPU1RHUkVTX1VTRVI9cG9zdGdyZXMKICBteXNxbDoKICAgIGltYWdlOiBteXNxbDo1LjYuMjcKICAgIGVudmlyb25tZW50OgogICAgICAtIE1ZU1FMX0RBVEFCQVNFPXRlc3QKICAgICAgLSBNWVNRTF9BTExPV19FTVBUWV9QQVNTV09SRD15ZXMK.DRNDrxjB7K3Jj5YRf46kj7RyVJUjUdY3p23DZ6E9aZ8 \ No newline at end of file +eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9kcm9uZQogIHBhdGg6IHNyYy9naXRodWIuY29tL2Ryb25lL2Ryb25lCgpwaXBlbGluZToKICB0ZXN0OgogICAgaW1hZ2U6IGRyb25lL2dvbGFuZzoxLjUKICAgIGVudmlyb25tZW50OgogICAgICAtIEdPMTVWRU5ET1JFWFBFUklNRU5UPTEKICAgICAgLSBHT1BBVEg9L2Ryb25lCiAgICBjb21tYW5kczoKICAgICAgLSBleHBvcnQgUEFUSD0kUEFUSDokR09QQVRIL2JpbgogICAgICAtIG1ha2UgZGVwcyBnZW4KICAgICAgLSBtYWtlIHRlc3QgdGVzdF9wb3N0Z3JlcyB0ZXN0X215c3FsCgogIGJ1aWxkOgogICAgaW1hZ2U6IGRyb25lL2dvbGFuZzoxLjUKICAgIGVudmlyb25tZW50OgogICAgICAtIEdPMTVWRU5ET1JFWFBFUklNRU5UPTEKICAgICAgLSBHT1BBVEg9L2Ryb25lCiAgICBjb21tYW5kczoKICAgICAgLSBleHBvcnQgUEFUSD0kUEFUSDokR09QQVRIL2JpbgogICAgICAtIG1ha2UgYnVpbGQKICAgIHdoZW46CiAgICAgIGV2ZW50OiBwdXNoCgogIHB1Ymxpc2g6CiAgICBpbWFnZTogczMKICAgIGJ1Y2tldDogZG93bmxvYWRzLmRyb25lLmlvCiAgICBzb3VyY2U6IHJlbGVhc2UvKiovKi50YXIuZ3oKICAgIHdoZW46CiAgICAgIGV2ZW50OiBwdXNoCiAgICAgIGJyYW5jaDogbWFzdGVyCgogIGRvY2tlcjoKICAgIHJlcG86IGRyb25lL2Ryb25lCiAgICB0YWc6IFsgIjAuNS4wIiwgIjAuNSIgXQogICAgc3RvcmFnZV9kcml2ZXI6IG92ZXJsYXkKICAgIHdoZW46CiAgICAgIGJyYW5jaDogbWFzdGVyCiAgICAgIGV2ZW50OiBwdXNoCgpzZXJ2aWNlczoKICBwb3N0Z3JlczoKICAgIGltYWdlOiBwb3N0Z3Jlczo5LjQuNQogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gUE9TVEdSRVNfVVNFUj1wb3N0Z3JlcwogIG15c3FsOgogICAgaW1hZ2U6IG15c3FsOjUuNi4yNwogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gTVlTUUxfREFUQUJBU0U9dGVzdAogICAgICAtIE1ZU1FMX0FMTE9XX0VNUFRZX1BBU1NXT1JEPXllcwo.r5LDjpl57Aj5esstD0OtJ1_kwI0iYp1cX9LAhxLoVaE \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3252b2c16..229b1e184 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ drone/drone *.deb .env temp/ +release/ server/swagger/files/*.json diff --git a/Dockerfile b/Dockerfile index 536c393f8..ba686be2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,13 @@ -# Build the drone executable on a x64 Linux host: -# -# go build --ldflags '-extldflags "-static"' -o drone -# -# Build the docker image: -# -# docker build --rm=true -t drone/drone . +# docker build --rm=true -t drone/drone . FROM centurylink/ca-certs EXPOSE 8000 -ADD contrib/docker/etc/nsswitch.conf /etc/ ENV DATABASE_DRIVER=sqlite3 ENV DATABASE_CONFIG=/var/lib/drone/drone.sqlite +ENV GODEBUG=netdns=go -ADD drone/drone /drone - -# Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf, -# but Go and CGO rely on /etc/nsswitch.conf to check the order of DNS resolving. -# To fix this we just create /etc/nsswitch.conf and add the following line: -#RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf +ADD release/drone /drone ENTRYPOINT ["/drone"] CMD ["server"] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 000000000..87b5056ad --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,11 @@ +FROM ?????????? + +EXPOSE 8000 +ENV DATABASE_DRIVER=sqlite3 +ENV DATABASE_CONFIG=/var/lib/drone/drone.sqlite +ENV GODEBUG=netdns=go + +ADD release/linux/arm64/drone /drone + +ENTRYPOINT ["/drone"] +CMD ["server"] diff --git a/Dockerfile.armhf b/Dockerfile.armhf new file mode 100644 index 000000000..5917bb454 --- /dev/null +++ b/Dockerfile.armhf @@ -0,0 +1,11 @@ +FROM ?????????? + +EXPOSE 8000 +ENV DATABASE_DRIVER=sqlite3 +ENV DATABASE_CONFIG=/var/lib/drone/drone.sqlite +ENV GODEBUG=netdns=go + +ADD release/linux/arm/drone /drone + +ENTRYPOINT ["/drone"] +CMD ["server"] diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 000000000..355cbce50 --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,11 @@ +FROM ?????????? + +EXPOSE 8000 +ENV DATABASE_DRIVER=sqlite3 +ENV DATABASE_CONFIG=/var/lib/drone/drone.sqlite +ENV GODEBUG=netdns=go + +ADD release/windows/amd64/drone /drone + +ENTRYPOINT ["/drone"] +CMD ["server"] diff --git a/Makefile b/Makefile index 265911527..47aecadf0 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ -.PHONY: vendor docs +.PHONY: vendor docs release PACKAGES = $(shell go list ./... | grep -v /vendor/) -all: gen build +all: gen build_static deps: go get -u golang.org/x/tools/cmd/cover @@ -24,11 +24,6 @@ gen_template: gen_migrations: go generate github.com/drone/drone/store/datastore/ddl -build: build_static - -build_static: - cd drone && go build --ldflags '-extldflags "-static" -X github.com/drone/drone/version.VersionDev=$(DRONE_BUILD_NUMBER)' -o drone - test: go test -cover $(PACKAGES) @@ -40,9 +35,25 @@ test_mysql: test_postgres: DATABASE_DRIVER="postgres" DATABASE_CONFIG="host=127.0.0.1 user=postgres dbname=postgres sslmode=disable" go test github.com/drone/drone/store/datastore -deb: - mkdir -p contrib/debian/drone/usr/local/bin - mkdir -p contrib/debian/drone/var/lib/drone - mkdir -p contrib/debian/drone/var/cache/drone - cp drone contrib/debian/drone/usr/local/bin - -dpkg-deb --build contrib/debian/drone + +# build the release files +build: build_static build_cross build_tar + +build_static: + go build --ldflags '-extldflags "-static" -X github.com/drone/drone/version.VersionDev=$(DRONE_BUILD_NUMBER)' -o release/drone github.com/drone/drone/drone + +# TODO this is getting moved to a shell script, do not alter +build_cross: + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o release/linux/amd64/drone github.com/drone/drone/drone + GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o release/linux/arm64/drone github.com/drone/drone/drone + GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -o release/linux/arm/drone github.com/drone/drone/drone + GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o release/windows/amd64/drone github.com/drone/drone/drone + GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o release/darwin/amd64/drone github.com/drone/drone/drone + +# TODO this is getting moved to a shell script, do not alter +build_tar: + tar -cvzf release/linux/amd64/drone.tar.gz release/linux/amd64/drone + tar -cvzf release/linux/arm64/drone.tar.gz release/linux/arm64/drone + tar -cvzf release/linux/arm/drone.tar.gz release/linux/arm/drone + tar -cvzf release/windows/amd64/drone.tar.gz release/windows/amd64 + tar -cvzf release/darwin/amd64/drone.tar.gz release/darwin/amd64/drone diff --git a/model/netrc.go b/model/netrc.go index f36169a10..1bb8e67ad 100644 --- a/model/netrc.go +++ b/model/netrc.go @@ -3,5 +3,5 @@ package model type Netrc struct { Machine string `json:"machine"` Login string `json:"login"` - Password string `json:"user"` + Password string `json:"password"` } diff --git a/store/datastore/init.go b/store/datastore/init.go new file mode 100644 index 000000000..b00660902 --- /dev/null +++ b/store/datastore/init.go @@ -0,0 +1,8 @@ +// +build !cgo + +package datastore + +import ( + _ "github.com/go-sql-driver/mysql" + _ "github.com/lib/pq" +) diff --git a/store/datastore/init_cgo.go b/store/datastore/init_cgo.go new file mode 100644 index 000000000..0aa3ef76d --- /dev/null +++ b/store/datastore/init_cgo.go @@ -0,0 +1,9 @@ +// +build cgo + +package datastore + +import ( + _ "github.com/go-sql-driver/mysql" + _ "github.com/lib/pq" + _ "github.com/mattn/go-sqlite3" +) diff --git a/store/datastore/store.go b/store/datastore/store.go index 18169d6a9..2d5936132 100644 --- a/store/datastore/store.go +++ b/store/datastore/store.go @@ -7,9 +7,6 @@ import ( "github.com/drone/drone/store" "github.com/drone/drone/store/datastore/ddl" - _ "github.com/go-sql-driver/mysql" - _ "github.com/lib/pq" - _ "github.com/mattn/go-sqlite3" "github.com/rubenv/sql-migrate" "github.com/russross/meddler"