more progress
parent
cf5ec17197
commit
09eaab23f4
@ -0,0 +1,24 @@
|
||||
# building the binary
|
||||
FROM golang:1.11 as builder
|
||||
|
||||
# Add Maintainer Info
|
||||
LABEL maintainer="Jesse Duffield <jessedduffield@gmail.com>"
|
||||
|
||||
# Set the Current Working Directory inside the container
|
||||
WORKDIR /src/github.com/jesseduffield/lazydocker/test/printrandom
|
||||
|
||||
# Copy everything from the current directory to the PWD(Present Working Directory) inside the container
|
||||
COPY . .
|
||||
|
||||
# Build the package
|
||||
RUN go build
|
||||
|
||||
# putting binary into a minimal image
|
||||
FROM scratch
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY --from=builder /src/github.com/jesseduffield/lazydocker/test/printrandom/printrandom .
|
||||
|
||||
# Run the executable
|
||||
CMD ["./printrandom"]
|
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
exitOnInterrupt()
|
||||
|
||||
for range time.Tick(time.Second / 3) {
|
||||
fmt.Println(rand.Intn(1000))
|
||||
}
|
||||
}
|
||||
|
||||
func exitOnInterrupt() {
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
<-c
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue