Skip to content

Commit b93a76c

Browse files
committed
dx: add Makefile to simplify getting started
1 parent 91cb67a commit b93a76c

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LOGIN_CODE_SALT="algora-login-code"
66
LOCAL_STORE_TTL=3600
77
LOCAL_STORE_SALT="algora-local-store"
88

9-
DATABASE_URL="postgresql://algora:password@localhost:5432/algora"
9+
DATABASE_URL="postgresql://postgres:postgres@localhost:15432/algora_dev"
1010

1111
GITHUB_CLIENT_ID=""
1212
GITHUB_CLIENT_SECRET=""

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.PHONY: help install uninstall server watch postgres psql postgres-rm
2+
3+
help:
4+
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
5+
6+
install: ## Run the initial setup
7+
mix setup
8+
9+
uninstall: postgres-rm ## Remove all containers
10+
11+
server: ## Start the web server
12+
iex -S mix phx.server
13+
14+
watch: ## Recompile on file changes
15+
find lib/ | entr mix compile
16+
17+
postgres: ## Start a container with latest postgres
18+
docker run --detach -e POSTGRES_PASSWORD="postgres" -p 15432:5432 --name algora_db --volume=algora_db:/var/lib/postgresql/data postgres:latest
19+
20+
postgres-rm: ## Stop and remove the postgres container
21+
docker stop algora_db && docker rm algora_db
22+
23+
psql: ## Connect to postgres
24+
docker exec -it algora_db psql -U postgres -d algora_dev

README.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,18 @@ To get a local copy up and running, follow these steps.
112112

113113
### Prerequisites
114114

115-
- PostgreSQL
116-
- [asdf](https://github.com/asdf-vm/asdf) (optional) - install Elixir and Erlang/OTP
117-
- [direnv](https://github.com/direnv/direnv) (optional) - load environment variables
115+
The easiest way to get up and running is to [install](https://docs.docker.com/get-docker/) and use Docker for running Postgres.
116+
117+
Make sure Docker, Elixir, Erlang and Node.js are all installed on your development machine. The [.tool-versions](https://github.com/algora-io/algora/blob/main/.tool-versions) file is available to use with [asdf](https://github.com/asdf-vm/asdf) or similar tools.
118+
119+
We also recommend using [direnv](https://github.com/direnv/direnv) to load environment variables and [entr](https://github.com/eradman/entr) to watch for file changes.
118120

119121
### Setting up the project
120122

121123
1. Clone the repo and go to the project folder
122124

123125
```sh
124-
git clone https://github.com/algora-io/algora.git; cd algora
126+
git clone git@github.com:algora-io/algora.git && cd algora
125127
```
126128

127129
2. Install Elixir and Erlang/OTP
@@ -130,40 +132,28 @@ To get a local copy up and running, follow these steps.
130132
asdf install
131133
```
132134

133-
3. Create a new PostgreSQL user
134-
135-
```sh
136-
sudo -u postgres psql
137-
```
138-
139-
```sql
140-
CREATE USER algora WITH PASSWORD 'password';
141-
ALTER USER algora WITH CREATEDB;
142-
```
143-
144-
4. Initialize and load `.env`
135+
3. Initialize and load `.env`
145136

146137
```sh
147-
cp .env.example .env
148-
direnv allow .env
138+
cp .env.example .env && direnv allow .env
149139
```
150140

151-
5. Install and setup dependencies
141+
4. Install and setup dependencies
152142

153143
```sh
154-
mix setup
144+
make install
155145
```
156146

157-
6. Start your development server
147+
5. Start the web server inside IEx
158148

159149
```sh
160-
iex -S mix phx.server
150+
make server
161151
```
162152

163-
7. (Optional) Watch for file changes and auto reload IEx shell in a separate terminal
153+
6. (Optional) Watch for file changes and auto reload IEx shell in a separate terminal
164154

165155
```sh
166-
find lib/ | entr mix compile
156+
make watch
167157
```
168158

169159
### Setting up external services

0 commit comments

Comments
 (0)