Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker 環境への Next-L Enju Leaf 1.4 系のインストール #1840

Open
miyatatk opened this issue Nov 6, 2023 · 1 comment
Open

Docker 環境への Next-L Enju Leaf 1.4 系のインストール #1840

miyatatk opened this issue Nov 6, 2023 · 1 comment

Comments

@miyatatk
Copy link

miyatatk commented Nov 6, 2023

@nabeta ご無沙汰しております。おかげさまで Next-L Enju Leaf 1.3.5 を自宅内サーバーで安定運用し、1,500冊以上の蔵書を管理しています。

さて、Next-L Enju Leaf 1.4 系の開発が始まっていることは承知していましたが、バージョンアップで既存のデータを壊す可能性があるため、同じホストでの移行を断念し、このたび2台目の自宅内サーバーを立ち上げました。新サーバーで Docker、NGINX、PostgreSQL、Redis等のプラットフォームの準備が完了し、他のアプリケーションはこれらの上で問題なく稼働しています。

現在、まずはまっさらなアプリケーションを試すべく、Install に従って最新版の Next-L Enju Leaf 1.4.3 を Docker 環境にインストールしようとしていますが、いくつかの環境の違いのため丸ごとインストールするわけにいかず、苦労しています。

【違い】

  • NGINX、PostgreSQL、Redis はコンテナでなく、ホストのものを使いたい
  • ホスト内ではなく、自宅内ネットワーク全体で使いたい

このため、docker-compose.yml の一部を以下のように変更しています。

volumes:
  # postgres:
  solr:
  # redis:
  minio:

x-app: &app
  depends_on:
    # - postgres
    - solr
    # - redis
    # - minio

services:
  web:
    <<: *app
    command: bash -c "rm -f tmp/pids/server.pid && rails s -b 0.0.0.0"
    environment:
      - WEBPACKER_DEV_SERVER_HOST=webpacker
    expose:
      - 3000

  workers:
    <<: *app
    environment:
      - QUEUE=*
    command: bundle exec rake resque:work

  webpacker:
    <<: *app
    environment:
      - NODE_ENV=development
      - WEBPACKER_DEV_SERVER_HOST=127.0.0.1
    profiles:
      - develop
    command: ./bin/webpack-dev-server
    ports:
      - 127.0.0.1:3035:3035

  solr:
    image: solr:8
    ports:
      - 127.0.0.1:8983:8983
    env_file:
      - .env
    networks:
      internal:
    volumes:
      - solr:/var/solr/data
      - ./solr:/mnt/solr
    restart: always
    command: bash -c "precreate-core enju_leaf_${RAILS_ENV} /mnt/solr/configsets/sunspot/conf/; exec solr -f"
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8983/solr/enju_leaf_${RAILS_ENV}/admin/ping"]
      interval: 30s
      timeout: 5s
      retries: 3

# postgres:
  # ...すべて

# redis:
  # ...すべて

# nginx:
  # ...すべて

また、Dockerコンテナ側から見たホスト(サーバー)のIPアドレスは 172.17.0.1 であることから、.env ファイルを以下のように変更しています。

POSTGRES_HOST=172.17.0.1

REDIS_URL=redis://172.17.0.1/enju-leaf-${RAILS_ENV}

ENJU_LEAF_BIND_ADDRESS=172.17.0.1

NGINXの設定 /etc/nginx/conf.d/lib2.example.com は以下のとおりです。

server {
	listen      443 ssl;
	server_name lib2.example.com;
	...
	location / {
		proxy_pass	http://127.0.0.1:3000;

しかし、Docker をビルドしてブラウザで https://lib2.example.com を叩いても 502 Bad Gateway と表示され、正常に動きません。

アドバイスを頂ければ幸いです。

@nabeta
Copy link
Member

nabeta commented Nov 17, 2023

@miyatatk 遅くなりましてすみません。Docker Desktopをお使いの場合、ホスト側を指すのにhost.docker.internalという特殊なホスト名が使えますので、試していただけますか。
https://docs.docker.jp/desktop/networking.html#desktop-networking-i-want-to-connect-from-a-container-to-a-service-on-the-host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants