Created
March 29, 2018 20:30
-
-
Save configurator/2c8b10227201f201af0bcaed598d13af to your computer and use it in GitHub Desktop.
UPX in Docker breaks Go app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println("Hello Docker"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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