diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 31bc01fb..061df85e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,7 +7,7 @@ Contributions are [released](https://help.github.com/articles/github-terms-of-se 1. [Fork](https://github.com/qdm12/gluetun/fork) and clone the repository 1. Create a new branch `git checkout -b my-branch-name` 1. Modify the code -1. Ensure the docker build succeeds `docker build .` +1. Ensure the docker build succeeds `docker build .` (you might need `export DOCKER_BUILDKIT=1`) 1. Commit your modifications 1. Push to your fork and [submit a pull request](https://github.com/qdm12/gluetun/compare) diff --git a/Dockerfile b/Dockerfile index fddd5577..4f345a2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG ALPINE_VERSION=3.12 ARG GO_VERSION=1.15 -FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base +FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base RUN apk --update add git ENV CGO_ENABLED=0 WORKDIR /tmp/gobuild @@ -10,25 +10,29 @@ RUN go mod download COPY cmd/ ./cmd/ COPY internal/ ./internal/ -FROM base AS test +FROM --platform=$BUILDPLATFORM base AS test ENV CGO_ENABLED=1 RUN apk --update add g++ RUN go test -race ./... -FROM base AS lint +FROM --platform=$BUILDPLATFORM base AS lint ARG GOLANGCI_LINT_VERSION=v1.34.1 RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ sh -s -- -b /usr/local/bin ${GOLANGCI_LINT_VERSION} COPY .golangci.yml ./ RUN golangci-lint run --timeout=10m -FROM base AS build +FROM --platform=$BUILDPLATFORM base AS build +COPY --from=qmcgaw/xcputranslate /xcputranslate /usr/local/bin/xcputranslate +ARG TARGETPLATFORM ARG VERSION=unknown ARG BUILD_DATE="an unknown date" ARG COMMIT=unknown COPY cmd/ ./cmd/ COPY internal/ ./internal/ -RUN go build -trimpath -ldflags="-s -w \ +RUN GOARCH="$(echo ${TARGETPLATFORM} | xcputranslate -field arch)" \ + GOARM="$(echo ${TARGETPLATFORM} | xcputranslate -field arm)" \ + go build -trimpath -ldflags="-s -w \ -X 'main.version=$VERSION' \ -X 'main.buildDate=$BUILD_DATE' \ -X 'main.commit=$COMMIT' \