Skip to content

When answer build fails, error code 1 is not return #1317

@hhhguany

Description

@hhhguany

Describe the bug

Building a custom Answer image with plugins fails due to the output binary (/usr/bin/new_answer) not being found after running the answer build command inside a Docker multi-stage build.

Even though the answer build command completes without error, the expected output binary /usr/bin/new_answer does not appear to be created, resulting in a COPY failure in the final stage of the Dockerfile.

To Reproduce

Steps to reproduce the behavior:

  1. Create a multi-stage Dockerfile to build Answer with plugins (see example below).
  2. Run docker build .
  3. Build runs successfully up to the answer build step.
  4. Docker fails on the line COPY --from=golang-builder /usr/bin/new_answer /usr/bin/answer with an error: "/usr/bin/new_answer": not found.
# https://answer.apache.org/docs/plugins/
FROM apache/answer:latest as answer-builder

FROM golang:1.22-alpine AS golang-builder

COPY --from=answer-builder /usr/bin/answer /usr/bin/answer

RUN apk --no-cache add \
    build-base git bash nodejs npm go && \
    npm install -g pnpm@8.9.2

RUN answer build \
    --with github.com/apache/answer-plugins/connector-basic \
    --with github.com/apache/answer-plugins/editor-chart \
    --with github.com/apache/answer-plugins/editor-formula \
    --output /usr/bin/new_answer

FROM alpine
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

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
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]

Expected behavior

The answer build command should produce the specified output binary at /usr/bin/new_answer, which can then be copied into the final image layer.

Screenshots

N/A — see CLI output:

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref ...: "/usr/bin/new_answer": not found

Platform

  • Device: Desktop
  • OS: CentOS 7 (Docker host)
  • Docker version: 24.0.5
  • Answer version: v1.4.5

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions