在Dockerfile中从Github捆绑

我试图将我们的Rails应用程序移到Docker部署,但是我无法设法从Github引用中获取安装包。

使用下面的Dockerfile:

FROM ruby:2.3.0-slim MAINTAINER Chris Jewell <chrisjohnjewell@gmail.com> # Install dependencies: # - build-essential: To ensure certain gems can be compiled # - nodejs: Compile assets # - libpq-dev: Communicate with postgres through the postgres gem # - postgresql-client-9.4: In case you want to talk directly to postgres RUN apt-get update && apt-get install -qq -y build-essential nodejs libpq-dev postgresql-client-9.4 --fix-missing --no-install-recommends # Set an environment variable to store where the app is installed to inside # of the Docker image. ENV INSTALL_PATH /ventbackend RUN mkdir -p $INSTALL_PATH # This sets the context of where commands will be ran in and is documented # on Docker's website extensively. WORKDIR $INSTALL_PATH # Ensure gems are cached and only get updated when they change. This will # drastically increase build times when your gems do not change. COPY Gemfile Gemfile RUN bundle install # Copy in the application code from your work station at the current directory # over to the working directory. COPY . . # Provide dummy data to Rails so it can pre-compile assets. RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname SECRET_TOKEN=pickasecuretoken assets:precompile # Expose a volume so that nginx will be able to read in assets in production. VOLUME ["$INSTALL_PATH/public"] # The default command that gets ran will be to start the Unicorn server. CMD bundle exec unicorn -c config/unicorn.rb 

尝试运行docker-compose up时出现以下错误:

You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git

我假设这是因为在Gemfile中的行像:

 gem 'logstasher', github: 'MarkMurphy/logstasher', ref: 'be3e871385bde7b1897ec2a1831f868a843d8000' 

不过,我们也使用一些私人gem。

要在容器上安装Git吗? 这将如何与Github进行身份validation?

要在容器上安装Git吗?

在这种情况下,是的:您可以在“ 使用Docker维护Rubygem ”中看到一个示例。 它的Dockerfile包括:

 # ~~~~ OS Maintenance ~~~~ RUN apt-get update && apt-get install -y git 

这将如何与Github进行身份validation?

它不必authenticationGitHub为了读取 ,即克隆。
它需要推回一个gem(发布它), 那么你将需要例如你的SSH密钥(通过卷安装)。
但这不是必要的。