How to run or deploy app with git dependency from private repo
My application has a Git dependency on a private BitBucket repository.
my_package:
git:
url: git@bitbucket.org:myuser/mypackage.git
When I ran
gcloud --verbosity debug preview app run app.yaml
I get
Resolving dependencies...
Git error. Command: git clone --mirror git@bitbucket.org: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
I am guessing that adding a statement ADD
in Dockerfile
would be a viable solution.
For this to work, the repo needs to be checked out in the local directory.
I tried:
FROM google/dart-runtime
ADD ../my_package ../my_package
https://docs.docker.com/reference/builder/#add says
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.
It seems I need to move a directory ..my_package
to a directory my_app
. It's not beautiful: - (
When I add a dummy line to Dockerfile
run
, but if I add a statement ADD ...
, it seems to be completely ignored.
source to share
Update 2
My previous solution is still very awkward because I have to check every time before starting the application again.
With a lot of support, I found a much more convenient solution. Instead of a symbolic link, I mount the directory. See https://superuser.com/questions/842642 for details . I don't know if and how this can work on other oSes (Win, OX X, ...)
I am mounting ../my_package
in docker/my_package
(instead of a symlink) and using this 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"]
Update 1
It turns out to be just serving the .git
uploaded package directory , albeit git-daemon
a much more convenient solution.
All I had to do was install everything as per the docs https://www.dartlang.org/cloud/ and use the git dependency in pubspec.yaml
to this repo, served by the git-demon.
my_package: git: url: git://192.168.2.96/my_package ref: test
This url works when running locally as well as in a Docker container.
Original
I can run my application with this 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 git@bitbucket.org: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"]
I created id_rsa
with ssh-keygen without passphrase. It is for this reason that I remove the file from the image after the command git clone
. In any case, it is not used.
In my BitBucket repository, I added id_rsa.pub
as a deployment key.
source to share
Apologies for adding this as an answer, but I cannot comment without more rep:
Please vote on google-cloud-sdk issue 93 if you'd like to get this fixed:
https://code.google.com/p/google-cloud-sdk/issues/detail?id=93
source to share