Defang is the easiest way to deploy containerized apps like this Phoenix + Postgres sample to AWS. This is a sample Phoenix application that uses a PostgreSQL database. The sample doesn't add anything to the database, but is based off of the default Phoenix getting started instructions which add a postgres database to the application.
- Download Defang CLI
- (Optional) If you are using Defang BYOC authenticated with your AWS account
- (Optional for local development) Docker CLI
To run the application locally, you can use the following command:
docker compose -f compose.yaml -f compose.dev.yaml up --buildThis will run Phoenix in development mode. If you need to run any commands in the container, after you have run the command above and started the container, you can run the command in a new terminal:
docker compose -f compose.yaml -f compose.dev.yaml exec phoenix bash- Open the terminal and type
defang login - Provide values for
SECRET_KEY_BASEandDATABASE_URLSECRET_KEY_BASEis a secret key used by Phoenix to sign cookies and other things. You can generate one by runningdocker compose -f compose.yaml -f compose.dev.yaml run --rm phoenix mix phx.gen.secretDATABASE_URLis the connection string for your PostgreSQL database. It should look something likeecto://username:password@hostname/dbname
- Type
defang compose upin the CLI. - Your app will be running within a few minutes.
Title: Phoenix & PostgreSQL
Short Description: A sample Phoenix application that uses a PostgreSQL database.
Tags: Phoenix, PostgreSQL, Database, Elixir
Languages: Elixir