{"id":25072517,"url":"https://github.com/cr0t/elixir-on-whales","last_synced_at":"2025-07-13T15:33:17.839Z","repository":{"id":136839856,"uuid":"234416934","full_name":"cr0t/elixir-on-whales","owner":"cr0t","description":"Docker Compose template for Elixir/Phoenix apps","archived":false,"fork":false,"pushed_at":"2022-09-13T10:52:30.000Z","size":32,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T22:02:50.733Z","etag":null,"topics":["docker","docker-compose","elixir","phoenix","phoenix-framework"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cr0t.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-16T21:38:26.000Z","updated_at":"2023-11-29T19:10:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"f01026bd-ca97-41f7-b37b-7a42838ab9a5","html_url":"https://github.com/cr0t/elixir-on-whales","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/cr0t/elixir-on-whales","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr0t%2Felixir-on-whales","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr0t%2Felixir-on-whales/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr0t%2Felixir-on-whales/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr0t%2Felixir-on-whales/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cr0t","download_url":"https://codeload.github.com/cr0t/elixir-on-whales/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cr0t%2Felixir-on-whales/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265162840,"owners_count":23720848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","elixir","phoenix","phoenix-framework"],"created_at":"2025-02-06T22:29:49.192Z","updated_at":"2025-07-13T15:33:17.790Z","avatar_url":"https://github.com/cr0t.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elixir on Whales\n\n\u003e Inspired by [Dockerizing Ruby and Rails development] blog post.\n\nThis repository provides a template that supposed to help to organize an development environment for Elixir and/or Phoenix applications.\n\nBelow there is step-by-step instructions on how to bootstrap a new Phoenix application.\n\nYou can also find a few tips on how to use `:observer` GUI from inside a running Docker container.\n\n## Phoenix Application\n\n```console\n$ git clone git@github.com:cr0t/elixir-on-whales.git \u003cyour-app-name\u003e\n$ cd \u003cyour-app-name\u003e \u0026\u0026 rm -rf .git\n$ mv .env.example .env\n$ mv README.md README-ON-WHALES.md # we need this to avoid conflicts with app's README.md\n$ mv LICENSE LICENSE-ON-WHALES     # and with app's license\n```\n\nNow you can open `docker-compose.yml`, remove services you do not need and adjust versions and other settings in the `.env` file before you proceed.\n\n```console\n$ docker-compose up\n```\n\nThis will download Docker images and set up containers for us. Don't exit (yet)!\n\nWhen this is done, **in a separate terminal** you need to start a new shell session to install Phoenix framework inside the container.\n\n```console\n$ docker-compose exec shell sh\n/app# mix archive.install hex phx_new 1.6.12\n/app# mix phx.new . --module WhalesExample\n```\n\n\u003e Replace `WhalesExample` with the name for your application.\n\nNow you should edit `config/dev.exs` and `config/test.exs` files. You can do it inside the shell session, or via editor on your host machine.\n\nYou need to ensure that your application will use correct database URL, and server will run on 0.0.0.0 (by default, Phoenix starts a server on 127.0.0.1 interface, so it makes it unreachable outside of container).\n\nBelow there configuration files (not full, only sections that need to be changed).\n\n\u003e Please, ensure that you replaced `WhalesExampleWeb` with your application module name in the examples below.\n\n`config/dev.exs` highlights:\n\n```elixir\nconfig :app, WhalesExampleWeb.Repo,\n  url: System.get_env(\"DATABASE_URL\") || \"postgres://postgres:secret@postgres:5432/app_dev\",\n  stacktrace: true,\n  show_sensitive_data_on_connection_error: true,\n  pool_size: 10\n\n# ...\n\nconfig :app, WhalesExampleWeb.Endpoint,\n  http: [ip: {0, 0, 0, 0}, port: 4000],\n```\n\n`config/test.exs` highlights:\n\n```elixir\ndatabase_url =\n  System.get_env(\"DATABASE_URL\") || \"postgres://postgres:secret@postgres:5432/app_dev\"\n\nconfig :app, WhalesExampleWeb.Repo,\n  url: database_url |\u003e String.replace(\"app_dev\", \"app_test#{System.get_env(\"MIX_TEST_PARTITION\")}\")\n  pool: Ecto.Adapters.SQL.Sandbox\n```\n\nNow we can create database, restart Docker containers and get Phoenix applpication up and running!\n\n```console\n/app# mix ecto.create\n/app# exit\n$ docker-compose stop # or down\n$ docker-compose start # or up\n```\n\n\u003e We need to run two last commands to re-start all services defined in `docker-compose.yml` (if we left it original).\n\nAs you see, we made a trick with `String.replace(\"app_dev\", ...)` in `test.exs` configuration file - this is a dirty workaround that converts `DATABASE_URL` environment variable to its own database url to run tests.\n\n\u003e Do not forget to explicitly run `MIX_ENV=test mix test` command.\n\nOk! Now you can try to open http://localhost:4000/ in the browser on the host machine and check if you see Phoenix welcome page.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg width=\"1378\" alt=\"image\" src=\"https://user-images.githubusercontent.com/113878/189381540-651b1ac1-f637-40dc-bba9-c21dabb15644.png\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg width=\"1378\" alt=\"image\" src=\"https://user-images.githubusercontent.com/113878/189381588-18c4ca17-3d25-445b-ad2e-90ed8e07690d.png\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n[Dockerizing Ruby and Rails development]: https://evilmartians.com/chronicles/ruby-on-whales-docker-for-ruby-rails-development\n\n## Using `:observer` in macOS\n\nIf you use macOS and want to be able to access `:observer` GUI, there is a workaround we found [here](https://github.com/moby/moby/issues/8710).\n\nFirst, you need to install a couple of utilities:\n\n```console\n$ brew install socat\n$ brew cask install xquartz\n```\n\n\u003e Probably, you will need to restart your system.\n\n[`socat`](http://www.dest-unreach.org/socat/) (\"SOcket CAT: netcat on steroids\") is a small utility which can help us with proxying ports.\n\nThe [XQuartz project](https://www.xquartz.org/) is an open-source effort to develop a version of the X.Org X Window System that runs on OS X.\n\nThen you also need to obtain your host machine local network IP address (try to run `ipconfig getifaddr en0` or look into System Preferences). You need to update `.env` file with this piece of information (see `X_WINDOWS_ADDRESS`).\n\nNow we need to start proxy on the host system (use a separate terminal to run this command):\n\n```console\n$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\\\"$DISPLAY\\\"\n```\n\nAfter having this done we can start using magic of remote X Window sessions:\n\n```console\n$ docker-compose exec phoenix iex\nErlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1] [hipe]\n\nInteractive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help)\niex(1)\u003e :observer.start()\n:ok\n```\n\nNow you should see something similar to this on your screen:\n\n![docker-observer-mac-os-x-windows](https://user-images.githubusercontent.com/113878/73979910-6b420200-492f-11ea-9b1d-d526b11c9d06.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcr0t%2Felixir-on-whales","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcr0t%2Felixir-on-whales","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcr0t%2Felixir-on-whales/lists"}