0

ホスト環境変数を使用した ENV 置換を可能にするために配置したラッパー スクリプトを使用して Docker イメージをビルドしようとすると、常に問題が発生します。

スクリプトを実行するたびに、エラーが発生します。

[+] Building 0.1s (2/2) FINISHED                                                                                                                                                                                                                                                      
 => [internal] load build definition from 63                                                                                                                                                                                                                                     0.1s
 => => transferring dockerfile: 47B                                                                                                                                                                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                0.1s
 => => transferring context: 2B                                                                                                                                                                                                                                                  0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2556703017/pipe:[1080734]: no such file or directory
Unable to find image 'my-image:latest' locally
docker: Error response from daemon: pull access denied for gotk-st24-test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

これがラッパースクリプトです

#!/bin/env bash
# Make sure you have the appropriate token in your ENV variables on a machine that you're running this script on.
DOCKER_BUILDKIT=1 docker build --no-cache  -f <(envsubst < ./Dockerfile) -t "my-image" .
docker run -d -t my-image $1

そして、ここにありますDockerfile

FROM fluxcd/fluxctl:1.24.3 as builder

ARG ARCH=linux/amd64
ARG KUBECTL_VER=1.22.2
ARG GH_CLI_VER=2.2.0

RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VER}/bin/${ARCH}/kubectl \
    -o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl

RUN curl -sL https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_amd64.tar.gz \
    | tar xvz -C /tmp && mv /tmp/gh_${GH_CLI_VER}_linux_amd64/bin/gh /usr/local/bin/ && chmod +x /usr/local/bin/gh && \
    rm -rf /tmp/gh_*

FROM k8s.gcr.io/git-sync/git-sync:v3.3.5 as gitsync

FROM alpine:3.14 as gtk-cli

RUN apk update && apk add coreutils git
ENV GITHUB_TOKEN=$GITHUB_TOKEN

COPY --from=builder --chmod=755 /usr/local/bin/kubectl /usr/local/bin/
COPY --from=builder --chmod=755 /usr/local/bin/fluxctl /usr/local/bin/
COPY --from=builder --chmod=755 /usr/local/bin/gh /usr/local/bin/
COPY --from=gitsync --chmod=755 /git-sync /usr/local/bin/
COPY --chmod=755 ./ssh-entrypoint.sh /ssh-entrypoint.sh
COPY --chmod=755 ./docker-entrypoint.sh /docker-entrypoint.sh

RUN kubectl version --client=true && fluxctl version && gh version
WORKDIR /
ENTRYPOINT [ "/docker-entrypoint.sh" ]

ここで助けていただければ幸いです。

よろしくお願いします!

4

0 に答える 0