-
Notifications
You must be signed in to change notification settings - Fork 6
/
DEPLOYMENT_NOTES.txt
71 lines (65 loc) · 4.28 KB
/
DEPLOYMENT_NOTES.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Note: Not all Erlang/Elixir versions are supported out of the box. Have to check this:
https://github.com/HashNuke/heroku-buildpack-elixir/blob/master/README.md#version-support
You will get errors on deployment if you select an incompatible version via the buildpack config.
NOTES ON DOWNGRADING
Make sure to rm -rf BOTH the deps AND _build dirs.
If you are using apt to manage the dep and want to hold it, use `sudo apt-mark [un]hold esl-erlang`
and to look at held packages use `apt-mark showhold`
Docker build command:
docker build -t mpnetwork \
--target=$MIX_ENV \
--build-arg APP_NAME_ARG=$APP_NAME \
--build-arg MIX_ENV_ARG=$MIX_ENV \
--build-arg SECRET_KEY_BASE_ARG=$SECRET_KEY_BASE \
--build-arg LIVE_VIEW_SIGNING_SALT_ARG=$LIVE_VIEW_SIGNING_SALT \
--build-arg SPARKPOST_API_KEY_ARG=$SPARKPOST_API_KEY \
--build-arg FQDN_ARG=$FQDN \
--build-arg STATIC_URL_ARG=$STATIC_URL \
--build-arg LOGFLARE_API_KEY_ARG=$LOGFLARE_API_KEY \
--build-arg LOGFLARE_DRAIN_ID_ARG=$LOGFLARE_DRAIN_ID \
--build-arg DATABASE_URL_ARG=$DATABASE_URL \
--build-arg TEST_DATABASE_URL_ARG=$TEST_DATABASE_URL \
--build-arg OBAN_LICENSE_KEY_ARG=$OBAN_LICENSE_KEY \
.
Docker run command (name must be unique among running containers, if not kill the previous one):
docker run -it --name=mpnetwork_web --env-file=.env --network=host -p 4000:4000 -v $PWD:/app mpnetwork
HOW TO SET UP THE APP USING NIX IF YOU JUST CLONED IT AND ARE INSIDE THE DIRECTORY
----------------------------------------------------------------------------------
0) Install Nix in a multiuser setup (or use NixOS) and enable flakes.
(See flake.nix and shell.nix for the app-specific Nix config details. Still a WIP.)
1) Make sure the PG_DATA env var points to .pgdata in the project directory. Direnv should have ensured this
(you may need to decrypt .env.gpg to .env, possibly)
2) Run `nix develop`. Nix does a bunch of PFM work to get all your external app deps in place.
3) Run `initdb`. (The .pgdata directory must be empty. And exist.)
4) Run `dbgo` (an alias I set up via direnv to start the server. `dbno` stops it.)
5) Run `psql -d postgres` and then `\du` in there to see who the admin user is. Probably your username.
The rest of these instructions assume it's your username, which is now Nix sets it up.
You're going to want to create a postgres user. (Control-D to exit.)
6) Run `sudo --preserve-env -u $USER psql postgres $USER`. You need --preserve-env (or -E) or else your env vars
that point to the correct DB socket file will fail to work through `sudo`.
7) While in there, run these sql commands to fix db `postgres` being owned by $USER:
CREATE USER postgres SUPERUSER;
ALTER DATABASE postgres OWNER TO postgres;
(Control-D to exit.)
8) Run `mix deps.get`. For Oban you'll need a separate setup that is provided when you log into getoban.pro.
9) Run `mix ecto.create` and then `mix ecto.migrate`. The migrations will run.
10) Run `mix run priv/repo/seeds.exs`. This will seed the dev DB with a basic admin login and default office.
11) Run `mix test`. The migrations on the test DB should run automatically and then the tests should run and PASS!
12) Run `npm install` (It's possible you have your custom bin/npm wrapper in PATH which prevents you from
having to `cd assets` first. But if you don't, do that first.)
12) Run `mix test_js`. See bugs and security issues. Sad. #NEEDSFIX
To run both test suites with 1 command to get a combined success/fail, run `test/test`.
Other notes:
Cloud logging is provided by Logflare. I paid for lifetime access.
UptimeRobot checks down/up status. (I used to use Pingdom, but then they got bought out.)
The app used to use Travis CI, but then they stopped their free tier for open-source projects thanks to crypto miners.
...I haven't come up with another CI solution yet.
Harvestapp.com for invoicing, proposify for proposals.
Dynadot runs the domain.
Sparkpost runs the email.
Staging and prod DB's are hosted by Google Cloud Postgres.
Currently, gigalixir does the deploys, but I want to move to something else ASAP due to cost concerns.
The original Phase 1 project to-do list is here:
https://docs.google.com/spreadsheets/d/1M97cq0kvvXwBL0tNDe5UoNazKxuQfTdQGQNux1pSx7o/edit?usp=sharing
The Phase 2 project to-do list is here:
https://docs.google.com/spreadsheets/d/1KT8FH8hQaszr1FE9I84WHVBHcP1NwMcgaqy2GWATNWw/edit?usp=sharing