我目前正在努力生成一个实例并直接运行一些有关Google Compute Engine的代码。我遇到的主要问题是,如果我想克隆私人仓库,它可以与公共仓库一起使用,但是它不再起作用...
我尝试了许多变通办法,直到现在我都找不到任何情况。我有这个startup-script.sh:
#!/usr/bin/env bash
set -ex
# Talk to the metadata server to get the project id and location of application binary.
PROJECTID=$(curl -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" -H "Metadata-flavor: Google")
# Install logging monitor. The monitor will automatically pickup logs send to
# syslog.
sudo curl -s "https://storage.googleapis.com/signals-agents/logging/google-fluentd-install.sh" | sudo bash
sudo service google-fluentd restart &
# Install dependencies from apt (I actually need them)
sudo apt-get update
sudo apt-get install -yq ca-certificates supervisor git emacs redis-server
#############
# Here I have to setup my SSH key but what are my possibilities?
#############
# Cloning my repo
git clone git@gitlab.com:MY-AWESOME-SERVICE.git service
# Create a goapp user. The application will run as this user.
sudo getent passwd goapp || sudo /usr/sbin/useradd -m -d /home/goapp goapp
sudo chown -R goapp:goapp service
# Configure supervisor to run the Go app.
sudo echo "
[program:goapp]
directory=/service
command=/service/main
autostart=true
autorestart=true
user=goapp
environment=HOME=\"/home/goapp\",USER=\"goapp\"
stdout_logfile=syslog
stderr_logfile=syslog
" > goapp.conf
sudo mv goapp.conf /etc/supervisor/conf.d/goapp.conf
sudo supervisorctl reread
sudo supervisorctl update
# Application should now be running under supervisor
我看到了一些有关ssh-copy-id的东西,但我不确定是否完全了解它是如何工作的
感谢您的帮助!