1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AWS契約してLightSailでLibreChatを動かす

Posted at

image.png

1.はじめに

2023年5月に生成AIの自己研鑽を始めてから2年が経過しました。ChatGPTが2023年11月頃に爆発的な人気を集め、それから半年後に私も生成AI関連の学習を開始しました。
初めは知識が乏しく、他の方々の技術ブログを参考にしながら実践を重ね、生成AIについての理解を深めていきました。
その過程で、LLMとは別にアプリケーションのホスティング環境が必要となり、初めてGoogle Cloudを個人契約し、GCE(Google Compute Engine)の無料枠でホスティングを始めました。
当初は請求額を気にしながら無料枠での運用にこだわっていた私ですが、今ではGoogle Cloud、Azure、OpenRouter、Notion AIの月額利用料が5,000円から10,000円に達しています。
節約の必要性を感じつつも、2年前から会社の仕事でAWSとAzureに関わるようになったこともあり、積極的に自己投資として学習を続けています。
最近はコンテナ技術に興味を持ち、クラウドネイティブ開発におけるコンテナ活用の効率性に感銘を受けています。
Azure App ServiceやAzure Container Registryを仕事で使用し、Google Cloud Runを自宅で試してみましたが、AzureとGoogleのマルチコンテナ環境の使いづらさを実感しました。
現在のOSSの多くはDocker Composeで記述されており、クラウドネイティブ開発における効率化の要となっています。
ただし、Docker Composeを活用するにはIaaS環境が必須という制約があり、それが少し残念です。
そこでAWSのLightSailに注目し、実際に試してみたいと考えています。今回は、AWSを契約してLightSailでLibreChatをマルチコンテナアプリケーションの運用を個人で検証してみようと思います。

2.AWSとは

AWSは、Amazonが自社のEコマースプラットフォーム運営のために構築した巨大なITインフラを外部向けにサービス化したクラウドコンピューティングプラットフォームです。2006年にサービスを開始し、現在では200以上のサービスを提供する世界最大のクラウドプロバイダーとなっています。

主なサービスにはEC2 、S3 、RDS 、Kubernetes、Amazon ECS、Docker Swarm、 LightSailなどがあります。

AWSの特徴は、必要な時に必要な分だけリソースを利用できる柔軟性と、従量課金制による cost-effective な料金体系にあります。また、世界中の多くの地域にデータセンターを展開し、高い可用性と信頼性を実現しています。
AWSの開発には、当時のAmazonのCTOであったアラン・コーエン(Allan Cohen)やCEOのジェフ・ベゾス(Jeff Bezos)が深く関わっていました。特に、AWSの初期ビジョンを形作ったのは、アンディ・ジャシー(Andy Jassy)でした。ジャシーは後にAWSの初代CEOとなり、2021年にはAmazon.com, Inc.のCEOに就任しています。
彼らは、Amazonが構築した強力なITインフラを外部に提供するというビジョンを持ち、それが今日のAWSの基盤となりました。

aws-development-history.png

AWSは2006年に正式にサービスを開始しました。最初に公開されたサービスはAmazon Simple Queue Service(SQS)でしたが、広く知られるようになったのは2006年3月に公開されたAmazon Simple Storage Service(S3)からです。

aws-timeline-fishbone.png

3.クラウドネイティブ開発とは

クラウドネイティブ開発とは、クラウド環境の特性を最大限に活かしたアプリケーション開発のアプローチです。従来のオンプレミス環境向けに設計されたアプリケーションをクラウドに「持ち込む」のではなく、クラウドの特性を前提として最初から設計・開発する方法論です。

3.1. クラウドネイティブの特徴

No 項目 説明
1 マイクロサービスアーキテクチャ アプリケーションを小さな独立したサービスに分割し、それぞれが特定の機能を担当
2 コンテナ化 アプリケーションとその依存関係をコンテナにパッケージ化し、環境に依存しない実行を可能に
3 DevOpsの実践 開発と運用の連携を強化し、継続的インテグレーション/継続的デリバリー(CI/CD)を実現
4 自動スケーリング トラフィックに応じて自動的にリソースを増減させる機能を活用
5 インフラのコード化(IaC) インフラストラクチャをコードとして管理し、再現性と一貫性を確保

cloud-native-architecture.png

3.2. クラウドネイティブ開発のメリット

No. 項目 説明
1 迅速なデプロイ 新機能や修正を素早くリリース可能
2 高い柔軟性 需要の変化に応じて迅速にスケールアップ/ダウン
3 コスト効率 使用したリソースに対してのみ課金される従量課金制
4 高い信頼性 分散システムによる耐障害性の向上
5 グローバル展開の容易さ 世界中のデータセンターを活用した地理的分散が容易

クラウドネイティブ開発は、Cloud Native Computing Foundation (CNCF) によって推進されており、Kubernetes、Prometheus、Envoyなどのオープンソースプロジェクトを中心に発展しています。

4.AWS LightSailとは

AWS LightSailは、AWSが提供する簡易なクラウドホスティングサービスで、仮想プライベートサーバー(VPS)の設定と管理を簡素化することを目的としています。従来のEC2と比較して、シンプルな料金体系と使いやすいインターフェースが特徴で、特にWordPressやNode.jsなどの一般的なアプリケーションの展開に適しています。また、Docker対応により、マルチコンテナアプリケーションの展開も容易に行えるようになっています。

aws-lightsail-diagram.png

5.AWSを個人で契約

AWS(Amazon Web Service)を個人で契約するにはAWSアカウントを作成する必要があります。AWSアカウントの作成は無料ですが、作成する際にメールアドレスとクレジットカードが必要です。
AWSアカウントの作成手順はAWS公式の「(AWS アカウント作成の流れ【AWS 公式】」が分かり易いです。
悩んだのはアカウント名のみで、英語での住所入力はおやっと思ったくらいです。
AWSアカウント作成のステップは①AWSアカウントの作成、②連絡先情報の入力、③請求情報の入力、④SMSまたは音声電話による本人認証、⑤AWSサポートプランの選択の5ステップです。

aws-account-creation-process.png

※①の半角英字のアカウント名は悩みましたが、私が普段使っているハンドル名「potofo」としました。
※③の請求情報は英語でしか入力できないようです。
※私は⑤のAWSサポートプランは聞かれませんでした。気になったので「サポート」サービスを検索して「サポートコンソール」を起動したら、無料のBasic(ベーシック)でした。

6.LightSailの概要

契約後に分かったことですが、LightSailにはIaaSのVPSインスタンスとコンテナーサービスという2つのサービスがあります。
VPS(Virtual Private Server)インスタンスでは、通常のIaaSの1台のサーバーを時分割で利用する方式が採用されています。ただし、IaaSとしてはGoogle Cloudのe2-microの方が無料枠があるため、より経済的に感じます。
私の誤解でしたが、LightSailをマルチコンテナーのPaaSとして利用できると思い込んでいたため、期待外れでした。

LightSailのインスタンスは、基本的にEC2のVPSを安価に提供するものです。コンテナーサービスでは「カスタムコンテナ」で複数のコンテナを起動できますが、独自マネージドサービスでの管理に限られます。構築は可能ですが、Azure App ServiceやGoogle Cloud Runのサイドカーコンテナと同様の制約があります。

この点でも、Google Cloud Runの方が優位性があると感じます。

結論として、残念なことにLightSailのコンテナサービスもコンテナインスタンスではマルチコンテナに対応していませんでした。

会社の業務での運用ではIaaSの運用コスト課題になるため、IaaSの運用は選択しませんが、
気を取り直して、せっかくAWSの無料枠もありますし、LightSailのインスタンスでLibreChatを起動してみたいと思います。

Google Cloud GCE e2-microとの比較

項目 Google Cloud GCE e2-micro AWS Lightsail 最小構成
CPU 2 vCPU (共有コア、物理コアの一部を共有) 1 vCPU
メモリ 1 GB 512 MB
ストレージ 30 GB (標準永続ディスク、無料枠上限) 20 GB SSD
データ転送 1 GB/月 (無料枠) 制限あり (プランに含まれる)
月額料金 6.11~6.11~6.11~9.78 (リージョンによる)無料枠で永続的に無料 (1アカウント1インスタンス) 3.50USD/月初月無料 (新規利用者)
但しIPv4のデュアルスタックを選択すると最低料金は$5.00/月となる

7.LibreChatインスタンス作成

まず最初は素のUbuntu 22.04 LTSのOSイメージでIaaSのVPSインスタンスを作成してみます。
作成したLightSailインスタンス

7.1. LightSailインスタンスの作成

[LightSail]から「インスタンスの作成」ボタンを押し以下のインスタンスを作成しました。

作成したLightSailインスタンス

No 項目 設定項目 備考
1 インスタンスの場所 日本(ap-northeast-1)
2 アベイラビリティゾーンを選択 ゾーンA
3 インスタンスイメージを選択
4  ┗プラットフォームの選択 Linux/Unix
5  ┗設計図の選択 オペレーティングシステム(OS)のみ
 Ubuntu 22.04 LTS
6  ┗オプション
7   ┗起動スクリプト どうやらEC2同様に初回にインスタンスを作成した後、停止、起動で制御し、終了するとインスタンスが破棄される仕組みの模様インスタンス初回起動時にOSのみのベースイメージにgitでdocker-compose.yamlをダウンロードしたり、OSの起動スクリプトを生成するスクリプトをここに書けば、ベースイメージに様々なアプリケーションをインストールできそうです。 インスタンスを作成すると月額料金が課金されて終了すると課金が止まる仕掛けのようです。
8   ┗SSHキー デフォルトSSHキー インターネットを介してのSSH接続はセキュリティリスクがあるので、SSHキーペアを作成して、公開鍵でアクセスするようです
9   ┗自動スナップショット チェックしない
有効にすると毎日定刻にOSイメージのスナップショットが取得されるようです
こちらもEC2のスナップショットと同じですね。
スナップショットは別料金です。
10  ┗インスタンスプランを選択
11   ┗ネットワークタイプを選択 デュアルスタック IPv6にしてもインターネットからはアクセスできますが、何らかの機能が制限されるようなのでデュアルスタックを選びました
12   ┗サイズを選択 12.00USD LibreChatは5.00USD、7.00USDでは動きませんでした12.00USDの2GBメモリを選択する必要があります
13  ┗インスタンスを特定
14   ┗インスタンス名 ptf-chat
15   ┗タグ付けオプション

「インスタンスの作成」ボタンを押すと直ぐにインスタンスを作り始め「ステータス」が「開始中」になります

LightSail-Instance.png

1~2分程度で「ステータス」が「実行中」に変わればマネジメントコンソールのLightSailコンソールがかSSH接続できます

7.2. 静的IPのアタッチ

LightSailではデフォルトでパブリックIPが動的に割り当たりますので、静的IPアタッチを行います。
作成したインスタンスの「ネットワーキング」タブから「静的IPをアタッチする」ボタンで設定します。
アタッチする静的IPの名前はデフォルトの「StaticIp-1」で良いと思います。

LightSail-EIP.png

7.3. dockerの導入

スーパーユーザで既存のdockerを削除して、dockerのgpgを取得後apt updateしたのちdocker をインストールします。

作業はputty端末で実施しました。

ここをクリックしてコマンド実行結果を表示
ubuntu@ip-172-26-9-78:~$ sudo su -
root@ip-172-26-9-78:~# apt remove docker docker-engine docker.io containerd runc
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker.io' is not installed, so not removed
E: Unable to locate package docker
E: Unable to locate package docker-engine
root@ip-172-26-9-78:~# apt install -y ca-certificates curl gnupg lsb-release
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu4).
lsb-release set to manually installed.
ca-certificates is already the newest version (20240203~22.04.1).
ca-certificates set to manually installed.
curl is already the newest version (7.81.0-1ubuntu1.20).
curl set to manually installed.
gnupg is already the newest version (2.2.27-3ubuntu2.1).
gnupg set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@ip-172-26-9-78:~# mkdir -p /etc/apt/keyrings
root@ip-172-26-9-78:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
root@ip-172-26-9-78:~# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
root@ip-172-26-9-78:~# apt update
Hit:1 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:3 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease [127 kB]
... 省略 ...
Get:40 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [39.6 kB]
Get:41 http://security.ubuntu.com/ubuntu jammy-security/multiverse Translation-en [8716 B]
Get:42 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [368 B]
Fetched 37.1 MB in 7s (5314 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
50 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@ip-172-26-9-78:~#
root@ip-172-26-9-78:~# apt install -y ca-certificates curl gnupg lsb-release
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu4).
lsb-release set to manually installed.
... 省略 ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.9) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@ip-172-26-9-78:~#
root@ip-172-26-9-78:~# docker --version
Docker version 28.1.1, build 4eba377
root@ip-172-26-9-78:~#

Debianの場合

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

7.4. LibreChatの導入

LibreChatはGitHubからクローンして.env設定ファイルとlibrechat.yaml、docker-compose.override.ymlを作成します。

私の.envファイルをlibrechat.yamlをサンプルとしてつけますので、APIプロバイダーが一致する場合はAPIキーを変更してご利用ください。

LibreChatでは.envファイルapiコンテナにbindされていますが、librechat.yamlはbindされておりません、そこでdocker-compose.override.ymlファイルを使ってbindしています。

LibreChatでは.envファイルapiコンテナにbindされていますが、librechat.yamlはbindされておりません、そこでdocker-compose.override.ymlファイルを使ってbindしています。

root@ip-172-26-9-78:~# git clone https://github.com/danny-avila/LibreChat.git
Cloning into 'LibreChat'...
remote: Enumerating objects: 45105, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 45105 (delta 5), reused 5 (delta 5), pack-reused 45095 (from 1)
Receiving objects: 100% (45105/45105), 79.69 MiB | 21.35 MiB/s, done.
Resolving deltas: 100% (32788/32788), done.
root@ip-172-26-9-78:~# cd LibreChat/
root@ip-172-26-9-78:~/LibreChat#
root@ip-172-26-9-78:~/LibreChat# vi.env
root@ip-172-26-9-78:~/LibreChat# vi librechat.yaml

私のLibreChatはOpenRouter、Azure OpenAI、OpenAIの3つのAPIプロバイダーを設定しています。
流用する場合は.envの以下のAPIキーを修正してください。

.envの変更箇所

OPENROUTER_KEY=sk-xxxxxxxxxxxxxxxxxxxx
AZURE_API_KEY=XXXXXXXXXXXXXXXXXXXX
OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX

.env

ここをクリックして.envファイルを表示
#=====================================================================#
#                       LibreChat Configuration                       #
#=====================================================================#
# Please refer to the reference documentation for assistance          #
# with configuring your LibreChat environment.                        #
#                                                                     #
# https://www.librechat.ai/docs/configuration/dotenv                  #
#=====================================================================#

#==================================================#
#               Server Configuration               #
#==================================================#

HOST=localhost
PORT=80

MONGO_URI=mongodb://127.0.0.1:27017/LibreChat

DOMAIN_CLIENT=http://localhost:3080
DOMAIN_SERVER=http://localhost:3080

NO_INDEX=true
# Use the address that is at most n number of hops away from the Express application. 
# req.socket.remoteAddress is the first hop, and the rest are looked for in the X-Forwarded-For header from right to left. 
# A value of 0 means that the first untrusted address would be req.socket.remoteAddress, i.e. there is no reverse proxy.
# Defaulted to 1.
TRUST_PROXY=1

#===============#
# JSON Logging  #
#===============#

# Use when process console logs in cloud deployment like GCP/AWS
CONSOLE_JSON=false

#===============#
# Debug Logging #
#===============#

DEBUG_LOGGING=true
DEBUG_CONSOLE=false

#=============#
# Permissions #
#=============#

# UID=1000
# GID=1000

#===============#
# Configuration #
#===============#
# Use an absolute path, a relative path, or a URL

# CONFIG_PATH="/alternative/path/to/librechat.yaml"
CONFIG_PATH="/app/librechat.yaml"

#===================================================#
#                     Endpoints                     #
#===================================================#

# ENDPOINTS=openAI,assistants,azureOpenAI,google,gptPlugins,anthropic
ENDPOINTS=openAI,azureOpenAI,OpenRouter

PROXY=

#===================================#
# Known Endpoints - librechat.yaml  #
#===================================#
# https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints

# ANYSCALE_API_KEY=
# APIPIE_API_KEY=
# COHERE_API_KEY=
# DEEPSEEK_API_KEY=
# DATABRICKS_API_KEY=
# FIREWORKS_API_KEY=
# GROQ_API_KEY=
# HUGGINGFACE_TOKEN=
# MISTRAL_API_KEY=
# OPENROUTER_KEY=
OPENROUTER_KEY=sk-xxxxxxxxxxxxxxxxxxxx
# PERPLEXITY_API_KEY=
# SHUTTLEAI_API_KEY=
# TOGETHERAI_API_KEY=
# UNIFY_API_KEY=
# XAI_API_KEY=

#============#
# Anthropic  #
#============#

ANTHROPIC_API_KEY=user_provided
# ANTHROPIC_MODELS=claude-3-7-sonnet-latest,claude-3-7-sonnet-20250219,claude-3-5-haiku-20241022,claude-3-5-sonnet-20241022,claude-3-5-sonnet-latest,claude-3-5-sonnet-20240620,claude-3-opus-20240229,claude-3-sonnet-20240229,claude-3-haiku-20240307,claude-2.1,claude-2,claude-1.2,claude-1,claude-1-100k,claude-instant-1,claude-instant-1-100k
# ANTHROPIC_REVERSE_PROXY=

#============#
# Azure      #
#============#

# Note: these variables are DEPRECATED
# Use the `librechat.yaml` configuration for `azureOpenAI` instead
# You may also continue to use them if you opt out of using the `librechat.yaml` configuration

# AZURE_OPENAI_DEFAULT_MODEL=gpt-3.5-turbo # Deprecated
# AZURE_OPENAI_MODELS=gpt-3.5-turbo,gpt-4 # Deprecated
# AZURE_USE_MODEL_AS_DEPLOYMENT_NAME=TRUE # Deprecated
# AZURE_API_KEY= # Deprecated
# AZURE_OPENAI_API_INSTANCE_NAME= # Deprecated
# AZURE_OPENAI_API_DEPLOYMENT_NAME= # Deprecated
# AZURE_OPENAI_API_VERSION= # Deprecated
# AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME= # Deprecated
# AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME= # Deprecated
# PLUGINS_USE_AZURE="true" # Deprecated

AZURE_OPENAI_DEFAULT_MODEL=gpt-4o-mini # Deprecated
AZURE_OPENAI_MODELS=gpt-4o-mini,gpt-4o # Deprecated
AZURE_USE_MODEL_AS_DEPLOYMENT_NAME=TRUE # Deprecated
AZURE_API_KEY=XXXXXXXXXXXXXXXXXXXX # Deprecated
AZURE_OPENAI_API_INSTANCE_NAME=ptf-eus # Deprecated
AZURE_OPENAI_API_DEPLOYMENT_NAME=gpt-4o-mini # Deprecated
AZURE_OPENAI_API_VERSION=2024-10-21 # Deprecated
# AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME= # Deprecated
# AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME= # Deprecated
# PLUGINS_USE_AZURE="true" # Deprecated

#=================#
#   AWS Bedrock   #
#=================#

# BEDROCK_AWS_DEFAULT_REGION=us-east-1 # A default region must be provided
# BEDROCK_AWS_ACCESS_KEY_ID=someAccessKey
# BEDROCK_AWS_SECRET_ACCESS_KEY=someSecretAccessKey
# BEDROCK_AWS_SESSION_TOKEN=someSessionToken

# Note: This example list is not meant to be exhaustive. If omitted, all known, supported model IDs will be included for you.
# BEDROCK_AWS_MODELS=anthropic.claude-3-5-sonnet-20240620-v1:0,meta.llama3-1-8b-instruct-v1:0

# See all Bedrock model IDs here: https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns

# Notes on specific models:
# The following models are not support due to not supporting streaming:
# ai21.j2-mid-v1

# The following models are not support due to not supporting conversation history:
# ai21.j2-ultra-v1, cohere.command-text-v14, cohere.command-light-text-v14

#============#
# Google     #
#============#

GOOGLE_KEY=user_provided

# GOOGLE_REVERSE_PROXY=
# Some reverse proxies do not support the X-goog-api-key header, uncomment to pass the API key in Authorization header instead.
# GOOGLE_AUTH_HEADER=true

# Gemini API (AI Studio)
# GOOGLE_MODELS=gemini-2.5-pro-exp-03-25,gemini-2.0-flash-exp,gemini-2.0-flash-thinking-exp-1219,gemini-exp-1121,gemini-exp-1114,gemini-1.5-flash-latest,gemini-1.0-pro,gemini-1.0-pro-001,gemini-1.0-pro-latest,gemini-1.0-pro-vision-latest,gemini-1.5-pro-latest,gemini-pro,gemini-pro-vision

# Vertex AI
# GOOGLE_MODELS=gemini-1.5-flash-preview-0514,gemini-1.5-pro-preview-0514,gemini-1.0-pro-vision-001,gemini-1.0-pro-002,gemini-1.0-pro-001,gemini-pro-vision,gemini-1.0-pro

# GOOGLE_TITLE_MODEL=gemini-pro

# GOOGLE_LOC=us-central1

# Google Safety Settings
# NOTE: These settings apply to both Vertex AI and Gemini API (AI Studio)
#
# For Vertex AI:
# To use the BLOCK_NONE setting, you need either:
# (a) Access through an allowlist via your Google account team, or
# (b) Switch to monthly invoiced billing: https://cloud.google.com/billing/docs/how-to/invoiced-billing
#
# For Gemini API (AI Studio):
# BLOCK_NONE is available by default, no special account requirements.
#
# Available options: BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, BLOCK_LOW_AND_ABOVE
#
# GOOGLE_SAFETY_SEXUALLY_EXPLICIT=BLOCK_ONLY_HIGH
# GOOGLE_SAFETY_HATE_SPEECH=BLOCK_ONLY_HIGH
# GOOGLE_SAFETY_HARASSMENT=BLOCK_ONLY_HIGH
# GOOGLE_SAFETY_DANGEROUS_CONTENT=BLOCK_ONLY_HIGH
# GOOGLE_SAFETY_CIVIC_INTEGRITY=BLOCK_ONLY_HIGH

#============#
# OpenAI     #
#============#

#OPENAI_API_KEY=user_provided
OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXX
# OPENAI_MODELS=o1,o1-mini,o1-preview,gpt-4o,gpt-4.5-preview,chatgpt-4o-latest,gpt-4o-mini,gpt-3.5-turbo-0125,gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k

DEBUG_OPENAI=false

# TITLE_CONVO=false
# OPENAI_TITLE_MODEL=gpt-4o-mini

# OPENAI_SUMMARIZE=true
# OPENAI_SUMMARY_MODEL=gpt-4o-mini

# OPENAI_FORCE_PROMPT=true

# OPENAI_REVERSE_PROXY=

# OPENAI_ORGANIZATION=

#====================#
#   Assistants API   #
#====================#

ASSISTANTS_API_KEY=user_provided
# ASSISTANTS_BASE_URL=
# ASSISTANTS_MODELS=gpt-4o,gpt-4o-mini,gpt-3.5-turbo-0125,gpt-3.5-turbo-16k-0613,gpt-3.5-turbo-16k,gpt-3.5-turbo,gpt-4,gpt-4-0314,gpt-4-32k-0314,gpt-4-0613,gpt-3.5-turbo-0613,gpt-3.5-turbo-1106,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview

#==========================#
#   Azure Assistants API   #
#==========================#

# Note: You should map your credentials with custom variables according to your Azure OpenAI Configuration
# The models for Azure Assistants are also determined by your Azure OpenAI configuration.

# More info, including how to enable use of Assistants with Azure here:
# https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints/azure#using-assistants-with-azure

#============#
# Plugins    #
#============#

# PLUGIN_MODELS=gpt-4o,gpt-4o-mini,gpt-4,gpt-4-turbo-preview,gpt-4-0125-preview,gpt-4-1106-preview,gpt-4-0613,gpt-3.5-turbo,gpt-3.5-turbo-0125,gpt-3.5-turbo-1106,gpt-3.5-turbo-0613

DEBUG_PLUGINS=true

CREDS_KEY=f34be427ebb29de8d88c107a71546019685ed8b241d8f2ed00c3df97ad2566f0
CREDS_IV=e2341419ec3dd3d19b13a1a87fafcbfb

# Azure AI Search
#-----------------
AZURE_AI_SEARCH_SERVICE_ENDPOINT=
AZURE_AI_SEARCH_INDEX_NAME=
AZURE_AI_SEARCH_API_KEY=

AZURE_AI_SEARCH_API_VERSION=
AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE=
AZURE_AI_SEARCH_SEARCH_OPTION_TOP=
AZURE_AI_SEARCH_SEARCH_OPTION_SELECT=

# DALL·E
#----------------
# DALLE_API_KEY=
# DALLE3_API_KEY=
# DALLE2_API_KEY=
# DALLE3_SYSTEM_PROMPT=
# DALLE2_SYSTEM_PROMPT=
# DALLE_REVERSE_PROXY=
# DALLE3_BASEURL=
# DALLE2_BASEURL=

# DALL·E (via Azure OpenAI)
# Note: requires some of the variables above to be set
#----------------
# DALLE3_AZURE_API_VERSION=
# DALLE2_AZURE_API_VERSION=

# Flux
#-----------------
FLUX_API_BASE_URL=https://api.us1.bfl.ai
# FLUX_API_BASE_URL = 'https://api.bfl.ml';

# Get your API key at https://api.us1.bfl.ai/auth/profile
# FLUX_API_KEY=

# Google
#-----------------
GOOGLE_SEARCH_API_KEY=
GOOGLE_CSE_ID=

# YOUTUBE
#-----------------
YOUTUBE_API_KEY=

# SerpAPI
#-----------------
SERPAPI_API_KEY=

# Stable Diffusion
#-----------------
SD_WEBUI_URL=http://host.docker.internal:7860

# Tavily
#-----------------
TAVILY_API_KEY=

# Traversaal
#-----------------
TRAVERSAAL_API_KEY=

# WolframAlpha
#-----------------
WOLFRAM_APP_ID=

# Zapier
#-----------------
ZAPIER_NLA_API_KEY=

#==================================================#
#                      Search                      #
#==================================================#

SEARCH=true
MEILI_NO_ANALYTICS=true
MEILI_HOST=http://0.0.0.0:7700
MEILI_MASTER_KEY=DrhYf7zENyR6AlUCKmnz0eYASOQdl6zxH7s7MKFSfFCt

# Optional: Disable indexing, useful in a multi-node setup
# where only one instance should perform an index sync.
# MEILI_NO_SYNC=true

#==================================================#
#          Speech to Text & Text to Speech         #
#==================================================#

STT_API_KEY=
TTS_API_KEY=

#==================================================#
#                        RAG                       #
#==================================================#
# More info: https://www.librechat.ai/docs/configuration/rag_api

# RAG_OPENAI_BASEURL=
# RAG_OPENAI_API_KEY=
# RAG_USE_FULL_CONTEXT=
# EMBEDDINGS_PROVIDER=openai
# EMBEDDINGS_MODEL=text-embedding-3-small

#===================================================#
#                    User System                    #
#===================================================#

#========================#
# Moderation             #
#========================#

OPENAI_MODERATION=false
OPENAI_MODERATION_API_KEY=
# OPENAI_MODERATION_REVERSE_PROXY=

BAN_VIOLATIONS=true
BAN_DURATION=1000 * 60 * 60 * 2
BAN_INTERVAL=20

LOGIN_VIOLATION_SCORE=1
REGISTRATION_VIOLATION_SCORE=1
CONCURRENT_VIOLATION_SCORE=1
MESSAGE_VIOLATION_SCORE=1
NON_BROWSER_VIOLATION_SCORE=20

LOGIN_MAX=7
LOGIN_WINDOW=5
REGISTER_MAX=5
REGISTER_WINDOW=60

LIMIT_CONCURRENT_MESSAGES=true
CONCURRENT_MESSAGE_MAX=2

LIMIT_MESSAGE_IP=true
MESSAGE_IP_MAX=40
MESSAGE_IP_WINDOW=1

LIMIT_MESSAGE_USER=false
MESSAGE_USER_MAX=40
MESSAGE_USER_WINDOW=1

ILLEGAL_MODEL_REQ_SCORE=5

#========================#
# Balance                #
#========================#

# CHECK_BALANCE=false
# START_BALANCE=20000 # note: the number of tokens that will be credited after registration.

#========================#
# Registration and Login #
#========================#

ALLOW_EMAIL_LOGIN=true
#ALLOW_EMAIL_LOGIN=false
ALLOW_REGISTRATION=true
#ALLOW_REGISTRATION=false
#ALLOW_SOCIAL_LOGIN=false
#ALLOW_SOCIAL_REGISTRATION=false
#ALLOW_PASSWORD_RESET=false
ALLOW_PASSWORD_RESET=true
# ALLOW_ACCOUNT_DELETION=true # note: enabled by default if omitted/commented out
ALLOW_UNVERIFIED_EMAIL_LOGIN=true

SESSION_EXPIRY=1000 * 60 * 15
REFRESH_TOKEN_EXPIRY=(1000 * 60 * 60 * 24) * 7

JWT_SECRET=16f8c0ef4a5d391b26034086c628469d3f9f497f08163ab9b40137092f2909ef
JWT_REFRESH_SECRET=eaa5191f2914e30b9387fd84e254e4ba6fc51b4654968a9b0803b456a54b8418

# Discord
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_CALLBACK_URL=/oauth/discord/callback

# Facebook
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_CALLBACK_URL=/oauth/facebook/callback

# GitHub
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=/oauth/github/callback
# GitHub Enterprise
# GITHUB_ENTERPRISE_BASE_URL=
# GITHUB_ENTERPRISE_USER_AGENT=

# Google
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=/oauth/google/callback

# Apple
APPLE_CLIENT_ID=
APPLE_TEAM_ID=
APPLE_KEY_ID=
APPLE_PRIVATE_KEY_PATH=
APPLE_CALLBACK_URL=/oauth/apple/callback

# OpenID
OPENID_CLIENT_ID=
OPENID_CLIENT_SECRET=
OPENID_ISSUER=
OPENID_SESSION_SECRET=
OPENID_SCOPE="openid profile email"
OPENID_CALLBACK_URL=/oauth/openid/callback
OPENID_REQUIRED_ROLE=
OPENID_REQUIRED_ROLE_TOKEN_KIND=
OPENID_REQUIRED_ROLE_PARAMETER_PATH=
# Set to determine which user info property returned from OpenID Provider to store as the User's username
OPENID_USERNAME_CLAIM=
# Set to determine which user info property returned from OpenID Provider to store as the User's name
OPENID_NAME_CLAIM=

OPENID_BUTTON_LABEL=
OPENID_IMAGE_URL=
# Set to true to automatically redirect to the OpenID provider when a user visits the login page
# This will bypass the login form completely for users, only use this if OpenID is your only authentication method
OPENID_AUTO_REDIRECT=false

# LDAP
LDAP_URL=
LDAP_BIND_DN=
LDAP_BIND_CREDENTIALS=
LDAP_USER_SEARCH_BASE=
#LDAP_SEARCH_FILTER="mail="
LDAP_CA_CERT_PATH=
# LDAP_TLS_REJECT_UNAUTHORIZED=
# LDAP_STARTTLS=
# LDAP_LOGIN_USES_USERNAME=true
# LDAP_ID=
# LDAP_USERNAME=
# LDAP_EMAIL=
# LDAP_FULL_NAME=

#========================#
# Email Password Reset   #
#========================#

EMAIL_SERVICE=
EMAIL_HOST=
EMAIL_PORT=25
EMAIL_ENCRYPTION=
EMAIL_ENCRYPTION_HOSTNAME=
EMAIL_ALLOW_SELFSIGNED=
EMAIL_USERNAME=
EMAIL_PASSWORD=
EMAIL_FROM_NAME=
EMAIL_FROM=noreply@librechat.ai

#========================#
# Firebase CDN           #
#========================#

FIREBASE_API_KEY=
FIREBASE_AUTH_DOMAIN=
FIREBASE_PROJECT_ID=
FIREBASE_STORAGE_BUCKET=
FIREBASE_MESSAGING_SENDER_ID=
FIREBASE_APP_ID=

#========================#
# S3 AWS Bucket          #
#========================#

AWS_ENDPOINT_URL=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_BUCKET_NAME=

#========================#
# Azure Blob Storage     #
#========================#

AZURE_STORAGE_CONNECTION_STRING=
AZURE_STORAGE_PUBLIC_ACCESS=false
AZURE_CONTAINER_NAME=files

#========================#
# Shared Links           #
#========================#

ALLOW_SHARED_LINKS=true
ALLOW_SHARED_LINKS_PUBLIC=true

#==============================#
# Static File Cache Control    #
#==============================#

# Leave commented out to use defaults: 1 day (86400 seconds) for s-maxage and 2 days (172800 seconds) for max-age
# NODE_ENV must be set to production for these to take effect
# STATIC_CACHE_MAX_AGE=172800
# STATIC_CACHE_S_MAX_AGE=86400

# If you have another service in front of your LibreChat doing compression, disable express based compression here
# DISABLE_COMPRESSION=true

#===================================================#
#                        UI                         #
#===================================================#

APP_TITLE=LibreChat
# CUSTOM_FOOTER="My custom footer"
HELP_AND_FAQ_URL=https://librechat.ai

# SHOW_BIRTHDAY_ICON=true

# Google tag manager id
#ANALYTICS_GTM_ID=user provided google tag manager id

#===============#
# REDIS Options #
#===============#

# REDIS_URI=10.10.10.10:6379
# USE_REDIS=true

# USE_REDIS_CLUSTER=true
# REDIS_CA=/path/to/ca.crt

#==================================================#
#                      Others                      #
#==================================================#
#   You should leave the following commented out   #

# NODE_ENV=

# E2E_USER_EMAIL=
# E2E_USER_PASSWORD=

#=====================================================#
#                  Cache Headers                      #
#=====================================================#
#   Headers that control caching of the index.html    #
#   Default configuration prevents caching to ensure  #
#   users always get the latest version. Customize    #
#   only if you understand caching implications.      #

# INDEX_HTML_CACHE_CONTROL=no-cache, no-store, must-revalidate
# INDEX_HTML_PRAGMA=no-cache
# INDEX_HTML_EXPIRES=0

# no-cache: Forces validation with server before using cached version
# no-store: Prevents storing the response entirely
# must-revalidate: Prevents using stale content when offline

#=====================================================#
#                  OpenWeather                        #
#=====================================================#
OPENWEATHER_API_KEY=

librechat.yamlファイル

ここをクリックしてlibrechat.yamlファイルを表示
# For more information, see the Configuration Guide:
# https://www.librechat.ai/docs/configuration/librechat_yaml

# Configuration version (required)
version: 1.2.1

# Cache settings: Set to true to enable caching
cache: true

# File strategy s3/firebase
# fileStrategy: "s3"

# Custom interface configuration
interface:
  customWelcome: "Welcome to LibreChat! Enjoy your experience."
  # Privacy policy settings
  privacyPolicy:
    externalUrl: 'https://librechat.ai/privacy-policy'
    openNewTab: true

  # Terms of service
  termsOfService:
    externalUrl: 'https://librechat.ai/tos'
    openNewTab: true
    modalAcceptance: true
    modalTitle: "Terms of Service for LibreChat"
    modalContent: |
      # Terms and Conditions for LibreChat

      *Effective Date: February 18, 2024*

      Welcome to LibreChat, the informational website for the open-source AI chat platform, available at https://librechat.ai. These Terms of Service ("Terms") govern your use of our website and the services we offer. By accessing or using the Website, you agree to be bound by these Terms and our Privacy Policy, accessible at https://librechat.ai//privacy.

      ## 1. Ownership

      Upon purchasing a package from LibreChat, you are granted the right to download and use the code for accessing an admin panel for LibreChat. While you own the downloaded code, you are expressly prohibited from reselling, redistributing, or otherwise transferring the code to third parties without explicit permission from LibreChat.

      ## 2. User Data

      We collect personal data, such as your name, email address, and payment information, as described in our Privacy Policy. This information is collected to provide and improve our services, process transactions, and communicate with you.

      ## 3. Non-Personal Data Collection

      The Website uses cookies to enhance user experience, analyze site usage, and facilitate certain functionalities. By using the Website, you consent to the use of cookies in accordance with our Privacy Policy.

      ## 4. Use of the Website

      You agree to use the Website only for lawful purposes and in a manner that does not infringe the rights of, restrict, or inhibit anyone else's use and enjoyment of the Website. Prohibited behavior includes harassing or causing distress or inconvenience to any person, transmitting obscene or offensive content, or disrupting the normal flow of dialogue within the Website.

      ## 5. Governing Law

      These Terms shall be governed by and construed in accordance with the laws of the United States, without giving effect to any principles of conflicts of law.

      ## 6. Changes to the Terms

      We reserve the right to modify these Terms at any time. We will notify users of any changes by email. Your continued use of the Website after such changes have been notified will constitute your consent to such changes.

      ## 7. Contact Information

      If you have any questions about these Terms, please contact us at contact@librechat.ai.

      By using the Website, you acknowledge that you have read these Terms of Service and agree to be bound by them.

  endpointsMenu: true
  modelSelect: true
  parameters: true
  sidePanel: true
  presets: true
  prompts: true
  bookmarks: true
  multiConvo: true
  agents: true

# Example Registration Object Structure (optional)
registration:
  socialLogins: ['github', 'google', 'discord', 'openid', 'facebook', 'apple']
  # allowedDomains:
  # - "gmail.com"


# Example Balance settings
# balance:
#   enabled: false
#   startBalance: 20000
#   autoRefillEnabled: false
#   refillIntervalValue: 30
#   refillIntervalUnit: 'days'
#   refillAmount: 10000

# speech:
#   tts:
#     openai:
#       url: ''
#       apiKey: '${TTS_API_KEY}'
#       model: ''
#       voices: ['']

#
#   stt:
#     openai:
#       url: ''
#       apiKey: '${STT_API_KEY}'
#       model: ''

# rateLimits:
#   fileUploads:
#     ipMax: 100
#     ipWindowInMinutes: 60  # Rate limit window for file uploads per IP
#     userMax: 50
#     userWindowInMinutes: 60  # Rate limit window for file uploads per user
#   conversationsImport:
#     ipMax: 100
#     ipWindowInMinutes: 60  # Rate limit window for conversation imports per IP
#     userMax: 50
#     userWindowInMinutes: 60  # Rate limit window for conversation imports per user

# Example Actions Object Structure
actions:
  allowedDomains:
    - "swapi.dev"
    - "librechat.ai"
    - "google.com"

# Example MCP Servers Object Structure
# mcpServers:
#   everything:
#     # type: sse # type can optionally be omitted
#     url: http://localhost:3001/sse
#     timeout: 60000  # 1 minute timeout for this server, this is the default timeout for MCP servers.
#   puppeteer:
#     type: stdio
#     command: npx
#     args:
#       - -y
#       - "@modelcontextprotocol/server-puppeteer"
#     timeout: 300000  # 5 minutes timeout for this server
#   filesystem:
#     # type: stdio
#     command: npx
#     args:
#       - -y
#       - "@modelcontextprotocol/server-filesystem"
#       - /home/user/LibreChat/
#     iconPath: /home/user/LibreChat/client/public/assets/logo.svg
#   mcp-obsidian:
#     command: npx
#     args:
#       - -y
#       - "mcp-obsidian"
#       - /path/to/obsidian/vault

# Definition of custom endpoints
endpoints:
  # assistants:
  #   disableBuilder: false # Disable Assistants Builder Interface by setting to `true`
  #   pollIntervalMs: 3000  # Polling interval for checking assistant updates
  #   timeoutMs: 180000  # Timeout for assistant operations
  #   # Should only be one or the other, either `supportedIds` or `excludedIds`
  #   supportedIds: ["asst_supportedAssistantId1", "asst_supportedAssistantId2"]
  #   # excludedIds: ["asst_excludedAssistantId"]
  #   # Only show assistants that the user created or that were created externally (e.g. in Assistants playground).
  #   # privateAssistants: false # Does not work with `supportedIds` or `excludedIds`
  #   # (optional) Models that support retrieval, will default to latest known OpenAI models that support the feature
  #   retrievalModels: ["gpt-4-turbo-preview"]
  #   # (optional) Assistant Capabilities available to all users. Omit the ones you wish to exclude. Defaults to list below.
  #   capabilities: ["code_interpreter", "retrieval", "actions", "tools", "image_vision"]
  # agents:
  #   # (optional) Default recursion depth for agents, defaults to 25
  #   recursionLimit: 50
  #   # (optional) Max recursion depth for agents, defaults to 25
  #   maxRecursionLimit: 100
  #   # (optional) Disable the builder interface for agents
  #   disableBuilder: false
  #   # (optional) Agent Capabilities available to all users. Omit the ones you wish to exclude. Defaults to list below.
  #   capabilities: ["execute_code", "file_search", "actions", "tools"]
  custom:
    # OpenRouter Example
    - name: 'OpenRouter'
      # For `apiKey` and `baseURL`, you can use environment variables that you define.
      # recommended environment variables:
      apiKey: '${OPENROUTER_KEY}'
      baseURL: 'https://openrouter.ai/api/v1'
      models:
        default: ['openai/gpt-4o-mini','openai/o3-mini-high','openai/o3-mini','anthropic/claude-3.7-sonnet']
        fetch: true
      titleConvo: true
      titleModel: 'OpenRouter'
      # Recommended: Drop the stop parameter from the request as Openrouter models use a variety of stop tokens.
      dropParams: ['stop']
      modelDisplayLabel: 'OpenRouter'

docker-compose.override.ymlファイル

ここをクリックしてdocker-compose.override.ymlファイルを表示
services:
  api:
    volumes:
      - type: bind
        source: ./.env
        target: /app/.env
      - type: bind
        source: ./librechat.yaml
        target: /app/librechat.yaml
      - ./images:/app/client/public/images
      - ./uploads:/app/uploads
      - ./logs:/app/api/logs

7.5. LibreChatの起動

LibreChatの起動はdocker compose up -dコマンドで行います。初回起動時にはDockerHubからのpullが行われるため、多少時間を要します。

root@ip-172-26-9-78:~/LibreChat# docker compose up -d
WARN[0000] The "UID" variable is not set. Defaulting to a blank string.
WARN[0000] The "GID" variable is not set. Defaulting to a blank string.
WARN[0000] The "UID" variable is not set. Defaulting to a blank string.
WARN[0000] The "GID" variable is not set. Defaulting to a blank string.
WARN[0000] The "UID" variable is not set. Defaulting to a blank string.
WARN[0000] The "GID" variable is not set. Defaulting to a blank string.
[+] Running 13/54
 ⠦ vectordb [⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀] Pulling                                                                                                                       8.7s
 ⠦ api [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶]   205MB / 241.1MB Pulling                                                                                                               8.7s
 ⠦ rag_api [⣿⣿⣿⣿⣿⣷⣿⣀⠀⠀] Pulling                                                                                                                             8.7s
 ⠦ mongodb [⠀⠀⠀⠀⠀⠀⠀⠀] Pulling                                                                                                                               8.7s
 ⠦ meilisearch [⠀⠀⠀⠀⠀⠀] Pulling       

8.LibreChat初期設定

アタッチした静的IPにブラウザで接続すると以下のようなLibreChatの初期画面が表示されるので、「新規登録」からメールアドレス、パスワードを登録します。

LibreChat.png

ユーザ登録が完了したら.envファイルの以下のパラメタを修正して、LibreChatを再起動しましょう。

これにより新規登録ができなくなります。

#========================#
# Registration and Login #
#========================#

ALLOW_EMAIL_LOGIN=true
#ALLOW_EMAIL_LOGIN=false
#ALLOW_REGISTRATION=true
ALLOW_REGISTRATION=false
ALLOW_SOCIAL_LOGIN=false
ALLOW_SOCIAL_REGISTRATION=false
ALLOW_PASSWORD_RESET=false
#ALLOW_PASSWORD_RESET=true

9.使って見る

openai/gpt-4o-mini-search-previewを使って日本の総理大臣を質問

gpt-4o-mini-search-previewはLLMの中でインターネット検索するため、現在の日本の総理大臣を正しく答えることができます。

LibreChat-gpt-4o-search-preview.png

10.まとめ

本記事では、AWS LightSailを使用してLibreChatのインスタンスを使用してマルチコンテナアプリケーションとして構築・運用する手順を詳しく解説しました。
本来ならばAWS LightSail コンテナサービスからマルチコンテナアプリケーションを構築・運用したいところですが、現時点では一筋縄ではいかないようです。
AWS契約からインスタンスの作成、Docker環境の構築、LibreChatの設定まで、順を追って実施することで、安価で安定した生成AI環境を構築することができます。

特に以下のポイントがポイントとなります:

  • AWS LightSailの5.00USD/月プランでは十分な性能が得られず12.00USD/月プランに変更したこと
  • Docker Composeを使用した効率的なコンテナ管理
  • .envファイルとlibrechat.yamldocker-compose.override.ymlによる詳細な設定が可能
  • OpenAI、OpenRouterとの連携による多様なAIモデルの利用

この構成により、ChatGPTのような商用サービスに依存することなく、自前で管理可能な生成AI環境を実現できます。セキュリティ面でも考慮されており、初期設定後は新規登録を制限することで、安全な運用が可能です。

11.課題

LightSailはVPSサービスであり、コンテナ型のPaaSではないことによる弊害

  • DNS登録されない
    EC2はデフォルトでDNSされますが、LightSailはDNS登録されないため、Route 53などの別サービスでドメインの年間利用を行いRoute 53サービスでDNS解決させることもできます。
    私が調べた限り2025年4月時点ですと.clickドメインが最安値で年間3.00USDで利用できます。
    それ以外に毎月0.50USDのDNS管理費用がかかります。
  • デフォルトではTLS通信されない
    EIP(Elastic IP)で割り当てたグローバルな静的IPではデフォルトではTLS通信されないため、ACM(AWS Certificate Manager)を使って無料でSSL証明書を発行することができます。
    この場合Route 53や外部のドメイン管理組織によるドメインが必要になります。

12.参考URL

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?