Last active
April 23, 2026 02:13
-
-
Save bbassett/24be1cd4d4843bff6be06fb0081daaaa to your computer and use it in GitHub Desktop.
generate an elixir app
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/bash | |
| set -euo pipefail | |
| APP_NAME="${1:-}" | |
| if [[ -z "$APP_NAME" ]]; then | |
| echo "Usage: $0 <app_name>" | |
| exit 1 | |
| fi | |
| mix phx.new ${APP_NAME} --database postgres --verbose --install | |
| cd ${APP_NAME} | |
| mix igniter.install ash --yes | |
| mix igniter.install credo --yes | |
| mix deps.get | |
| mix credo.gen.config | |
| mix compile | |
| mix phx.gen.auth Accounts User users --live | |
| mix deps.get | |
| PROJECT_NAME="${APP_NAME}_db" | |
| DB_NAME="${APP_NAME}_dev" | |
| DB_USER="postgres" | |
| DB_PASSWORD="postgres" | |
| PORT=5432 | |
| OUTPUT_FILE="docker-compose.yml" | |
| cat > "$OUTPUT_FILE" <<EOF | |
| name: ${PROJECT_NAME} | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| container_name: ${PROJECT_NAME}_postgres | |
| restart: unless-stopped | |
| environment: | |
| POSTGRES_DB: ${DB_NAME} | |
| POSTGRES_USER: ${DB_USER} | |
| POSTGRES_PASSWORD: ${DB_PASSWORD} | |
| ports: | |
| - "${PORT}:5432" | |
| volumes: | |
| - ${PROJECT_NAME}_data:/var/lib/postgresql/data | |
| volumes: | |
| ${PROJECT_NAME}_data: | |
| EOF | |
| git branch -m main | |
| git add . | |
| git commit -m "initial commit" | |
| echo "Created ${OUTPUT_FILE}" | |
| echo | |
| echo "Project name: ${PROJECT_NAME}" | |
| echo "Database: ${DB_NAME}" | |
| echo "User: ${DB_USER}" | |
| echo "Password: ${DB_PASSWORD}" | |
| echo | |
| docker compose up -d | |
| mix ecto.create | |
| mix ecto.migrate | |
| echo "Start app with:" | |
| echo " iex -S mix phx.server" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment