From 497d4ef270034d8c00db7ecf03825864e3f4a3d2 Mon Sep 17 00:00:00 2001 From: Andrew Stucki Date: Mon, 26 Oct 2020 22:19:00 -0400 Subject: [PATCH] Add debug symbol stripping and binary packing --- Dockerfile | 4 +++- Dockerfile.arm5 | 4 +++- Dockerfile.arm6 | 4 +++- Dockerfile.arm64 | 4 +++- Dockerfile.arm7 | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5afbd9..cb60690 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,11 @@ FROM golang:latest as builder WORKDIR /go/src/github.com/PierreZ/goStatic COPY . . RUN mkdir ./bin && \ - CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -tags netgo -installsuffix netgo -o ./bin/goStatic && \ + apt-get update && apt-get install -y upx && \ + CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s" -tags netgo -installsuffix netgo -o ./bin/goStatic && \ mkdir ./bin/etc && \ ID=$(shuf -i 100-9999 -n 1) && \ + upx -9 ./bin/goStatic && \ echo $ID && \ echo "appuser:x:$ID:$ID::/sbin/nologin:/bin/false" > ./bin/etc/passwd && \ echo "appgroup:x:$ID:appuser" > ./bin/etc/group diff --git a/Dockerfile.arm5 b/Dockerfile.arm5 index 3677e3e..96b24ab 100644 --- a/Dockerfile.arm5 +++ b/Dockerfile.arm5 @@ -3,9 +3,11 @@ FROM golang:latest as builder WORKDIR /go/src/github.com/PierreZ/goStatic COPY . . RUN mkdir ./bin && \ - CGO_ENABLED=0 GOARCH=arm GOARM=5 GOOS=linux go build -tags netgo -installsuffix netgo -o ./bin/goStatic && \ + apt-get update && apt-get install -y upx && \ + CGO_ENABLED=0 GOARCH=arm GOARM=5 GOOS=linux go build -ldflags="-s" -tags netgo -installsuffix netgo -o ./bin/goStatic && \ mkdir ./bin/etc && \ ID=$(shuf -i 100-9999 -n 1) && \ + upx -9 ./bin/goStatic && \ echo $ID && \ echo "appuser:x:$ID:$ID::/sbin/nologin:/bin/false" > ./bin/etc/passwd && \ echo "appgroup:x:$ID:appuser" > ./bin/etc/group diff --git a/Dockerfile.arm6 b/Dockerfile.arm6 index 892a0ac..3e8fcfb 100644 --- a/Dockerfile.arm6 +++ b/Dockerfile.arm6 @@ -3,9 +3,11 @@ FROM golang:latest as builder WORKDIR /go/src/github.com/PierreZ/goStatic COPY . . RUN mkdir ./bin && \ - CGO_ENABLED=0 GOARCH=arm GOARM=6 GOOS=linux go build -tags netgo -installsuffix netgo -o ./bin/goStatic && \ + apt-get update && apt-get install -y upx && \ + CGO_ENABLED=0 GOARCH=arm GOARM=6 GOOS=linux go build -ldflags="-s" -tags netgo -installsuffix netgo -o ./bin/goStatic && \ mkdir ./bin/etc && \ ID=$(shuf -i 100-9999 -n 1) && \ + upx -9 ./bin/goStatic && \ echo $ID && \ echo "appuser:x:$ID:$ID::/sbin/nologin:/bin/false" > ./bin/etc/passwd && \ echo "appgroup:x:$ID:appuser" > ./bin/etc/group diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 2c11adc..20d91b9 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -3,9 +3,11 @@ FROM golang:latest as builder WORKDIR /go/src/github.com/PierreZ/goStatic COPY . . RUN mkdir ./bin && \ - CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -tags netgo -installsuffix netgo -o ./bin/goStatic && \ + apt-get update && apt-get install -y upx && \ + CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -ldflags="-s" -tags netgo -installsuffix netgo -o ./bin/goStatic && \ mkdir ./bin/etc && \ ID=$(shuf -i 100-9999 -n 1) && \ + upx -9 ./bin/goStatic && \ echo $ID && \ echo "appuser:x:$ID:$ID::/sbin/nologin:/bin/false" > ./bin/etc/passwd && \ echo "appgroup:x:$ID:appuser" > ./bin/etc/group diff --git a/Dockerfile.arm7 b/Dockerfile.arm7 index f3cfb98..14506ea 100644 --- a/Dockerfile.arm7 +++ b/Dockerfile.arm7 @@ -3,9 +3,11 @@ FROM golang:latest as builder WORKDIR /go/src/github.com/PierreZ/goStatic COPY . . RUN mkdir ./bin && \ - CGO_ENABLED=0 GOARCH=arm GOARM=7 GOOS=linux go build -tags netgo -installsuffix netgo -o ./bin/goStatic && \ + apt-get update && apt-get install -y upx && \ + CGO_ENABLED=0 GOARCH=arm GOARM=7 GOOS=linux go build -ldflags="-s" -tags netgo -installsuffix netgo -o ./bin/goStatic && \ mkdir ./bin/etc && \ ID=$(shuf -i 100-9999 -n 1) && \ + upx -9 ./bin/goStatic && \ echo $ID && \ echo "appuser:x:$ID:$ID::/sbin/nologin:/bin/false" > ./bin/etc/passwd && \ echo "appgroup:x:$ID:appuser" > ./bin/etc/group