簡體   English   中英

在Dockerfile中從Github捆綁

[英]Bundling from Github in a Dockerfile

我正在嘗試將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'

但是,我們也使用一些私人寶石。

將Git安裝在容器上是否可行? 如何使用Github進行身份驗證?

將Git安裝在容器上是否可行?

在這種情況下,是的:您可以在“ 使用Docker維護Ruby gem ”中看到一個示例。 Dockerfile確實包含:

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

如何使用Github進行身份驗證?

它不必通過GitHub進行身份驗證即可讀取 (即克隆)。
您需要推回一個gem(發布它), 然后 ,例如,需要您的ssh密鑰(通過卷安裝)。
但是這里不需要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM