我已經嘗試了很多方法來將我的導軌應用程序構建爲泊塢窗圖像。並將其部署到谷歌容器引擎。但直到現在,沒有人成功。如何使用kubernetes將rails應用程序部署到Google容器引擎?
我Dockerfile(在軌根路徑)
FROM ruby:2.2.2
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y nodejs
ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile $APP_HOME/Gemfile
ADD Gemfile.lock $APP_HOME/Gemfile.lock
ADD vendor/gems/my_gem $APP_HOME/vendor/gems/my_gem
ADD init.sh $APP_HOME/
RUN export LANG=C.UTF-8 && bundle install
ADD . $APP_HOME
CMD ["sh", "init.sh"]
我init.sh
#!/bin/bash
bundle exec rake db:create db:migrate
bundle exec rails server -b 0.0.0.0
我kubernetes配置文件
apiVersion: v1
kind: ReplicationController
metadata:
labels:
name: web
name: web-controller
spec:
replicas: 2
selector:
name: web
template:
metadata:
labels:
name: web
spec:
containers:
- name: web
image: gcr.io/my-project-id/myapp:v1
ports:
- containerPort: 3000
name: http-server
env:
- name: RAILS_ENV
value: "production"
後,我與kubectl GKE創建網絡控制器:
kubectl create -f web-controller.yml
,看到了莢日誌:
kubectl logs web-controller-xxxxx
它表明:
init.sh: 2: init.sh: bundle: not found
init.sh: 3: init.sh: bundle: not found
似乎找不到路徑。那該怎麼辦?