diff --git a/Dockerfile b/Dockerfile index 8758a1d..b302607 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,20 @@ -FROM golang:alpine3.8 as builder -WORKDIR /project -COPY surprise.go . +FROM --platform=$BUILDPLATFORM golang:1.11-alpine AS builder RUN apk add --no-cache git RUN go get github.com/pdevine/go-asciisprite -RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o surprise surprise.go +WORKDIR /project +COPY surprise.go . -FROM scratch +ARG TARGETOS +ARG TARGETARCH +ENV GOOS=$TARGETOS GOARCH=$TARGETARCH +RUN CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o surprise surprise.go + +FROM scratch AS release-linux COPY --from=builder /project/surprise /surprise -CMD ["/surprise"] +ENTRYPOINT ["/surprise"] + +FROM microsoft/nanoserver AS release-windows +COPY --from=builder /project/surprise /surprise.exe +ENTRYPOINT ["\\surprise.exe"] + +FROM release-$TARGETOS diff --git a/surprise.go b/surprise.go index dc4afd4..cb6d7c9 100644 --- a/surprise.go +++ b/surprise.go @@ -66,10 +66,10 @@ type Flicker struct { func NewCake() *Cake { s := &Cake{BaseSprite: sprite.BaseSprite{ Visible: true, - X: Width/2 - 20, Y: Height/2}, } s.AddCostume(sprite.NewCostume(birthday_c0, '@')) + s.X = Width/2 - s.Width/2 points := []sprite.Point{ sprite.Point{12, 0}, @@ -170,6 +170,11 @@ func main() { cake := NewCake() allSprites.Sprites = append(allSprites.Sprites, cake) + txt := "Press 'ESC' to quit." + c := sprite.NewCostume(txt, '~') + text := sprite.NewBaseSprite(Width/2-len(txt)/2, Height-2, c) + allSprites.Sprites = append(allSprites.Sprites, text) + mainloop: for { tm.Clear(tm.ColorDefault, tm.ColorDefault) @@ -177,7 +182,7 @@ mainloop: select { case ev := <-event_queue: if ev.Type == tm.EventKey { - if ev.Key == tm.KeyEsc || ev.Ch == 'q' { + if ev.Key == tm.KeyCtrlC || ev.Key == tm.KeyEsc || ev.Ch == 'q' { break mainloop } } else if ev.Type == tm.EventResize {