-
-
Save easbarba/423ac1f1bcba9b87a6a83cdd9d271d8f to your computer and use it in GitHub Desktop.
Setup script for Phoenix projects using Nix and PostgreSQL
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 | |
echo | |
if [ ! -d "deps" ] || [ ! "$(ls -A deps)" ]; then | |
printf "\e[32m=> Fetching dependencies and building the application...\e[0m\n\n" | |
echo "+ mix do deps.get, compile --verbose" | |
mix do deps.get, compile --verbose | |
echo | |
fi | |
if [ ! -d "$PGDATA" ]; then | |
printf "\e[32m=> Initialising the database in $PGDATA...\e[0m\n\n" | |
echo "+ initdb --no-locale --encoding=UTF-8" | |
initdb --no-locale --encoding=UTF-8 | |
echo | |
fi | |
if [ ! -f "$PGDATA/postmaster.pid" ]; then | |
printf "\e[32m=> Starting PostgreSQL...\e[0m\n\n" | |
echo "+ pg_ctl -l \"$PGDATA/server.log\" start" | |
pg_ctl -l "$PGDATA/server.log" start | |
echo | |
fi | |
printf "\e[32m=> Creating the postgres user if necessary...\e[0m\n\n" | |
echo "+ createuser postgres --createdb --echo" | |
createuser postgres --createdb --echo | |
echo | |
set -e | |
printf "\e[32m=> Setting up the database...\e[0m\n\n" | |
echo "+ mix ecto.reset" | |
mix ecto.reset | |
echo | |
printf "\e[32m\e[1mThe project setup is complete!\e[0m\n\n" | |
printf "To start the application in an IEx shell, you can now run:\n\n" | |
printf " iex -S mix phx.server\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment