VOOZH about

URL: https://qiita.com/torifukukaiou/items/bc1e3486330e1be2674f

⇱ 闘魂Phoenix道場:PostgreSQLをDockerで立ち上げるッ!!!(devcontainer付き) Phoenixアプリから使わせていただく #Elixir - Qiita


👁 Image
6

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 1 year has passed since last update.

👁 Image
みんなでPostgreSQLの知見を共有しよう
Qiita Tech Festa20252025年7月15日まで開催中!
@torifukukaiou(Awesome YAMAUCHI)Team Coffeein👁 Image
株式会社ハウインターナショナル

闘魂Phoenix道場:PostgreSQLをDockerで立ち上げるッ!!!(devcontainer付き) Phoenixアプリから使わせていただく

6
Last updated at Posted at 2025-06-18

いよいよはじまりました!
Qiita Tech Festa 👁 :tada:
👁 :tada:
👁 :tada:

はじめに

こんにちは、ElixirとPhoenixをこよなく愛する闘魂プログラマーです。
つまりAIプログラマーです。あっ、AIとは、Antonio Inokiさん、つまり猪木さんのことです。

本記事は、みんなでPostgreSQLの知見を共有しよう への参加記事です。

PhoenixのデフォルトDBはPostgreSQL

Phoenix では、プロジェクトを作成する際にPostgreSQLがデフォルトで使われます。

mix phx.new hello
# => デフォルトでPostgreSQLが選ばれます

Phoenixとは、Elixir製のすんごいWebアプリケーションフレームワークのことです。

DockerでPostgreSQLを立ち上げる

新しいPCを新調するたびに、自分のローカルにPostgreSQLを入れるのは面倒ですし、慎重派の私はDockerコンテナで立ち上げています。

docker run -d --rm -p 5432:5432 -e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres postgres

POSTGRES_USERPOSTGRES_PASSWORDには、config/dev.exsにデータベースへの接続情報が以下のように作られるのでそれにあわせて、postgresをセットしています。

config/dev.exs
config :hello, Hello.Repo,
 username: "postgres",
 password: "postgres",
 hostname: "localhost",
 database: "hello_dev",
 stacktrace: true,
 show_sensitive_data_on_connection_error: true,
 pool_size: 10

devcontainerでも起動してます

私がメンテしている phx_devcontainer というdevcontainer定義でもPostgreSQLが入っています。

こちらを使うと、Elixir + Phoenix + PostgreSQL の開発環境が短時間で整います。
devcontainerですので、つまりは所謂ひとつのCodespaceでも開発ができます。
別記事で紹介していますので、よければご覧ください。

おわりに

PhoenixとPostgreSQLは、最初から相性がいいです。意識しなくてもPostgreSQLと共に開発が始まります。

PostgreSQLキャンペーンをきっかけに、象さんのアイコンを思い出しました。

闘魂とは、己に打ち克つこと。そしてPhoenixアプリケーションの裏にPostgreSQLあり。

元氣ですかーーーッ!!!

6

Go to list of users who liked

0
0

Go to list of comments

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
6

Go to list of users who liked

0