more utilites, removed unsupported architectures, simplified installation for delve

This commit is contained in:
Pavel 2022-07-26 19:39:53 +03:00
parent 4b0b69d1e9
commit a73b933299
8 changed files with 72 additions and 100 deletions

View File

@ -15,22 +15,22 @@ jobs:
docker-file: docker-file:
- path: 1.16 - path: 1.16
tags: "1.16" tags: "1.16"
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/386
- path: 1.16-3.13 - path: 1.16-3.13
tags: "1.16-3.13" tags: "1.16-3.13"
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/386
- path: 1.17 - path: 1.17
tags: "1.17" tags: "1.17"
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/386
- path: 1.17-3.13 - path: 1.17-3.13
tags: "1.17-3.13" tags: "1.17-3.13"
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/386
- path: 1.18 - path: 1.18
tags: "1.18" tags: "1.18"
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/386
- path: 1.18-3.13 - path: 1.18-3.13
tags: "1.18-3.13" tags: "1.18-3.13"
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6 platforms: linux/amd64,linux/arm64,linux/386
steps: steps:
- name: Checkout - name: Checkout
@ -39,7 +39,7 @@ jobs:
- name: Prepare - name: Prepare
id: prepare id: prepare
run: | run: |
DOCKER_IMAGE=neur0toxine/golang-alpine-dumb-init DOCKER_IMAGE=neur0toxine/golang-alpine
TEMP="${{ matrix.docker-file.tags }}" TEMP="${{ matrix.docker-file.tags }}"
TAGZ=($TEMP) TAGZ=($TEMP)

View File

