finalzed build
This commit is contained in:
parent
2619e02988
commit
c0539ade72
6 changed files with 38 additions and 23 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,4 @@
|
|||
go.sum
|
||||
build/
|
||||
.idea/*
|
||||
*.iml
|
22
Dockerfile
22
Dockerfile
|
@ -1,20 +1,4 @@
|
|||
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
|
||||
|
||||
FROM centurylink/ca-certs
|
||||
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"]
|
||||
ADD ./build/hetzner-sb-notifier_linux_amd64_1.0 /
|
||||
ENTRYPOINT ["/hetzner-sb-notifier_linux_amd64_1.0"]
|
14
Dockerfile_with_build
Normal file
14
Dockerfile_with_build
Normal file
|
@ -0,0 +1,14 @@
|
|||
FROM golang:1.11-stretch as builder
|
||||
|
||||
RUN mkdir /hetzner-sb-notifier
|
||||
COPY . /hetzner-sb-notifier/
|
||||
WORKDIR /hetzner-sb-notifier
|
||||
|
||||
RUN chmod +x build.sh
|
||||
|
||||
RUN /hetzner-sb-notifier/build.sh linux
|
||||
RUN ls -lth /hetzner-sb-notifier/builds
|
||||
|
||||
FROM centurylink/ca-certs
|
||||
COPY --from=builder /hetzner-sb-notifier/builds /root
|
||||
ENTRYPOINT ["/root/hetzner-sb-notifier_linux_amd64_1.0"]
|
|
@ -42,4 +42,8 @@ Got 545 offers. Filtered offers: 3
|
|||
|
||||
## Build
|
||||
|
||||
The Go project uses Go Modules
|
||||
The Go project uses Go Modules and can be easily build with the wrapper script build.sh:
|
||||
````
|
||||
chmod +x build.sh
|
||||
./build.sh
|
||||
````
|
12
build.sh
12
build.sh
|
@ -1,4 +1,12 @@
|
|||
VERSION=1.0
|
||||
GO111MODULE=on
|
||||
go get github.com/mitchellh/gox
|
||||
CGO_ENABLED=0
|
||||
GOOS=linux
|
||||
GOARCH=amd64
|
||||
|
||||
echo "Fetching dependencies"
|
||||
go get ./...
|
||||
gox -output="build/hetzner-sb-notifier_{{.OS}}_{{.Arch}}_${VERSION}" -osarch=$1/amd64
|
||||
echo "Building project"
|
||||
mkdir builds
|
||||
go build -a -installsuffix cgo -o ./builds/hetzner-sb-notifier_${GOOS}_${GOARCH}_${VERSION} .
|
||||
echo "Done"
|
||||
|
|
2
go.mod
2
go.mod
|
@ -4,6 +4,8 @@ require (
|
|||
cloud.google.com/go v0.31.0
|
||||
github.com/golang/protobuf v1.2.0
|
||||
github.com/googleapis/gax-go v2.0.0+incompatible // indirect
|
||||
github.com/mitchellh/gox v0.4.0 // indirect
|
||||
github.com/mitchellh/iochan v1.0.0 // indirect
|
||||
go.opencensus.io v0.18.0 // indirect
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519 // indirect
|
||||
google.golang.org/api v0.0.0-20181021000519-a2651947f503 // indirect
|
||||
|
|
Reference in a new issue