Skip to content

Instantly share code, notes, and snippets.

@configurator
Created March 29, 2018 20:30
Show Gist options
  • Save configurator/2c8b10227201f201af0bcaed598d13af to your computer and use it in GitHub Desktop.
Save configurator/2c8b10227201f201af0bcaed598d13af to your computer and use it in GitHub Desktop.
UPX in Docker breaks Go app
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello Docker");
}
# Build app
FROM golang as builder
COPY . /build
RUN cd /build && CGO_ENABLED=0 go build -ldflags='-s -w' app.go
# Compress
FROM lalyos/upx as compressor
COPY --from=builder /build/app /compress/
RUN ["upx", "/compress/app"]
# Create empty image with only the app in it
FROM scratch
COPY --from=compressor /compress/app /
# COPY --from=builder /build/app /
ENTRYPOINT ["/app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment