From 50af1d7c7f98b6e906466611c7da8dfea4c93d78 Mon Sep 17 00:00:00 2001 From: lalyos Date: Tue, 26 May 2015 12:46:55 +0200 Subject: [PATCH] inital version --- Dockerfile | 9 +++++++++ Makefile | 15 +++++++++++++++ README.md | 27 +++++++++++++++++++++++++++ build/Dockerfile | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 build/Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb598ae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM lalyos/scratch-chmx + +ADD release/upx /bin/upx +RUN ["/bin/chmx", "/bin/upx"] + +VOLUME /data +WORKDIR /data + +ENTRYPOINT ["/bin/upx"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9c1090a --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +VERSION=3.91 + +build: + rm -rf release + docker build -t upx-bin build + docker run --rm -v $(shell pwd)/release:/release upx + docker build -t lalyos/upx . + +deps: + go get github.com/progrium/gh-release + +release: build + gh-release create lalyos/docker-upx $(VERSION) + +.PHONY: build diff --git a/README.md b/README.md new file mode 100644 index 0000000..16fb6ef --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Go small or go home + +Lets save the interweb, and make all binaries small. This tiny () Docker image +is a containerized [upx](http://upx.sourceforge.net). + +## Usage + + +You can compress your binary file as: + +``` +docker run -v $PWD:/release lalyos/upx mybinary +``` + +## + + +## tl;dr + +- It is statically built with Alpine linux +- compressed by itdelf (eat your own dogfood) +- added into a [custom scratch](https://github.com/lalyos/docker-scratch-chmx) + +## TODO + +If I’m getting too bored (unlikely in the coming weeks) i might create an +ordinary Alpine package for upx. diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..1f78333 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,35 @@ +FROM lalyos/alpine-build:edge + +RUN apk add -U zlib-dev xz-dev curl perl + +ENV LDFLAGS=-static + +ENV UCL_VER 1.03 +RUN curl -L http://www.oberhumer.com/opensource/ucl/download/ucl-${UCL_VER}.tar.gz|tar -xzv \ + && cd ucl-${UCL_VER} \ + && ./configure \ + && make \ + && make install + +ENV LZMA_VER 920 +RUN curl -LO http://www.7-zip.org/a/lzma${LZMA_VER}.tar.bz2 \ + && bunzip2 lzma${LZMA_VER}.tar.bz2 \ + && tar -xvf lzma${LZMA_VER}.tar +ENV UPX_LZMADIR / + +VOLUME /release + +ENV UPX_UCLDIR=/ucl-${UCL_VER} +ENV UPX_VER 3.91 +RUN curl -LO http://upx.sourceforge.net/download/upx-${UPX_VER}-src.tar.bz2 \ + && bunzip2 upx-${UPX_VER}-src.tar.bz2 \ + && tar -xvf upx-${UPX_VER}-src.tar \ + && cd upx-${UPX_VER}-src \ + && sed -i "/addLoad/ s/NULL/(char*)NULL/" src/packer.cpp \ + && make all + +# packs itself +CMD /upx-${UPX_VER}-src/src/upx.out --best --ultra-brute -o/release/upx /upx-${UPX_VER}-src/src/upx.out + + +