repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
787c062
parent
2dbbf13
author
Antonio Mika
date
2022-08-31 14:56:23 +0000 UTC
Switch to debian based images and implement cgo cross compilation
2 files changed,  +22, -6
M Dockerfile
+13, -6
 1@@ -1,11 +1,14 @@
 2-FROM --platform=$BUILDPLATFORM golang:1.19-alpine as builder-deps
 3+FROM --platform=$BUILDPLATFORM golang:1.19 as builder-deps
 4 LABEL maintainer="Pico Maintainers <hello@pico.sh>"
 5 
 6-ENV CGO_ENABLED 0
 7-
 8 WORKDIR /app
 9 
10-RUN apk add --no-cache git ca-certificates
11+RUN dpkg --add-architecture arm64 && dpkg --add-architecture amd64
12+RUN apt-get update
13+RUN apt-get install -y git ca-certificates \
14+    libwebp-dev:amd64 libwebp-dev:arm64 \
15+    crossbuild-essential-amd64 crossbuild-essential-arm64 \
16+    libc-dev:amd64 libc-dev:arm64
17 
18 COPY go.* ./
19 
20@@ -19,10 +22,14 @@ ARG APP=lists
21 ARG TARGETOS
22 ARG TARGETARCH
23 
24+ENV CGO_ENABLED=1
25+ENV LDFLAGS="-s -w -linkmode external -extldflags '-static -lm -pthread'"
26+ENV CC=/app/scripts/gccwrap.sh
27+
28 ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
29 
30-RUN go build -o /go/bin/${APP}-ssh -ldflags="-s -w" ./cmd/${APP}/ssh
31-RUN go build -o /go/bin/${APP}-web -ldflags="-s -w" ./cmd/${APP}/web
32+RUN go build -ldflags "$LDFLAGS" -tags netgo -o /go/bin/${APP}-ssh ./cmd/${APP}/ssh
33+RUN go build -ldflags "$LDFLAGS" -tags netgo -o /go/bin/${APP}-web ./cmd/${APP}/web
34 
35 FROM scratch as release-ssh
36 
A scripts/gccwrap.sh
+9, -0
 1@@ -0,0 +1,9 @@
 2+#!/bin/bash
 3+
 4+if [[ "$GOARCH" == "arm64" ]]; then
 5+	GCC_ARCH="aarch64"
 6+elif [[ "$GOARCH" == "amd64" ]]; then
 7+	GCC_ARCH="x86_64"
 8+fi
 9+
10+exec "${GCC_ARCH}-linux-gnu-gcc" "$@"