debian-forge-composer/distribution/Dockerfile-ubi
Ondřej Budai 128f56169e Dockerfile*: chown the copied files
When `go install` is called, go tries to get the git commit hash and embed it
into the built binary. Internally, go just calls the git executable.

The newer go-toolset seems to be based on RHEL 9.2 that ships a newer version
of git (2.39.1). This version contains the safe directory patch that
disallows git from operating on repositories owned by different users.

Thus, we need to chown the files when copying.

See

https://git-scm.com/docs/git-config/2.35.2#Documentation/git-config.txt-safedirectory
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-05-17 13:08:29 +02:00

35 lines
1.6 KiB
Text

FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder
# We need to be root to install packages, but ubi9/go-toolset defaults to uid 1001
USER 0
# The go package `proglottis/gpgme` a dependency of `containers/image/v5` package
# uses `libgpgme` so we need to install it and its build dependencies
RUN dnf install -y gpgme-devel libassuan-devel
USER 1001
# ubi9/go-toolset defaults to uid 1001. Let's copy the files with this UID as well.
# Otherwise, VCS stamping will fail because git >= 2.35.2 refuses to work in
# a repository owned by a different user.
COPY --chown=1001 . .
ENV GOFLAGS=-mod=vendor
RUN go install ./cmd/osbuild-composer/
FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder2
RUN go install github.com/jackc/tern@latest
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
RUN microdnf install -y python3 python3-dnf
RUN mkdir -p "/usr/libexec/osbuild-composer"
RUN mkdir -p "/etc/osbuild-composer/"
RUN mkdir -p "/run/osbuild-composer/"
RUN mkdir -p "/var/cache/osbuild-composer/"
RUN mkdir -p "/var/lib/osbuild-composer/"
RUN mkdir -p "/usr/share/osbuild-composer/"
RUN mkdir -p "/opt/migrate/"
COPY --from=builder /opt/app-root/src/go/bin/osbuild-composer /usr/libexec/osbuild-composer/
COPY ./containers/osbuild-composer/entrypoint.py /opt/entrypoint.py
COPY ./dnf-json /usr/libexec/osbuild-composer/
COPY ./pkg/jobqueue/dbjobqueue/schemas /opt/migrate/schemas
COPY --from=builder2 /opt/app-root/src/go/bin/tern /opt/migrate/
EXPOSE 8080 8700
ENTRYPOINT ["python3", "/opt/entrypoint.py", "--remote-worker-api", "--composer-api", "--shutdown-wait-period", "15"]