【发布时间】:2022-11-23 02:34:51
【问题描述】:
我正在尝试将 Rails 应用程序配置为用户 docker-compose 以进行本地开发。尝试在浏览器中访问它时我没有得到响应,我收到DNS_PROBE_FINISHED_NXDOMAIN。
docker-compose.yml
version: '3.8'
services:
web:
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- "3000:3000"
volumes:
- .:/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
- web_logs:/app/log
env_file: .env
environment:
- RAILS_ENV=development
depends_on:
- database
- redis
database:
image: postgres:14-bullseye
restart: always
ports:
- 5432:5432
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: integral_development
redis:
image: redis:6.2
volumes:
postgres_data:
gem_cache:
node_modules:
web_logs:
文件
FROM ruby:3.1.2-slim-buster
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
nodejs \
postgresql-client \
yarn
# Bundle install
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle check || bundle install
# Yarn install
# COPY package.json yarn.lock ./
# RUN yarn install
# Copy the main application.
COPY . ./
ENTRYPOINT ["./entrypoints/docker-entrypoint.sh"]
docker-entrypoint.sh
#!/bin/sh
set -e
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
bundle exec foreman start -f Procfile
简介
web: bundle exec puma -C config/puma.rb -p 3000
worker: bundle exec rake jobs:work
【问题讨论】:
-
尝试连接到
localhost:3000和127.0.0.1:3000
标签: ruby-on-rails docker macos docker-compose