# 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"] EXPOSE3000
# Configure the main process to run when running the image CMD ["rails", "server", "-b", "0.0.0.0"]
빌드를 시작해도 아직 레일스 세팅이 안되어있다. docker 컨테이너를 이용하여 레일스 설치를 진행한다.
1
docker-compose run --no-deps web rails new . --api --force --database=postgresql
실행 시 뭔가 쭉쭉 설치되고 로컬 디렉토리와 컨테이너 볼륨을 지정해줬기 때문에 작업 디렉토리에 레일스 폴더, 파일들이 생성된다.
3. database.yml 작성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# ./config/database.yml
default:&default adapter:postgresql encoding:utf8 # For details on connection pooling, see Rails configuration guide # https://guides.rubyonrails.org/configuring.html#database-pooling pool:5 host:database# docker 환경 데이터베이스와 연결을 하기위해서는 컨테이너 이름으로 지정해주어야 한다. username:juren password:juren