replaced .travis.yml with multistage Docker build

This commit is contained in:
Mahmoud Rahbar Azad 2018-10-25 22:32:22 +02:00
parent ddb4f49cf7
commit 2619e02988
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 7DBBD39E2BFEB784
3 changed files with 24 additions and 27 deletions

View file

@ -1,27 +0,0 @@
language: go
# Force-enable Go modules. This will be unnecessary when Go 1.12 lands.
env:
- GO111MODULE=on
# You don't need to test on very old version of the Go compiler. It's the user's
# responsibility to keep their compilers up to date.
go:
- 1.11.x
# Only clone the most recent commit.
git:
depth: 1
# Skip the install step. Don't `go get` dependencies. Only build with the code
# in vendor/
install: true
notifications:
email: false
before_script:
- go install -mod vendor github.com/mitchellh/gox
script:
- gox -output="hetzner-sb-notifier_{{.OS}}_{{.Arch}}"

20
Dockerfile Normal file
View file

@ -0,0 +1,20 @@
FROM golang:alpine as builder
RUN apk update && apk add git && apk add ca-certificates
RUN adduser -D -g '' appuser
RUN mkdir /hetzner-sb-notifier
COPY . /hetzner-sb-notifier/
WORKDIR /hetzner-sb-notifier
ENV VERSION=1.0
RUN chmod +x build.sh
RUN /hetzner-sb-notifier/build.sh linux
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /hetzner-sb-notifier/build/hetzner-sb-notifier_linux_amd64 /hetzner-sb-notifier
RUN chmod +x hetzner-sb-notifier
USER appuser
ENTRYPOINT ["/hetzner-sb-notifier"]

4
build.sh Normal file
View file

@ -0,0 +1,4 @@
GO111MODULE=on
go get github.com/mitchellh/gox
go get ./...
gox -output="build/hetzner-sb-notifier_{{.OS}}_{{.Arch}}_${VERSION}" -osarch=$1/amd64