CI/CD: Make deployed binaries static

Closes: #2
This commit is contained in:
nemunaire 2021-05-18 00:42:52 +02:00
parent 43b7841d77
commit 02c1389778
2 changed files with 17 additions and 7 deletions

View File

@ -58,13 +58,17 @@ steps:
- apk --no-cache add go-bindata - apk --no-cache add go-bindata
- sed -i '/yarn --cwd htdocs --offline build/d' static.go - sed -i '/yarn --cwd htdocs --offline build/d' static.go
- go generate -v - go generate -v
- go build -v -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} - go build -v -tags netgo -ldflags '-w' -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
environment:
CGO_ENABLED: 0
- name: vet - name: vet
image: golang:alpine image: golang:alpine
commands: commands:
- apk --no-cache add build-base - apk --no-cache add build-base
- go vet -v - go vet -v
environment:
CGO_ENABLED: 0
- name: deploy - name: deploy
image: appleboy/drone-scp image: appleboy/drone-scp
@ -103,8 +107,9 @@ steps:
- name: build macOS - name: build macOS
image: golang:alpine image: golang:alpine
commands: commands:
- go build -v -o happydns-darwin-${DRONE_STAGE_ARCH} - go build -v -tags netgo -ldflags '-w' -o happydns-darwin-${DRONE_STAGE_ARCH}
environment: environment:
CGO_ENABLED: 0
GOOS: darwin GOOS: darwin
GOARCH: amd64 GOARCH: amd64
@ -177,8 +182,10 @@ steps:
- apk --no-cache add go-bindata - apk --no-cache add go-bindata
- sed -i '/yarn --cwd htdocs --offline build/d' static.go - sed -i '/yarn --cwd htdocs --offline build/d' static.go
- go generate -v - go generate -v
- go build -v -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} - go build -v -tags netgo -ldflags '-w' -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
- ln happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} happydns - ln happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} happydns
environment:
CGO_ENABLED: 0
- name: deploy - name: deploy
image: appleboy/drone-scp image: appleboy/drone-scp
@ -250,8 +257,9 @@ steps:
- apk --no-cache add go-bindata build-base - apk --no-cache add go-bindata build-base
- sed -i '/yarn --cwd htdocs --offline build/d' static.go - sed -i '/yarn --cwd htdocs --offline build/d' static.go
- go generate -v - go generate -v
- go build -v -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}el - go build -v -tags netgo -ldflags '-w' -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}el
environment: environment:
CGO_ENABLED: 0
GOARM: 5 GOARM: 5
- name: deploy armel - name: deploy armel
@ -292,8 +300,9 @@ steps:
image: golang:alpine image: golang:alpine
commands: commands:
- apk --no-cache add build-base - apk --no-cache add build-base
- go build -v -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}hf - go build -v -tags netgo -ldflags '-w' -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}hf
environment: environment:
CGO_ENABLED: 0
GOARM: 6 GOARM: 6
- name: deploy armhf - name: deploy armhf
@ -334,9 +343,10 @@ steps:
image: golang:alpine image: golang:alpine
commands: commands:
- apk --no-cache add build-base - apk --no-cache add build-base
- go build -v -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7 - go build -v -tags netgo -ldflags '-w' -o happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7
- ln happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7 happydns - ln happydns-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}v7 happydns
environment: environment:
CGO_ENABLED: 0
GOARM: 7 GOARM: 7
- name: deploy armv7 - name: deploy armv7

View File

@ -34,7 +34,7 @@ COPY generate.go go.mod go.sum main.go static.go ./
RUN sed -i '/yarn --cwd htdocs --offline build/d' static.go && \ RUN sed -i '/yarn --cwd htdocs --offline build/d' static.go && \
go get -d -v && \ go get -d -v && \
go generate -v && \ go generate -v && \
go build -v go build -v -ldflags '-w'
FROM alpine FROM alpine