apache / apache/answer

Docker build fails with: `version "v2.0.0" invalid: should be v0 or v1, not v2`

Open
#1,514 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
15.7k
Forks
1.4k
Avg merge
3d 8h
Merged PRs (30d)
7

Description

## Describe the bug

Custom build using `ANSWER_MODULE` failing with: `replace github.com/apache/answer: version "v2.0.0" invalid: should be v0 or v1, not v2`

## To Reproduce

Steps to reproduce the behavior:

1. Specify `ARG ANSWER_MODULE=github.com/apache/answer@v2.0.0` and build apache answer
2. See build fail with error

## Expected behavior

A working build.

## CI/CD log

```
#15 43.92 go: downloading github.com/apache/answer-plugins/reviewer-basic v1.0.8
#15 44.20 go: added github.com/apache/answer-plugins/reviewer-basic v1.0.8
#15 44.21 [go mod edit -replace github.com/apache/answer=github.com/apache/answer@v2.0.0]
#15 44.23 [go mod tidy]
#15 44.24 go: errors parsing go.mod:
#15 44.24 go.mod:73: replace github.com/apache/answer: version "v2.0.0" invalid: should be v0 or v1, not v2
#15 44.24 build failed exit status 1
#15 ERROR: process "/bin/bash -c /scripts/build.sh" did not complete successfully: exit code: 1
```

## Dockerfile

```
# Initialize /usr/bin/answer
# INFO: Replace version
FROM docker.io/apache/answer:2.0.0 AS answer-builder
# INFO: Replace version
FROM code.forgejo.org/oci/golang:1.26-alpine3.23 AS golang-builder
COPY --from=answer-builder /usr/bin/answer /usr/bin/answer

# Set build time variables
# INFO: Replace version
ARG PNPM_VERSION=10.32.1
ARG ANSWER_MODULE=github.com/apache/answer@v2.0.0

# Install dependencies
RUN apk --no-cache add \
build-base git bash nodejs npm go && \
npm install -g pnpm@${PNPM_VERSION}

# Build /usr/bin/new_answer
COPY scripts/ /scripts
RUN chmod 755 /scripts/*.sh
RUN ["/bin/bash","-c","/scripts/build.sh"]

# Defaults from https://github.com/apache/answer/blob/main/Dockerfile
# INFO: Replace version
FROM code.forgejo.org/oci/alpine:latest
LABEL maintainer="linkinstar@apache.org"

ARG TIMEZONE
ENV TIMEZONE=${TIMEZONE:-"Asia/Shanghai"}

RUN apk update \
&& apk --no-cache add \
bash \
ca-certificates \
curl \
dumb-init \
gettext \
openssh \
sqlite \
gnupg \
tzdata \
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone

# Defaults from https://answer.apache.org/docs/plugins/#build-with-plugin-from-answer-base-image
COPY --from=golang-builder /usr/bin/new_answer /usr/bin/answer
COPY --from=answer-builder /data /data
COPY --from=answer-builder /entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh

VOLUME /data
ENTRYPOINT ["/entrypoint.sh"]
```

## Problem

As far as I understand, go requires a `/v2` suffix after a major version bump. Also see [this](https://go.dev/blog/v2-go-modules).

If you want met to submit a PR, please let me know, but I think this is better handled by maintainers. Also my understanding of go is limited so this problem description might not be 100% accurate.

## Platform

- Device: n.a
- OS: n.a
- Browser and version: n.a
- Version: v2.0.0

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Dockerfile and scripts/build.sh, then inspect the go.mod entry reported in the build log and how ANSWER_MODULE is passed into the build. Reproduce the failure with ANSWER_MODULE=github.com/apache/answer@v2.0.0 and check the module path and release versioning. Done means the custom Docker build completes successfully for the documented v2.0.0 input.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
build-system, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.