Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go 1.21.1 errors parsing go.mod #984

Closed
3 tasks done
Septrum101 opened this issue Oct 8, 2023 · 3 comments
Closed
3 tasks done

go 1.21.1 errors parsing go.mod #984

Septrum101 opened this issue Oct 8, 2023 · 3 comments

Comments

@Septrum101
Copy link

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

When I user go 1.21.1, this actions will failure

Expected behaviour

success Build and push by digest

Actual behaviour

#14 [builder 4/5] RUN go mod download
#14 0.326 go: errors parsing go.mod:
#14 0.326 /app/go.mod:5: unknown directive: toolchain
#14 ERROR: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1
------
 > [builder 4/5] RUN go mod download:
0.326 go: errors parsing go.mod:
0.326 /app/go.mod:5: unknown directive: toolchain
------
Dockerfile:6
--------------------
   4 |     COPY . .
   5 |     ENV CGO_ENABLED=0
   6 | >>> RUN go mod download
   7 |     RUN go build -v -o XrayR -trimpath -ldflags "-s -w -buildid=" ./main
   8 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1
Error: buildx failed with: ERROR: failed to solve: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1

Repository URL

https://github.com/XrayR-project/XrayR

Workflow run URL

https://github.com/XrayR-project/XrayR/actions

YAML workflow

name: Publish Docker image
on:
  workflow_dispatch:
  push:
    branches:
      - master
    paths:
      - "**/*.go"
      - "go.mod"
      - "go.sum"
      - ".github/workflows/*.yml"
    tags:
      - 'v*'
  pull_request:
    branches:
      - 'master'
env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        platform:
          - linux/amd64
          - linux/arm/v6
          - linux/arm/v7
          - linux/arm64
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Build and push by digest
        id: build
        uses: docker/build-push-action@v5
        with:
          context: .
          platforms: ${{ matrix.platform }}
          labels: ${{ steps.meta.outputs.labels }}
          outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
      - name: Export digest
        run: |
          mkdir -p /tmp/digests
          digest="${{ steps.build.outputs.digest }}"
          touch "/tmp/digests/${digest#sha256:}"          
      - name: Upload digest
        uses: actions/upload-artifact@v3
        with:
          name: digests
          path: /tmp/digests/*
          if-no-files-found: error
          retention-days: 1

  merge:
    runs-on: ubuntu-latest
    needs:
      - build
    steps:
      - name: Download digests
        uses: actions/download-artifact@v3
        with:
          name: digests
          path: /tmp/digests
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Create manifest list and push
        working-directory: /tmp/digests
        run: |
          docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
            $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)          
      - name: Inspect image
        run: |
          docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

Workflow logs

#14 [builder 4/5] RUN go mod download
#14 0.326 go: errors parsing go.mod:
#14 0.326 /app/go.mod:5: unknown directive: toolchain
#14 ERROR: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1
------
 > [builder 4/5] RUN go mod download:
0.326 go: errors parsing go.mod:
0.326 /app/go.mod:5: unknown directive: toolchain
------
Dockerfile:6
--------------------
   4 |     COPY . .
   5 |     ENV CGO_ENABLED=0
   6 | >>> RUN go mod download
   7 |     RUN go build -v -o XrayR -trimpath -ldflags "-s -w -buildid=" ./main
   8 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1
Error: buildx failed with: ERROR: failed to solve: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1

### BuildKit logs

_No response_

### Additional info

_No response_
@Septrum101
Copy link
Author

This problem comes from buildkit. Need https://github.com/moby/buildkit to update.

@crazy-max
Copy link
Member

crazy-max commented Oct 8, 2023

This problem comes from buildkit. Need https://github.com/moby/buildkit to update.

Why do you think this is a buildkit issue?

unknown directive: toolchain

This looks related to golang/go#62409 and looking at your go.mod: https://github.com/XrayR-project/XrayR/blob/682af90252d1a9c866ece1096698ac693412695b/go.mod#L3 and Dockerfile: https://github.com/XrayR-project/XrayR/blob/682af90252d1a9c866ece1096698ac693412695b/Dockerfile#L2 you need to update to Go 1.21.

@Septrum101
Copy link
Author

This problem comes from buildkit. Need https://github.com/moby/buildkit to update.

Why do you think this is a buildkit issue?

unknown directive: toolchain

This looks related to golang/go#62409 and looking at your go.mod: https://github.com/XrayR-project/XrayR/blob/682af90252d1a9c866ece1096698ac693412695b/go.mod#L3 and Dockerfile: https://github.com/XrayR-project/XrayR/blob/682af90252d1a9c866ece1096698ac693412695b/Dockerfile#L2 you need to update to Go 1.21.

Its awesome, Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants