환경 구조
4391 단어 Docker
mkdir container_01
docker pull ruby:2.4.1-alpine
touch Dockerfile docker-compose.yml Gemfile Gemfile.lock
docker-compose up -d --build
에서 사용Dockerfile
##### Base Image #####
FROM ruby:2.4.1-alpine
ENV LANG en_US.UTF-8
##### イメージ上でコマンドを実行 #####
RUN apk update && \
apk upgrade && \
apk add --update\
bash \
build-base \
curl-dev \
git \
libxml2-dev \
libxslt-dev \
linux-headers \
mysql-dev \
nodejs \
openssh \
ruby-dev \
ruby-json \
tzdata \
yaml \
yaml-dev \
zlib-dev
RUN gem install bundler
##### WORKDIRを指定してコマンド実行 #####
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
ENV APP_HOME /myapp
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
COPY . $APP_HOME
Gemfilesource 'https://rubygems.org'
gem 'rails'
docker-compose.ymlversion: '2'
services:
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
container_name: web
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root_password
volumes_from:
- datastore
container_name: db
datastore:
image: busybox
volumes:
- ./datastore_container:/var/lib/mysql
container_name: datastore
docker-compose run web rails new . --force --database=mysql --skip-bundle
JavaScript runtime은ther byracer의gem 설치를 유효하게 합니다.therubyracer
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.0.2'
gem 'mysql2', '>= 0.3.18', '< 0.5'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'therubyracer', '0.11.3'
gem 'libv8', '3.11.8.13'
group :development, :test do
gem 'byebug', platform: :mri
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
config/database.ymldefault: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: root_password
host: db
development:
<<: *default
database: container_development
test:
<<: *default
database: container_test
production:
<<: *default
database: myapp_production
username: myapp
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
docker-compose up -d --build
docker-compose run web rails db:create
docker-compose run web rails generate scaffold user name:string
docker-compose run web rails db:migrate
gem install libv8 -v '3.11.8.17' -- --with-system-v8
Reference
이 문제에 관하여(환경 구조), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/sunoko/items/bc62e390a054da2b31cf텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)