Docker에서 Ruby on Rails 개발 환경 구축
입문 
이것은 MacOS 사용자를 위한 설명입니다.
Docker 버전은 19.03.8입니다.
Docker 설치 
아래의 공식 사이트를 방문하세요.
https://hub.docker.com/editions/community/docker-ce-desktop-mac 
 
 
다운로드하려면 가져오기 를 클릭합니다.
다운로드가 완료되면 두 번 클릭하여 컴퓨터에 설치되어 있는지 확인하십시오.
 
 
맨 왼쪽에 고래의 표식이 나타나면 아래의 일을 시도해 보세요.
설치 성공 여부 확인 
다음 명령을 실행하여 Docker 버전을 표시한 후 docker를 설치하십시오.$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false
Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
Docker를 사용하여 Ruby on Rails 환경 구축 
Docker 설치가 완료되었기 때문에 이제 Docker를 사용하여 Ruby on Rails 환경을 구축합니다.
각 파일 준비
 
Docker에서 Ruby on Rails 환경을 구축할 프로젝트 디렉토리를 만들고 이동합니다.이번에는 docker_sample 입니다.$ mkdir docker_sample
$ cd docker_sample
그런 다음 이동하여 생성합니다Dockerfile.$ touch Dockerfile
$ ls
Dockerfile
다음은 Dockerfile에서 설명할 수 있도록 vi 명령을 사용하여 편집을 엽니다.$ vi Dockerfile
Dockerfile에 다음을 기술합니다.FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
다음은 Gemfile 편집입니다.마찬가지로 vi 명령으로 편집을 엽니다.$ vi Gemfile
Gemfile에 다음 내용을 기술합니다.source 'https://rubygems.org'
gem 'rails', '~>5'
그런 다음 생성Gemfile.lock합니다.이때 Gemfile.lock 는 비어 있습니다.이때 다음 세 개의 파일이 있으면 정상이다.$ touch Gemfile.lock
$ ls
Dockerfile  Gemfile     Gemfile.lock
다음은 생성entrypoint.sh입니다.$ vi entrypoint.sh
entrypoint.sh에 다음 내용을 기술합니다.
entrypoint.sh#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
다음은 생성docker-compose.yml입니다.vi docker-compose.yml
docker-compose.yml에 다음 내용을 기술합니다.
docker-compose.ymlversion: '3'
services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: 'postgres'
  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db
Rails new 진행 
모든 서류가 준비되었다Rails new.$ docker-compose run web rails new . --force --no-deps --database=postgresql --skip-bundle
이따가 다운로드가 끝날 거예요.
bundle install 
다운로드 완료 후 Gemfile 업데이트, 구축 실행.$ docker-compose build
운행 궤도 데이터베이스 설정 
초기 설정은 SQLite이므로 다음과 같이 코드를 교체합니다.
config/database.ymldefault: &default
  adapter: postgresql
  encoding: unicode
  host: db
  username: postgres
  password: postgres
  pool: 5
development:
  <<: *default
  database: myapp_development
test:
  <<: *default
  database: myapp_test
시작 컨테이너 
그리고 용기를 시작합니다.$ docker-compose up
데이터베이스 만들기 $ docker-compose run web rake db:create
그리고 db:create 완성.http://localhost:3000/.
 
 
지금까지 Docker에서 Ruby on Rails 개발 환경을 구축한 내용입니다 ^_^
개발 시 유용한 정보 
Docker가 Rails의 개발 환경을 구축할 수 있다면 곧 개발로 옮겨갈 것입니다. 하지만 그때 아래 링크로 제가 실제로 사용한 것과 가져온 것을 요약한 기사를 소개하겠습니다. 어쨌든 보십시오!
간단한 Docker 시작 및 중지 방법 
Docker 개발 환경에서 컨테이너에 들어가서 일반적인 명령으로 실행하는 방법 
Docker에서 Rails 개발 환경을 구축한 후 Pry를 가져오는 방법
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Docker에서 Ruby on Rails 개발 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/chisaki0606/items/a4b42af5c4735c94057a
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
아래의 공식 사이트를 방문하세요.
https://hub.docker.com/editions/community/docker-ce-desktop-mac
 
 다운로드하려면 가져오기 를 클릭합니다.
다운로드가 완료되면 두 번 클릭하여 컴퓨터에 설치되어 있는지 확인하십시오.
 
 맨 왼쪽에 고래의 표식이 나타나면 아래의 일을 시도해 보세요.
설치 성공 여부 확인 
다음 명령을 실행하여 Docker 버전을 표시한 후 docker를 설치하십시오.$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false
Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
Docker를 사용하여 Ruby on Rails 환경 구축 
Docker 설치가 완료되었기 때문에 이제 Docker를 사용하여 Ruby on Rails 환경을 구축합니다.
각 파일 준비
 
