psychedel / thundermoon-umbrella

some simulation examples using phoenix live view

Home Page:https://thundermoon.zero-x.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Codacy Badge

Thundermoon.Umbrella

This is a collection of examples using phoenix live view. The state is hold in memory and broadcasted to all clients. The examples include a simple chat, a counter and Conways Game of Life.

Changelog

Umbrella App

Docker

to start the application in a docker container

first copy and rename the files in .env to app and db.

set the corresponding values in those files and then run:

docker build -t thundermoon:app --target=app .
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 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

Testing

Cypress

Install

npm install cypress

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

npm run cypress

start testing ....

Release

manually test release can be built

MIX_ENV=prod mix phx.digest
MIX_ENV=prod mix release

export SECRET_KEY_BASE=REALLY_LONG_SECRET
export DATABASE_URL=ecto://<user>:<password>@localhost/thundermoon_dev

_build/dev/rel/my_app/bin/my_app 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=<container_tag> deploy.sh

Debug

ssh into production server, then

docker ps
docker exec -it <container-id> sh
./bin/thundermoon_umbrella remote
:observer_cli.start()

Send Test Error

SENTRY_DSN=https://12345@sentry.io/123 MIX_ENV=prod mix sentry.send_test_event

Semaphore

set dockerhub credentials as semaphore secrets

sem create secret dockerhub-secrets \
  -e DOCKER_USERNAME=<your-dockerhub-username> \
  -e DOCKER_PASSWORD=<your-dockerhub-password>

set app specific credentials

sem create secret thundermoon-secrets \
  -e DB_PASSWORD=<password> \
  -e SECRET_KEY_BASE=<secret> \
  -e SECRET_LIVE_VIEW_KEY=<secret> \
  -e SENTRY_DSN=<secret> \
  -e GITHUB_CLIENT_ID=<secret> \
  -e GITHUB_CLIENT_SECRET=<secret>

add deploy-key containing the private key to the secrets and add the pub key to the deploy server

sem create secret deploy-key -f ~/.ssh/id_rsa_semaphoreci:/home/semaphore/.keys/deploy-key

About

some simulation examples using phoenix live view

https://thundermoon.zero-x.net

License:MIT License


Languages

Language:Elixir 60.0%Language:CSS 26.4%Language:JavaScript 7.1%Language:HTML 3.7%Language:Dockerfile 1.5%Language:Shell 1.3%