我的应用程序对私有BitBucket存储库具有Git依赖关系。
my_package:
git:
url: [email protected]:myuser/mypackage.git
当我跑步时
gcloud --verbosity debug preview app run app.yaml
我懂了
Resolving dependencies...
Git error. Command: git clone --mirror [email protected]:myuser/my_package.git /root/.pub-cache/git/cache/my_package-6fe77906161a7a9252973e29e39a4149b75f9a7e
error: cannot run ssh: No such file or directory
fatal: unable to fork
我想在上添加一条ADD
指令Dockerfile
将是一个可行的解决方法。
该仓库需要检出到本地目录才能正常工作。
我试过了:
FROM google/dart-runtime
ADD ../my_package ../my_package
https://docs.docker.com/reference/builder/#add说
The <src> path must be inside the context of the build; you cannot ADD
../something /something, because the first step of a docker build is to
send the context directory (and subdirectories) to the docker daemon.
看来我必须将..my_package
目录移动到my_app
目录中。这不漂亮:-(
当我向Dockerfile
run
失败添加一条假行时,但是如果我添加一条ADD ...
指令,它似乎将被完全忽略。
我以前的解决方案仍然很不方便,因为在每次重新启动应用程序之前,我必须每次都进行检入。
在强大的支持下,我找到了一个更加方便的解决方案。我挂载目录而不是符号链接。有关更多详细信息,请参见https://superuser.com/questions/842642。我不知道这是否可以以及如何在其他操作系统上运行(Win,OX X,...)
我安装../my_package
到docker/my_package
(而不是符号链接)并使用此Dockerfile:
FROM google/dart
WORKDIR /app
ENV DART_SDK /usr/lib/dart
ADD dart_run.sh /dart_runtime/
RUN chmod 755 /dart_runtime/dart_run.sh && \
chown root:root /dart_runtime/dart_run.sh
ADD pubspec.yaml /app/
ADD pubspec.lock /app/
ADD docker/my_package /my_package
RUN pub get
ADD . /app/
RUN pub get --offline
## Expose ports for debugger (5858), application traffic (8080)
## and the observatory (8181)
EXPOSE 8080 8181 5858
CMD []
ENTRYPOINT ["/dart_runtime/dart_run.sh"]
事实证明,仅提供已.git
检出软件包的目录git-daemon
是一个更方便的解决方案。
我要做的就是根据https://www.dartlang.org/cloud/上的文档进行全部设置,并在pubspec.yaml
git-daemon服务的此仓库中使用git依赖项。
my_package:
git:
url: git://192.168.2.96/my_package
ref: test
该URL在本地以及在Docker容器内工作时均有效。
我可以使用此Dockerfile运行我的应用
FROM google/dart
WORKDIR /app
RUN \
apt-get update && \
apt-get install -y openssh-client
ADD tool/bitbucket_deployment_key /root/.ssh/id_rsa
RUN \
mkdir -p /root/.ssh && \
echo "Host bitbucket.org" >> /root/.ssh/config && \
echo " StrictHostKeyChecking no" >> /root/.ssh/config && \
# ssh-keyscan -t rsa -H bitbucket.org,131.103.20.167 >> /root/.ssh/known_hosts && \
chmod 400 /root/.ssh/id_rsa && \
eval $(ssh-agent) && \
ssh-add /root/.ssh/id_rsa
RUN \
git clone [email protected]:myuser/my_package.git /my_package --branch test && \
rm /root/.ssh/id_rsa
#ENV DART_SDK /usr/lib/dart
ADD dart_run.sh /dart_runtime/
RUN chmod 755 /dart_runtime/dart_run.sh && \
chown root:root /dart_runtime/dart_run.sh
ADD pubspec.yaml /app/
ADD pubspec.lock /app/
RUN pub get
ADD . /app/
RUN pub get --offline
# Expose ports for debugger (5858), application traffic (8080)
# and the observatory (8181)
EXPOSE 8080 8181 5858
CMD []
ENTRYPOINT ["/dart_runtime/dart_run.sh"]
我是id_rsa
使用ssh-keygen创建的,没有密码短语。这就是我在git clone
命令后从图像中删除文件的原因。无论如何,以后都不会使用它。
在我的BitBucket存储库中,我添加了id_rsa.pub
作为部署密钥。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句