- myapp/docker-compose.yml
- myapp/Dockerfile
- myapp/Gemfile
- myapp/Gemfile.lock
Last active
February 5, 2025 23:05
-
-
Save kuc-arc-f/99a52d06af503a41c5c91e320e3485ca to your computer and use it in GitHub Desktop.
docker-rails-2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.8' | |
| services: | |
| db: | |
| image: postgres:13 | |
| volumes: | |
| - postgres_data:/var/lib/postgresql/data | |
| environment: | |
| POSTGRES_USER: railsuser | |
| POSTGRES_PASSWORD: password | |
| web: | |
| build: . | |
| command: bash -c "rm -f tmp/pids/server.pid && rails server -b 0.0.0.0" | |
| volumes: | |
| - .:/myapp | |
| ports: | |
| - "3000:3000" | |
| depends_on: | |
| - db | |
| environment: | |
| DATABASE_HOST: db | |
| DATABASE_USER: railsuser | |
| DATABASE_PASSWORD: password | |
| volumes: | |
| postgres_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Rubyの公式イメージをベースにする | |
| FROM ruby:3.3.2 | |
| # 必要なパッケージをインストール | |
| RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs | |
| # 作業ディレクトリを設定 | |
| WORKDIR /myapp | |
| # GemfileとGemfile.lockをコピー | |
| COPY Gemfile /myapp/Gemfile | |
| COPY Gemfile.lock /myapp/Gemfile.lock | |
| # BundlerでGemをインストール | |
| RUN bundle install | |
| # アプリケーションのコードをコピー | |
| COPY . /myapp | |
| # ポートを公開 | |
| EXPOSE 3000 | |
| # Railsサーバーを起動 | |
| CMD ["rails", "server", "-b", "0.0.0.0"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| gem 'rails', '~> 8.0.0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment