Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions docker/app/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ RUN apt-get update -qq && \
curl \
&& rm -rf /var/lib/apt/lists/*


WORKDIR /digichat

RUN chown -R node:node ./
Expand All @@ -25,5 +24,24 @@ RUN if git config --global --get gpg.ssh.program; then \
git config --global --unset gpg.ssh.program; \
fi

# スクリプトの実行権限を付与
COPY --chown=node:node scripts/create-admin-user.sh /digichat/scripts/
RUN chmod +x /digichat/scripts/create-admin-user.sh

# 起動スクリプトの作成
RUN echo '#!/bin/bash\n\
# アプリケーションの起動\n\
pnpm dev &\n\
\n\
# アプリケーションの起動を待機\n\
echo "Waiting for application to start..."\n\
sleep 10\n\
\n\
# 管理者ユーザーの作成\n\
/digichat/scripts/create-admin-user.sh\n\
\n\
# フォアグラウンドプロセスの維持\n\
wait' > /digichat/start.sh && chmod +x /digichat/start.sh

# コンテナ起動時のコマンド
CMD ["/bin/bash"]
CMD ["/digichat/start.sh"]
2 changes: 1 addition & 1 deletion docker/db/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM postgres:17.2-bookworm
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i ja_JP -c -f UTF-8 -A /usr/share/locale/locale.alias ja_JP.UTF-8
ENV LANG ja_JP.utf8
ENV LANG ja_JP.utf8
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"format": "prettier --write \"./src/**/*.{ts,tsx}\"",
"lint": "eslint",
"stylelint": "stylelint \"./src/**/*.css\" --fix",
"seed": "npx prisma migrate reset --force & npx tsx ./prisma/seed/init.ts"
"seed": "npx prisma migrate reset --force & npx tsx ./prisma/seed/init.ts",
"create-admin-user": "bash ./scripts/create-admin-user.sh"
},
"dependencies": {
"@auth/prisma-adapter": "^2.8.0",
Expand Down
23 changes: 23 additions & 0 deletions scripts/create-admin-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# 環境変数の確認
if [ -z "$ADMIN_EMAIL" ]; then
echo "❌エラー: 環境変数`ADMIN_EMAIL`が設定されていません"
exit 1
fi

# ユーザー名とスラッグの生成
ADMIN_NAME="Admin User"
ADMIN_SLUG=$(echo $ADMIN_EMAIL | cut -d@ -f1)

# APIリクエストの実行
curl -X POST http://localhost:3000/api/ext/users/create \
-H "Content-Type: application/json" \
-H "Authorization: ${EXT_API_SECRET}" \
-d "{
\"name\": \"${ADMIN_NAME}\",
\"email\": \"${ADMIN_EMAIL}\",
\"slug\": \"${ADMIN_SLUG}\"
}"

echo "✅テスト用管理者ユーザーの作成が完了しました"