This repository contains the source code for Curbside Concerts / Send a Concert, a charity project that Test Double is working on with Can't Stop Columbus.
Stack:
The codebase is structured as a Phoenix Umbrella project into two "apps":
curbside_concerts
- An Ecto application containing the data contexts; this is responsible for interfacing with the database.curbside_concerts_web
- A Phoenix application containing the front-end routes, controllers, views, and templates.We recommend using asdf or exenv, to manage your Elixir versions and automatically use the local version defined in the local *-version
files. Alternatively, follow the instructions in the Elixir Install Page.
Note: It's important to have the correct Elixir version when developing locally, to help avoid build failures in Travis due to a mismatch in available methods, etc.
Erlang can be installed through homebrew:
brew install erlang
[Optional]docker and docker-compose, for running Postgres (recommended). Alternatively, you can install and run Postgres locally.
First time setup:
# start up the database, if using docker
docker-compose up -d
# install dependencies and initialize the database
bin/setup.sh
To run the app locally:
# start the postgres database
docker-compose up -d
# start the elixir application
mix phx.server
To run unit tests:
mix test
# or, use TDD
mix test.watch
See the e2e directory README for instruction on running the end-to-end tests using Cypress.
Some routes require authentication. On local, this means you'll need to create a user account in the database.
iex -S mix
> CurbsideConcerts.Accounts.create_user(%{username: "admin", password: "password"})
Then, you can log in with the credentials you created.
It's possible to develop against a production-like environment locally by copying the database contents from Heroku into your development instance of Postgres.
See the heroku documentation for more information on importing/exporting Postgres databases.
# Run the local database
docker-compose up -d
# Ensure that production has the latest migrations (it should already)
heroku run "POOL_SIZE=2 mix ecto.migrate" -a <heroku_app_name>
# Generate a backup of the heroku production data
heroku pg:backups:capture -a sendaconcert
# Download the dump file locally, defaults the file name to latest.dump
heroku pg:backups:download -a sendaconcert
# Replace your local db with the downloaded dump.
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d curbside_concerts_dev latest.dump
At the moment, this repository is connected directly to the Heroku Project. Pushing to master will automatically kick off a build and deploy.
If your change also requires a database migration, be sure to run that after the build completes:
heroku run "POOL_SIZE=2 mix ecto.migrate" -a <heroku_app_name>
To run Elixir code on the deployed instance, you can also access iex
:
heroku run "POOL_SIZE=2 iex -S mix" -a <heroku_app_name>
Note: The POOL_SIZE
argument here assumes you folowed the Phoenix / Heroku docs linked below, which sets a specific pool size for the app itself.
These are the steps needed to configure this application for a new Heroku project.
heroku buildpacks:add hashnuke/elixir -a <heroku_app_name>
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static -a <heroku_app_name
Note: If you get zipfile errors when building in Heroku, try setting a different Elixir / Erlang version in elixir_buildpack.config
. At the time of this writing, we were unable to get Elixir 1.10.* to deploy successfully.