Created
March 8, 2019 17:21
-
-
Save bruce/36c08abf8cf8882a25ac5ca81b085bfb to your computer and use it in GitHub Desktop.
docker-compose + development Phoenix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.2" | |
services: | |
postgres: | |
image: mdillon/postgis:10 | |
environment: | |
- POSTGRES_PASSWORD= | |
- POSTGRES_USER=exchange | |
- PG_DATA=/var/lib/postgresql/data | |
ports: | |
- "15432:5432" | |
volumes: | |
- ./pg_data:/var/lib/postgresql/data | |
exchange: | |
build: | |
context: ./ | |
dockerfile: Dockerfile.dev | |
volumes: | |
- type: bind | |
source: ./ | |
target: /app | |
ports: | |
- "4000:4000" | |
depends_on: | |
- postgres | |
command: | |
- ./bin/run.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM cargosense/elixir-ubuntu:20.2-v1.6.2 | |
# Install debian packages | |
RUN apt-get update | |
RUN apt-get install -y build-essential inotify-tools postgresql-client | |
# Install Phoenix packages | |
RUN mix local.hex --force | |
RUN mix local.rebar --force | |
RUN mix archive.install --force https://github.com/phoenixframework/archives/raw/master/phx_new.ez | |
WORKDIR /app | |
EXPOSE 4000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Adapted from Alex Kleissner's post, Running a Phoenix 1.3 project with docker-compose | |
# https://medium.com/@hex337/running-a-phoenix-1-3-project-with-docker-compose-d82ab55e43cf | |
set -e | |
# Ensure the app's dependencies are installed | |
mix deps.get | |
export PGPASSWORD="FIXME-YOUR-PASSWORD" | |
# Prepare Dialyzer if the project has Dialyxer set up | |
if mix help dialyzer >/dev/null 2>&1 | |
then | |
echo "\nFound Dialyxer: Setting up PLT..." | |
mix do deps.compile, dialyzer --plt | |
else | |
echo "\nNo Dialyxer config: Skipping setup..." | |
fi | |
# Wait for Postgres to become available. | |
until psql -h postgres -U "FIXME-YOUR-DB-USER" -c '\q' template1 2>/dev/null; do | |
>&2 echo "Postgres is unavailable - sleeping" | |
sleep 1 | |
done | |
echo "\nPostgres is available: continuing with database setup...." | |
if psql -h postgres -U "FIXME-YOUR-DB-USER" -c '\q' FIXME_YOUR_DB_NAME 2>/dev/null; | |
then | |
echo "Database already setup" | |
else | |
mix ecto.setup | |
fi | |
echo "\n Launching Phoenix web server..." | |
# Start the phoenix web server | |
mix phx.server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment