Files
BeetRoundServer/README.md

132 lines
3.0 KiB
Markdown
Raw Permalink Normal View History

2026-01-20 11:03:54 +01:00
# BeetRoundServer
To start your Phoenix server:
- Run `mix setup` to install and setup dependencies
- Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
2026-01-20 11:03:54 +01:00
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).
# Configure for deployment environment
Replace beetround.example.com in prod.exs for "url" & "check_origin"
TODO: verify that "url" replacement in config.exs ins't necessary (should be overruled by prod.exs, right?)
# Deployment on new uberspace asteroid
2026-01-20 11:03:54 +01:00
## Initial deployment
### Add subdomain
`uberspace web domain add beetround.example.com`
### Init database
Follow guide to initialize postgresql database:
https://lab.uberspace.de/guide_postgresql/
#### Configure database
`createuser beetround_admin -P`
`createdb --encoding=UTF8 --owner=beetround_admin --template=template0 beetround_server`
## Configure Elixir/Phoenix
`uberspace tools version use erlang 27`
## Build & run BeetRound
`cd ~/`
`mkdir develop`
`git clone https://git.working-copy.org/bent/BeetRoundServer.git`
`cd develop`
`export MIX_ENV=prod`
`mix deps.get`
`mix phx.gen.secret`
`export SECRET_KEY_BASE=<SECRET_KEY>`
`export DATABASE_URL=ecto://beetround_admin:<DB_PASSWORD>@localhost/beetround_server`
`mix assets.deploy` #throws "'mix tailwind beet_round_server --minify' exited with 1" error
Workaround: copy assets from develop machine
`mix compile`
`PHX_HOST=beetround.example.com PORT=4005 mix ecto.migrate`
### Create webbackend
`uberspace web backend set beetround.example.com --http --port 4005`
#### Test backend
`PHX_HOST=beetround.example.com PORT=4005 mix phx.server`
#### Create mix release
`mix release`
### Create service
Create service file:
`~/etc/services.d/beetround_server.ini:`
```
[program:beetround_server]
command=%(ENV_HOME)s/develop/BeetRoundServer/_build/prod/rel/beet_round_server/bin/beet_round_server
directory=%(ENV_HOME)s/develop/BeetRoundServer
autostart=true
autorestart=true
startsecs=60
environment =
MAIL_RELAY="<UBERSPACE_ASTEROID>.uberspace.de",
MAIL_ADDRESS="<MAIL_ADDRESS>",
MAIL_PW="<MAIL_PASSWORD>",
PHX_HOST="beetround.example.com",
MIX_ENV=prod,
PORT=4005,
DATABASE_URL="ecto://beetround_admin:<DB_PASSWORD>@localhost/beetround_server",
SECRET_KEY_BASE=<SECRET_KEY>
```
`supervisorctl reread`
`supervisorctl update`
`supervisorctl status`
## Updates (TODO old content. needs to be adjusted/checked)
Steps on develop environment:
- create new release version (with git flow)
- push main branch to repo
Steps on server:
- cd develop/SplitPot/
- pull main branch
- mix deps.get --only prod
- MIX_ENV=prod mix assets.deploy
- export BUILD_DATE="DD.MM.YYYY"
- MIX_ENV=prod mix release
- supervisorctl stop splitpot_server
- DB migrations
- export DATABASE_URL=...
- export SECRET_BASE_KEY=...
- MIX_ENV=prod mix ecto.migrate
- supervisorctl start splitpot_server