Docker에서 Ruby on Rails 환경을 구축할 프로젝트 디렉토리를 만들고 이동합니다.이번에는 docker_sample 입니다.$ mkdir docker_sample
$ cd docker_sample
그런 다음 이동하여 생성합니다Dockerfile.$ touch Dockerfile
$ ls
Dockerfile
다음은 Dockerfile에서 설명할 수 있도록 vi 명령을 사용하여 편집을 엽니다.$ vi Dockerfile
Dockerfile에 다음을 기술합니다.FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
다음은 Gemfile 편집입니다.마찬가지로 vi 명령으로 편집을 엽니다.$ vi Gemfile
Gemfile에 다음 내용을 기술합니다.source 'https://rubygems.org'
gem 'rails', '~>5'
그런 다음 생성Gemfile.lock합니다.이때 Gemfile.lock 는 비어 있습니다.이때 다음 세 개의 파일이 있으면 정상이다.$ touch Gemfile.lock
$ ls
Dockerfile  Gemfile     Gemfile.lock
다음은 생성entrypoint.sh입니다.$ vi entrypoint.sh
entrypoint.sh에 다음 내용을 기술합니다.
entrypoint.sh#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
다음은 생성docker-compose.yml입니다.vi docker-compose.yml
docker-compose.yml에 다음 내용을 기술합니다.
docker-compose.ymlversion: '3'
services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: 'postgres'
  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db
Rails new 진행 
모든 서류가 준비되었다Rails new.$ docker-compose run web rails new . --force --no-deps --database=postgresql --skip-bundle
이따가 다운로드가 끝날 거예요.
bundle install 
다운로드 완료 후 Gemfile 업데이트, 구축 실행.$ docker-compose build
운행 궤도 데이터베이스 설정 
초기 설정은 SQLite이므로 다음과 같이 코드를 교체합니다.
config/database.ymldefault: &default
  adapter: postgresql
  encoding: unicode
  host: db
  username: postgres
  password: postgres
  pool: 5
development:
  <<: *default
  database: myapp_development
test:
  <<: *default
  database: myapp_test
시작 컨테이너 
그리고 용기를 시작합니다.$ docker-compose up
데이터베이스 만들기 $ docker-compose run web rake db:create
그리고 db:create 완성.http://localhost:3000/.
 
 
지금까지 Docker에서 Ruby on Rails 개발 환경을 구축한 내용입니다 ^_^
개발 시 유용한 정보 
Docker가 Rails의 개발 환경을 구축할 수 있다면 곧 개발로 옮겨갈 것입니다. 하지만 그때 아래 링크로 제가 실제로 사용한 것과 가져온 것을 요약한 기사를 소개하겠습니다. 어쨌든 보십시오!
간단한 Docker 시작 및 중지 방법 
Docker 개발 환경에서 컨테이너에 들어가서 일반적인 명령으로 실행하는 방법 
Docker에서 Rails 개발 환경을 구축한 후 Pry를 가져오는 방법
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Docker에서 Ruby on Rails 개발 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/chisaki0606/items/a4b42af5c4735c94057a
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false
Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
Docker 설치가 완료되었기 때문에 이제 Docker를 사용하여 Ruby on Rails 환경을 구축합니다.
각 파일 준비
Docker에서 Ruby on Rails 환경을 구축할 프로젝트 디렉토리를 만들고 이동합니다.이번에는
docker_sample 입니다.$ mkdir docker_sample
$ cd docker_sample
Dockerfile.$ touch Dockerfile
$ ls
Dockerfile
$ vi Dockerfile
FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
Gemfile 편집입니다.마찬가지로 vi 명령으로 편집을 엽니다.$ vi Gemfile
Gemfile에 다음 내용을 기술합니다.source 'https://rubygems.org'
gem 'rails', '~>5'
Gemfile.lock합니다.이때 Gemfile.lock 는 비어 있습니다.이때 다음 세 개의 파일이 있으면 정상이다.$ touch Gemfile.lock
$ ls
Dockerfile  Gemfile     Gemfile.lock
entrypoint.sh입니다.$ vi entrypoint.sh
entrypoint.sh에 다음 내용을 기술합니다.entrypoint.sh
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
docker-compose.yml입니다.vi docker-compose.yml
docker-compose.yml에 다음 내용을 기술합니다.docker-compose.yml
version: '3'
services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: 'postgres'
  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db
Rails new 진행 
모든 서류가 준비되었다Rails new.$ docker-compose run web rails new . --force --no-deps --database=postgresql --skip-bundle
이따가 다운로드가 끝날 거예요.
bundle install 
다운로드 완료 후 Gemfile 업데이트, 구축 실행.$ docker-compose build
운행 궤도 데이터베이스 설정 
초기 설정은 SQLite이므로 다음과 같이 코드를 교체합니다.
config/database.ymldefault: &default
  adapter: postgresql
  encoding: unicode
  host: db
  username: postgres
  password: postgres
  pool: 5
