hibiken / asynq

Simple, reliable, and efficient distributed task queue in Go
MIT License
10.03k stars 716 forks source link

[BUG] Cannot install asynq tools latest version with golang 1.21.1 #943

Closed giangnh13579 closed 3 weeks ago

giangnh13579 commented 3 weeks ago

Describe the bug Cannot install asynq tools latest version with golang 1.21.1 in docker environment

To Reproduce Steps to reproduce the behavior (Code snippets if applicable):

  1. Setup Dockerfile
FROM golang:1.21-alpine as build

....

RUN go install github.com/hibiken/asynq/tools/asynq@latest
  1. Build the docker image
  2. Docker log returns error
 > [api build 10/10] RUN go install github.com/hibiken/asynq/tools/asynq@latest:
0.773 go: downloading github.com/hibiken/asynq/tools v0.0.0-20241026100454-013190b8244f
1.966 go: github.com/hibiken/asynq/tools/asynq@latest: github.com/hibiken/asynq/tools@v0.0.0-20241026100454-013190b8244f requires go >= 1.22 (running go 1.21.13; GOTOOLCHAIN=local)
------
failed to solve: process "/bin/sh -c go install github.com/hibiken/asynq/tools/asynq@latest" did not complete successfully: exit code: 1

Expected behavior

Environment (please complete the following information):

Additional context I've checked the commit history and see a commit that seems to cause this error https://github.com/hibiken/asynq/commit/013190b8244f614d57a522018506a6e24a2b8fc0 . I think I can install previous asynq tools but I can not find the version.

How can I install asynq tools with golang v1.21.1?

kamikazechaser commented 3 weeks ago

@giangnh13579 We recently bumped the minimum go version of this repo to 1.22. Update your toolchain and try again.

giangnh13579 commented 3 weeks ago

@giangnh13579 We recently bumped the minimum go version of this repo to 1.22. Update your toolchain and try again.

My application is running on Golang version 1.21, and I'm not sure if it will crash if I update to version 1.22.

For anyone facing the same issue, I separated the build stages in Docker: one stage uses version 1.21 to build the application, and another uses version 1.22 to build the async tool into a binary file. Then, I copy the files built from each stage into the final container.

FROM golang:1.21-alpine as build

...build your app here

FROM golang:1.22-alpine as build-asynq
WORKDIR /app

RUN apk update && apk add --no-cache git

ARG CGO_ENABLED=0

RUN go install github.com/hibiken/asynq/tools/asynq@latest

## Runtime stage
FROM alpine:3.16.2

...
# copy asynq tools built file
COPY --from=build-asynq /go/bin/asynq ./asynq
....
kamikazechaser commented 3 weeks ago

My application is running on Golang version 1.21, and I'm not sure if it will crash if I update to version 1.22.

Go guarantees backward compatibility, just not forward.