@ -1,13 +1,10 @@
FROM golang:1.16-alpine3.13 FROM golang:1.16-alpine3.13
RUN set -eux; \ RUN set -eux; \
apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \ apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \
cd /tmp && \ go install github.com/go-delve/delve/cmd/dlv@latest && \
git clone https://github.com/go-delve/delve && \ go install github.com/cosmtrek/air@latest && \
cd delve && \ go install github.com/jstemmer/go-junit-report@latest && \
go install github.com/go-delve/delve/cmd/dlv && \ go install github.com/axw/gocov/gocov@latest && \
cd / && \ chmod -R 777 "$GOPATH"
go install github.com/cosmtrek/air@latest && \
rm -rf delve && \
chmod -R 777 /go
WORKDIR / WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -1,13 +1,10 @@
FROM golang:1.16-alpine FROM golang:1.16-alpine
RUN set -eux; \ RUN set -eux; \
apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \ apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \
cd /tmp && \ go install github.com/go-delve/delve/cmd/dlv@latest && \
git clone https://github.com/go-delve/delve && \ go install github.com/cosmtrek/air@latest && \
cd delve && \ go install github.com/jstemmer/go-junit-report@latest && \
go install github.com/go-delve/delve/cmd/dlv && \ go install github.com/axw/gocov/gocov@latest && \
cd / && \ chmod -R 777 "$GOPATH"
go install github.com/cosmtrek/air@latest && \
rm -rf delve && \
chmod -R 777 /go
WORKDIR / WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -1,13 +1,10 @@
FROM golang:1.17-alpine3.13 FROM golang:1.17-alpine3.13
RUN set -eux; \ RUN set -eux; \
apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \ apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \
cd /tmp && \ go install github.com/go-delve/delve/cmd/dlv@latest && \
git clone https://github.com/go-delve/delve && \ go install github.com/cosmtrek/air@latest && \
cd delve && \ go install github.com/jstemmer/go-junit-report@latest && \
go install github.com/go-delve/delve/cmd/dlv && \ go install github.com/axw/gocov/gocov@latest && \
cd / && \ chmod -R 777 "$GOPATH"
go install github.com/cosmtrek/air@latest && \
rm -rf delve && \
chmod -R 777 /go
WORKDIR / WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -1,13 +1,10 @@
FROM golang:1.17-alpine FROM golang:1.17-alpine
RUN set -eux; \ RUN set -eux; \
apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \ apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \
cd /tmp && \ go install github.com/go-delve/delve/cmd/dlv@latest && \
git clone https://github.com/go-delve/delve && \ go install github.com/cosmtrek/air@latest && \
cd delve && \ go install github.com/jstemmer/go-junit-report@latest && \
go install github.com/go-delve/delve/cmd/dlv && \ go install github.com/axw/gocov/gocov@latest && \
cd / && \ chmod -R 777 "$GOPATH"
go install github.com/cosmtrek/air@latest && \
rm -rf delve && \
chmod -R 777 /go
WORKDIR / WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -1,20 +1,13 @@
FROM alpine:3.13 FROM alpine:3.13
RUN apk add --no-cache ca-certificates
# set up nsswitch.conf for Go's "netgo" implementation
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
# - docker run --rm debian grep '^hosts:' /etc/nsswitch.conf
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
ENV PATH /usr/local/go/bin:$PATH ENV PATH /usr/local/go/bin:$PATH
ENV GOLANG_VERSION 1.18.4
RUN set -eux; \ RUN set -eux; \
apk add --no-cache ca-certificates jq curl; \
([ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf); \
apk add --no-cache --virtual .fetch-deps gnupg; \ apk add --no-cache --virtual .fetch-deps gnupg; \
arch="$(apk --print-arch)"; \ arch="$(apk --print-arch)"; \
url=; \ export GOVERSION="$(curl -fsSL 'https://go.dev/dl/?mode=json&include=1.18' | jq -r '.[0].version')"; \
case "$arch" in \ case "$arch" in \
'x86_64') \ 'x86_64') \
export GOAMD64='v1' GOARCH='amd64' GOOS='linux'; \ export GOAMD64='v1' GOARCH='amd64' GOOS='linux'; \
@ -39,14 +32,10 @@ RUN set -eux; \
;; \ ;; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \ *) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \ esac; \
build=; \
if [ -z "$url" ]; then \
# https://github.com/golang/go/issues/38536#issuecomment-616897960 # https://github.com/golang/go/issues/38536#issuecomment-616897960
build=1; \ url="https://dl.google.com/go/$GOVERSION.src.tar.gz"; \
url='https://dl.google.com/go/go1.18.4.src.tar.gz'; \ sha256='4525aa6b0e3cecb57845f4060a7075aafc9ab752bb7b6b4cf8a212d43078e1e4'; \
sha256='4525aa6b0e3cecb57845f4060a7075aafc9ab752bb7b6b4cf8a212d43078e1e4'; \
# the precompiled binaries published by Go upstream are not compatible with Alpine, so we always build from source here 😅 # the precompiled binaries published by Go upstream are not compatible with Alpine, so we always build from source here 😅
fi; \
\ \
wget -O go.tgz.asc "$url.asc"; \ wget -O go.tgz.asc "$url.asc"; \
wget -O go.tgz "$url"; \ wget -O go.tgz "$url"; \
@ -65,36 +54,34 @@ RUN set -eux; \
tar -C /usr/local -xzf go.tgz; \ tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \ rm go.tgz; \
\ \
if [ -n "$build" ]; then \ apk add --no-cache --virtual .build-deps \
apk add --no-cache --virtual .build-deps \ bash \
bash \ gcc \
gcc \ go \
go \ musl-dev \
musl-dev \ ; \
; \ \
\ export GOCACHE='/tmp/gocache'; \
export GOCACHE='/tmp/gocache'; \ \
\ ( \
( \ cd /usr/local/go/src; \
cd /usr/local/go/src; \
# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully # set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \ export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
./make.bash; \ ./make.bash; \
); \ ); \
\ \
apk del --no-network .build-deps; \ apk del --no-network .build-deps; \
\ \
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain # remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
rm -rf \ rm -rf \
/usr/local/go/pkg/*/cmd \ /usr/local/go/pkg/*/cmd \
/usr/local/go/pkg/bootstrap \ /usr/local/go/pkg/bootstrap \
/usr/local/go/pkg/obj \ /usr/local/go/pkg/obj \
/usr/local/go/pkg/tool/*/api \ /usr/local/go/pkg/tool/*/api \
/usr/local/go/pkg/tool/*/go_bootstrap \ /usr/local/go/pkg/tool/*/go_bootstrap \
/usr/local/go/src/cmd/dist/dist \ /usr/local/go/src/cmd/dist/dist \
"$GOCACHE" \ "$GOCACHE" \
; \ ; \
fi; \
\ \
apk del --no-network .fetch-deps; \ apk del --no-network .fetch-deps; \
\ \
@ -106,14 +93,11 @@ RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH WORKDIR $GOPATH
RUN set -eux; \ RUN set -eux; \
apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \ apk add --no-cache bash make git gcc libc-dev dumb-init && \
cd /tmp && \ go install github.com/go-delve/delve/cmd/dlv@latest && \
git clone https://github.com/go-delve/delve && \ go install github.com/cosmtrek/air@latest && \
cd delve && \ go install github.com/jstemmer/go-junit-report@latest && \
go install github.com/go-delve/delve/cmd/dlv && \ go install github.com/axw/gocov/gocov@latest && \
cd / && \ chmod -R 777 "$GOPATH"
go install github.com/cosmtrek/air@latest && \
rm -rf delve && \
chmod -R 777 /go
WORKDIR / WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -1,13 +1,10 @@
FROM golang:1.18-alpine FROM golang:1.18-alpine
RUN set -eux; \ RUN set -eux; \
apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \ apk add --no-cache bash make git gcc libc-dev jq curl dumb-init && \
cd /tmp && \ go install github.com/go-delve/delve/cmd/dlv@latest && \
git clone https://github.com/go-delve/delve && \ go install github.com/cosmtrek/air@latest && \
cd delve && \ go install github.com/jstemmer/go-junit-report@latest && \
go install github.com/go-delve/delve/cmd/dlv && \ go install github.com/axw/gocov/gocov@latest && \
cd / && \ chmod -R 777 "$GOPATH"
go install github.com/cosmtrek/air@latest && \
rm -rf delve && \
chmod -R 777 /go
WORKDIR / WORKDIR /
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]

View File

@ -17,6 +17,9 @@ A minimal Dockerfile based on Go 1.16, 1.17, 1.18 and alpine with dumb-init and
- jq - jq
- curl - curl
- air - air
- delve
- gocov
- go-junit-report
- dumb-init - dumb-init
### Available platforms ### Available platforms