Skip to content

Commit 697074d

Browse files
committed
Switch to ubuntu base image to support riscv64
Signed-off-by: CrazyMax <[email protected]>
1 parent 266e4b7 commit 697074d

3 files changed

Lines changed: 32 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
- linux/arm/v7
8080
- linux/arm64
8181
- linux/ppc64le
82+
- linux/riscv64
8283
- linux/s390x
8384
- windows/amd64
8485
- windows/arm64

Dockerfile

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG BASE_VARIANT=bullseye
3+
ARG BASE_IMAGE="ubuntu:20.04"
44
ARG GO_VERSION=1.18.1
55
ARG XX_VERSION=1.1.0
66

77
ARG DEBIAN_FRONTEND=noninteractive
8-
ARG APT_MIRROR=deb.debian.org
98
ARG GO_LINKMODE=static
109
ARG DEV_SYSTEMD=false
1110

@@ -40,20 +39,40 @@ RUN mkdir -p /out
4039
FROM scratch AS binary-dummy
4140
COPY --from=build-dummy / /
4241

43-
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} AS base
42+
FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS golang
43+
ARG DEBIAN_FRONTEND
44+
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates curl jq
45+
WORKDIR /golang
46+
RUN curl -m30 --retry 5 --retry-connrefused --retry-delay 5 -sSL "https://go.dev/dl/?mode=json&include=all" -o "godist.json"
47+
ARG GO_VERSION
48+
ARG BUILDOS
49+
ARG BUILDARCH
50+
ENV PATH="/usr/local/go/bin:$PATH"
51+
RUN <<EOT
52+
GO_DIST_FILE=go${GO_VERSION%.0}.${BUILDOS}-${BUILDARCH}.tar.gz
53+
GO_DIST_URL=https://golang.org/dl/${GO_DIST_FILE}
54+
SHA256=$(cat godist.json | jq -r ".[] | select(.version==\"go${GO_VERSION%.0}\") | .files[] | select(.filename==\"$GO_DIST_FILE\").sha256")
55+
curl -sSL "$GO_DIST_URL.asc" -o "go.tgz.asc"
56+
curl -sSL "$GO_DIST_URL" -o "go.tgz"
57+
echo "$SHA256 *go.tgz" | sha256sum -c -
58+
tar -C /usr/local -xzf go.tgz
59+
go version
60+
EOT
61+
62+
FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS base
4463
COPY --from=xx / /
4564
RUN echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
46-
ARG APT_MIRROR
47-
RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
48-
&& sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list
4965
ENV GO111MODULE=off
5066
ARG DEBIAN_FRONTEND
51-
# bullseye-backports for cmake
52-
RUN echo "deb https://deb.debian.org/debian bullseye-backports main contrib non-free" >> /etc/apt/sources.list
5367
RUN --mount=type=cache,sharing=locked,id=moby-base-aptlib,target=/var/lib/apt \
54-
--mount=type=cache,sharing=locked,id=moby-base-aptcache,target=/var/cache/apt \
55-
apt-get update && apt-get install --no-install-recommends -y bash file git make lld && \
56-
apt-get -y -t bullseye-backports install cmake
68+
--mount=type=cache,sharing=locked,id=moby-base-aptcache,target=/var/cache/apt \
69+
apt-get update && apt-get install --no-install-recommends -y bash ca-certificates cmake file git make lld
70+
# install go
71+
COPY --from=golang /usr/local/go /usr/local/go
72+
ENV GOROOT="/usr/local/go"
73+
ENV GOPATH="/go"
74+
ENV PATH="$GOPATH/bin:/usr/local/go/bin:$PATH"
75+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5776

5877
# go-winres
5978
FROM base AS gowinres

docker-bake.hcl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
variable "APT_MIRROR" {
2-
default = "deb.debian.org"
3-
}
41
variable "GO_VERSION" {
52
default = "1.18.1"
63
}
@@ -56,7 +53,6 @@ variable "PACKAGER_NAME" {
5653
target "_common" {
5754
args = {
5855
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1 # https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#built-in-build-args
59-
APT_MIRROR = APT_MIRROR
6056
GO_VERSION = GO_VERSION
6157
GO_DEBUG = GO_DEBUG
6258
GO_STRIP = GO_STRIP
@@ -80,6 +76,7 @@ target "_platforms" {
8076
"linux/arm/v7",
8177
"linux/arm64",
8278
"linux/ppc64le",
79+
"linux/riscv64",
8380
"linux/s390x",
8481
"windows/amd64",
8582
"windows/arm64"

0 commit comments

Comments
 (0)