development:
  <<: *default
  database: myapp_development
test:
  <<: *default
  database: myapp_test
시작 컨테이너 
그리고 용기를 시작합니다.$ docker-compose up
데이터베이스 만들기 $ docker-compose run web rake db:create
그리고 db:create 완성.http://localhost:3000/.
 
 
지금까지 Docker에서 Ruby on Rails 개발 환경을 구축한 내용입니다 ^_^
개발 시 유용한 정보 
Docker가 Rails의 개발 환경을 구축할 수 있다면 곧 개발로 옮겨갈 것입니다. 하지만 그때 아래 링크로 제가 실제로 사용한 것과 가져온 것을 요약한 기사를 소개하겠습니다. 어쨌든 보십시오!
간단한 Docker 시작 및 중지 방법 
Docker 개발 환경에서 컨테이너에 들어가서 일반적인 명령으로 실행하는 방법 
Docker에서 Rails 개발 환경을 구축한 후 Pry를 가져오는 방법
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Docker에서 Ruby on Rails 개발 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/chisaki0606/items/a4b42af5c4735c94057a
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
$ docker-compose run web rails new . --force --no-deps --database=postgresql --skip-bundle
다운로드 완료 후
Gemfile 업데이트, 구축 실행.$ docker-compose build
운행 궤도 데이터베이스 설정 
초기 설정은 SQLite이므로 다음과 같이 코드를 교체합니다.
config/database.ymldefault: &default
  adapter: postgresql
  encoding: unicode
  host: db
  username: postgres
  password: postgres
  pool: 5
development:
  <<: *default
  database: myapp_development
test:
  <<: *default
  database: myapp_test
시작 컨테이너 
그리고 용기를 시작합니다.$ docker-compose up
데이터베이스 만들기 $ docker-compose run web rake db:create
그리고 db:create 완성.http://localhost:3000/.
 
 
지금까지 Docker에서 Ruby on Rails 개발 환경을 구축한 내용입니다 ^_^
개발 시 유용한 정보 
Docker가 Rails의 개발 환경을 구축할 수 있다면 곧 개발로 옮겨갈 것입니다. 하지만 그때 아래 링크로 제가 실제로 사용한 것과 가져온 것을 요약한 기사를 소개하겠습니다. 어쨌든 보십시오!
간단한 Docker 시작 및 중지 방법 
Docker 개발 환경에서 컨테이너에 들어가서 일반적인 명령으로 실행하는 방법 
Docker에서 Rails 개발 환경을 구축한 후 Pry를 가져오는 방법
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Docker에서 Ruby on Rails 개발 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/chisaki0606/items/a4b42af5c4735c94057a
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
default: &default
  adapter: postgresql
  encoding: unicode
  host: db
  username: postgres
  password: postgres
  pool: 5
development:
  <<: *default
  database: myapp_development
test:
  <<: *default
  database: myapp_test
그리고 용기를 시작합니다.
$ docker-compose up
데이터베이스 만들기 $ docker-compose run web rake db:create
그리고 db:create 완성.http://localhost:3000/.
 
 
지금까지 Docker에서 Ruby on Rails 개발 환경을 구축한 내용입니다 ^_^
개발 시 유용한 정보 
Docker가 Rails의 개발 환경을 구축할 수 있다면 곧 개발로 옮겨갈 것입니다. 하지만 그때 아래 링크로 제가 실제로 사용한 것과 가져온 것을 요약한 기사를 소개하겠습니다. 어쨌든 보십시오!
간단한 Docker 시작 및 중지 방법 
Docker 개발 환경에서 컨테이너에 들어가서 일반적인 명령으로 실행하는 방법 
Docker에서 Rails 개발 환경을 구축한 후 Pry를 가져오는 방법
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Docker에서 Ruby on Rails 개발 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/chisaki0606/items/a4b42af5c4735c94057a
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
$ docker-compose run web rake db:create
Docker가 Rails의 개발 환경을 구축할 수 있다면 곧 개발로 옮겨갈 것입니다. 하지만 그때 아래 링크로 제가 실제로 사용한 것과 가져온 것을 요약한 기사를 소개하겠습니다. 어쨌든 보십시오!
간단한 Docker 시작 및 중지 방법
Docker 개발 환경에서 컨테이너에 들어가서 일반적인 명령으로 실행하는 방법
Docker에서 Rails 개발 환경을 구축한 후 Pry를 가져오는 방법
Reference
이 문제에 관하여(Docker에서 Ruby on Rails 개발 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/chisaki0606/items/a4b42af5c4735c94057a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)