Skip to content

Commit eee0d0e

Browse files
committed
tools: Add Guix & Compose as development setup options.
1 parent c1b2576 commit eee0d0e

3 files changed

Lines changed: 96 additions & 13 deletions

File tree

README.md

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Zout [![Elixir CI](https://github.com/ZeusWPI/ZOUT/actions/workflows/elixir.yml/badge.svg)](https://github.com/ZeusWPI/ZOUT/actions/workflows/elixir.yml) [![Coverage Status](https://coveralls.io/repos/github/ZeusWPI/ZOUT/badge.svg?branch=master)](https://coveralls.io/github/ZeusWPI/ZOUT?branch=master)
22

3-
Het Zeus Overzicht met Uitgebreide Toestanden ("Zeus Overview with Extensive)
3+
Het Zeus Overzicht met Uitgebreide Toestanden ("Zeus Overview Using exTensive states")
44

55
The aim of this project is to provide an "uptime monitor" for Zeus projects.
66
Why use an existing solution, when you can build it yourself?
@@ -9,35 +9,77 @@ Anyway, this application is rather simple.
99
It has a list of projects, for which it pings some URL every X time, and saves the result in a big PostgreSQL table (we use TimescaleDB, so we can save all the things).
1010
We then show this with a simple UI.
1111

12-
## Installing dev environment
12+
## Setting up a dev environment
13+
14+
> Note: Once the server runs, it will ping registered services every minute or so, so don't leave it running too long in the background.
15+
16+
Combine any of the following:
17+
18+
### Nix (everything)
1319

1420
Enlightened people can use the nix flake.
15-
Others need to search how to install:
21+
22+
After setting up the database, run the webserver as follows:
23+
24+
```console
25+
mix setup
26+
mix phx.server
27+
```
28+
29+
Now, visit [http://localhost:4000](http://localhost:4000)
30+
31+
### Guix (everything except database)
32+
33+
Slightly more enlightened people can run the webserver like this:
34+
35+
```console
36+
guix shell -mmanifest.scm -CFN -ETERM -- sh -c "mix setup; mix phx.server"
37+
```
38+
39+
Now, visit [http://localhost:4000](http://localhost:4000)
40+
41+
### Others (everything except database)
42+
43+
Install the following:
1644

1745
- Elixir 1.19
18-
- PostgreSQL 17 with TimescaleDB extension
1946
- Node.js 24
2047

21-
Then, to start your Phoenix server:
48+
Start the webserver:
49+
50+
```console
51+
mix setup
52+
mix phx.server
53+
```
54+
55+
Now, visit [http://localhost:4000](http://localhost:4000)
2256

23-
* Install asset dependencies with `cd assets && npm install`
24-
* Install dependencies with `mix deps.get`
25-
* Create and migrate your database with `mix ecto.setup`
26-
* Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
57+
### Docker/Podman (database only)
2758

28-
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
29-
Note that once the server runs, it will ping registered services every minute or so,
30-
so don't leave it running too long in the background.
59+
Start a development postgres, accessible on `postgresql://postgres:postgres@localhost` :
60+
61+
```console
62+
podman compose -fdocker-compose.dev.yml up -d --build
63+
```
64+
65+
### Others (database only)
66+
67+
Set up a PostgreSQL 17 with the TimescaleDB extension.
68+
Make sure it's accessible on: `postgresql://postgres:postgres@localhost`
3169

3270
## Deployment
3371

72+
> Note: This is done automatically upon pushing to master.
73+
>
74+
> See [workflows/deploy.yml](.github/workflows/deploy.yml) and [deploy.ssh](deploy.ssh).
75+
3476
1. SSH to the server
3577
2. Pull the repo
3678
3. Take the application down with `podman-compose down`.
3779
4. Build a new docker image with `podman-compose build`
3880
5. Start the application with `podman-compose up -d`
3981

40-
## Learn more
82+
## Learn more about the Phoenix framework
4183

4284
* Official website: https://www.phoenixframework.org/
4385
* Guides: https://hexdocs.pm/phoenix/overview.html

docker-compose.dev.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
database:
3+
image: docker.io/timescale/timescaledb:latest-pg17
4+
restart: unless-stopped
5+
environment:
6+
POSTGRES_USER: postgres
7+
POSTGRES_PASSWORD: postgres
8+
ports:
9+
- "127.0.0.1:5432:5432"
10+
volumes:
11+
- zout-dev-database:/var/lib/postgresql/data
12+
13+
volumes:
14+
zout-dev-database:

manifest.scm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(use-modules (guix channels)
2+
(guix inferior)
3+
(guix profiles)
4+
(guix ui)
5+
(srfi srfi-11)
6+
(srfi srfi-26))
7+
8+
(define (pkgs channels specs)
9+
(let* ((inferior (inferior-for-channels channels))
10+
(lookup (cut lookup-inferior-packages inferior <> <>)))
11+
(map (lambda (spec)
12+
(let-values (((name version output)
13+
(package-specification->name+version+output spec)))
14+
(list (car (lookup name version))
15+
output)))
16+
specs)))
17+
18+
(packages->manifest
19+
(pkgs (list (channel
20+
(inherit %default-guix-channel)
21+
(commit "71ffb948b32b361d02ec0781e25f1e8f8f5aea75")))
22+
(list "bash"
23+
"coreutils" "findutils" "sed" "grep"
24+
"elixir@1.19" "erlang@27" "inotify-tools"
25+
"pgcli"
26+
"node@22"
27+
"nss-certs")))

0 commit comments

Comments
 (0)