https://github.com/grrrisu/thundermoon-umbrella
some simulation examples using phoenix live view
https://github.com/grrrisu/thundermoon-umbrella
elixir hacktoberfest lotka-volterra phoenix-framework phoenix-live phoenix-live-view
Last synced: 5 months ago
JSON representation
some simulation examples using phoenix live view
- Host: GitHub
- URL: https://github.com/grrrisu/thundermoon-umbrella
- Owner: grrrisu
- License: mit
- Created: 2019-05-31T14:47:35.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2025-10-25T07:01:36.000Z (8 months ago)
- Last Synced: 2025-10-25T08:26:14.347Z (8 months ago)
- Topics: elixir, hacktoberfest, lotka-volterra, phoenix-framework, phoenix-live, phoenix-live-view
- Language: Elixir
- Homepage: https://thundermoon.zero-x.net
- Size: 4.09 MB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine)
[](https://thundermoon.semaphoreci.com/badges/thundermoon-umbrella.svg?style=semaphore)
[](https://www.codacy.com/gh/grrrisu/thundermoon-umbrella/dashboard?utm_source=github.com&utm_medium=referral&utm_content=grrrisu/thundermoon-umbrella&utm_campaign=Badge_Grade)
# Thundermoon.Umbrella

_image: Thunderbird Moon by Joe Wilson-Sxwaset_
This is a collection of examples using [phoenix live view](https://github.com/phoenixframework/phoenix_live_view).
The state is hold in memory and broadcasted to all clients.
The examples include a simple chat, a counter, [Conways Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) and [Lotka-Volterra](https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations).
[Changelog](./changelog.md)
## Umbrella Apps
- [Thundermoon](apps/thundermoon/README.md)
- [ThundermoonWeb](apps/thundermoon_web/README.md)
- [Sim Library](apps/sim/README.md)
- [Game of Life](apps/game_of_life/README.md)
- [Lotka Volterra](apps/lotka_volterra/README.md)
## Docker
to start the application in a docker container
first copy and rename the files in `.env_files` to `app` and `db`.
set the corresponding values in those files and then run:
```shell
docker build -t thundermoon:build .
docker build -t thundermoon:app --target=app -f .semaphore/Dockerfile_release .
IMAGE=thundermoon:app docker-compose up
```
stop application
```
docker-compose down
```
## Developement
### Setup
To start the application
- Copy `config/dev.secret.example.exs` to `config/dev.secret.exs` and replace ueberauth `client_id` and `client_secret` with your Github App credentials
- Install dependencies with `mix deps.get`
- Create and migrate your database with `mix do ecto.create, ecto.migrate`
- Install Node.js dependencies with `cd apps/thundermoon_apps/assets && npm install`
- Start Phoenix endpoint with `mix phx.server`
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
### Migration
to create a migration issue the command in `app/thundermoon` directory and specify the repo
`mix ecto.gen.migration create_user -r Thundermoon.Repo`
### New Sub Application
go to `./apps`and issue the mix new command like this:
`mix new lotka_volterra --module LotkaVolterra --sup`
copy the new `mix.exs` file to the docker container in the `Dockerfile` line 15 (section _install dependencies_)
### Testing
#### Cypress
##### Install
`npm install -g cypress@4.5.0`
```shell
MIX_ENV=integration mix do ecto.create, ecto.migrate, run apps/thundermoon/priv/repo/seeds.exs
```
##### Run
run the application
`MIX_ENV=integration mix phx.server`
start the cypress Test Runner in `app/thundermoon_web/assets`
`npm run cypress`
start testing ....
##### Docker
Run cypress with docker
`docker build -t thundermoon:build .`
`docker build -t thundermoon:integration -f .semaphore/Dockerfile_integration .`
`IMAGE="thundermoon:integration" docker-compose -f .semaphore/docker-compose.integration.yml up --abort-on-container-exit --exit-code-from browser`
### Release
manually a test release can be built
```shell
MIX_ENV=prod mix esbuild default --minify
MIX_ENV=prod mix phx.digest
MIX_ENV=prod mix release
export SECRET_KEY_BASE=REALLY_LONG_SECRET
export DATABASE_URL=ecto://:@localhost/thundermoon_dev
_build/dev/rel/thundermoon_umbrella/bin/thundermoon_umbrella eval "Thundermoon.Release.migrate"
_build/prod/rel/thundermoon_umbrella/bin/thundermoon_umbrella start
```
## Production
stop docker stack
`docker stack rm thundermoon`
restart docker swarm
`TAG= deploy.sh`
show all services
```
docker service ls
```
see details of one service
```
docker service ps --no-trunc thundermoon_app
```
### Debug
ssh into production server, then
```shell
docker ps
docker exec -it sh
./bin/thundermoon_umbrella remote
```
```elixir
:observer_cli.start()
```
### Send Test Error
```shell
SENTRY_DSN=https://12345@sentry.io/123 MIX_ENV=prod mix sentry.send_test_event
```
## Semaphore
set dockerhub credentials as semaphore secrets
```shell
sem create secret dockerhub-secrets \
-e DOCKER_USERNAME= \
-e DOCKER_PASSWORD=
```
set app specific credentials
```shell
sem create secret thundermoon-secrets \
-e DB_PASSWORD= \
-e SECRET_KEY_BASE= \
-e SECRET_LIVE_VIEW_KEY= \
-e SENTRY_DSN= \
-e GITHUB_CLIENT_ID= \
-e GITHUB_CLIENT_SECRET= \
-e SSH_USER_AT_HOST=
```
add `deploy-key` containing the private key to the secrets and add the pub key to the deploy server
```shell
sem create secret deploy-key -f ~/.ssh/id_rsa_semaphoreci:/home/semaphore/.keys/deploy-key
```