34 Commits

Author SHA1 Message Date
Jamil
34c7013df2 chore(portal): remove priv/Caddyfile (#10708)
This was from an earlier time and is no longer relevant.
2025-10-26 15:57:26 +00:00
Jamil
e4ba5a6929 fix(portal): inherit pid 1 in cmd (#9957)
Apparently using the shell form of this causes it not to inherit PID 1
from tini.
2025-07-21 22:38:25 +00:00
Jamil
9badf1fe7c chore(portal): bump elixir 1.18.4, otp 27.3.4.1 (#9673) 2025-06-25 18:39:20 +00:00
Jamil
42b2420c00 ci(portal): Only set GIT_SHA before main app compile (#8955)
Delaying setting the GIT_SHA until as late as possible allows us to
cache more layers.

Fixes #8774
Related: #8948
2025-05-01 05:15:47 +00:00
Jamil
a93f40befd chore(portal): Bump elixir to 1.18.2 (#8009)
This is mostly to stay up to date with current Elixir and benefit from
the new included [JSON parser](https://hexdocs.pm/elixir/JSON.html).

Removing `Jason` in favor of the embedded `JSON` parser is saved for a
[future PR](https://github.com/firezone/firezone/issues/8011).

It found a couple type violations which were simple to fix, and some
formatting changes.
2025-02-05 23:52:58 +00:00
Jamil
6be7cf6b45 feat(portal): Add Sentry reporting (#8013)
This adds https://github.com/getsentry/sentry-elixir to the portal for
automatic process crash and exception trace reporting.

It also configures Logger reporting for the `warning` level and higher,
and sets the data scrubbing rules to allow all Logger metadata keys
(`logger_metadata.*` in the Sentry project settings).

Lastly, it configures automatic HTTP error reporting by tying into the
`api` and `web` endpoint modules with a custom `plug` middleware so we
get automatic reporting of unsuccessful Phoenix responses.

It is expected this will be noisy when we first deploy and we'll need to
tune it down a bit. This is the same approach used with other Sentry
platforms.
2025-02-04 18:35:52 +00:00
Jamil
a44787cc13 chore(portal): Bump to Alpine 3.20.5 (#8010)
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2025-02-03 23:28:20 +00:00
Jamil
9838cd99c9 chore(portal): Bump erlang to 27.2.1 (#8008)
In preparation for upgrading to Elixir 1.18.
2025-02-03 21:46:00 +00:00
Jamil
bf967f10b2 chore: Use consistent casing for Dockerfile directives (#7823)
Fixes a minor warning Docker complains about during build.
2025-01-21 16:44:20 +00:00
Jamil
53032fcbe1 fix(ci): Populate elixir vsn from env at build time (#7773)
Dependabot's workflow is set up in such a way it seems that it can't
find our `sha.exs` file.

This is a cleaner approach that doesn't rely on using external files for
the application version.

Interesting note: `mix compile` will happily use the cached `version`
even though it's computed from an env var, because `mix compile` uses
file hash and mtime to know when to recompile.

See https://github.com/firezone/firezone/network/updates/942719116
2025-01-16 22:26:22 +00:00
Jamil
2d0fafbc59 chore(ci): Use consistent casing for Docker directives (#7781)
```
 => WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 258)
```
2025-01-16 21:58:06 +00:00
Antoine
7830482ab3 feat(portal): ecs metadata discovery (#6619)
This PR adds support for ECS metadata API
(https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v4.html)
in order to discover hostname.

It also adds jq in the runtime image

Unlike EC2 or GCP VM, ECS tasks do not have a DNS record, we can only
use their IP as RELEASE_HOSTNAME. So I use their IPv4, IPv6 only
networks are therefore not supported.
2024-09-12 12:07:28 -06:00
Andrew Dryga
835fc4c8eb chore(portal): Bump all deps related to portal (#6445) 2024-08-28 10:40:02 -06:00
Andrew Dryga
52d1b07a2a chore(portal): Bump Alpine to 3.20, Erlang/OTP to 27 and Elixir to 1.17 (#5349)
Two blocking issues:
-
57470a1229
to be released (its used by WorkOS package; I think in future we should
contribute to them replacing that with Finch or Req);
- https://github.com/elixir-cldr/cldr_calendars/issues/19
2024-06-24 12:27:19 -06:00
Jamil
16bc9d943b fix(infra): Bump base images to resolve CVEs (#5515)
Fixes the CVEs here:

https://alpinelinux.org/posts/Alpine-3.17.8-3.18.7-3.19.2-released.html

I discovered while browsing our Google artifact registry.
2024-06-24 16:56:55 +00:00
Andrew
67c1425917 Try to fix file permissions issues for Tzdata 2024-06-17 18:10:18 -06:00
Jamil
7e533c42f8 refactor: Split releases for Clients and Gateways (#5287)
- Removes version numbers from infra components (elixir/relay)
- Removes version bumping from Rust workspace members that don't get
published
- Splits release publishing into `gateway-`, `headless-client-`, and
`gui-client-`
- Removes auto-deploying new infrastructure when a release is published.
Use the Deploy Production workflow instead.

Fixes #4397
2024-06-10 16:47:49 +00:00
Jamil
61534f92b0 refactor(elixir): remove telemetry id generation (#5084) (#5095)
Feel free to correct me if I'm wrong but it seems the telemetry id is
not longer used in Firezone 1.x
Removing this uuid generation would allow me to put the folder
`/var/firezone` as readonly instead of mounting a

[volume](367a46a5c8/firezone/values.yaml (L157))
to allow firezone to write inside. The folder `/var/firezone` seems to
be used only for this purpose

Maybe I should also remove

[this](49a965a686/elixir/Dockerfile (L293))
?

PS: I cannot find the contrib branch, but don't hesite to create it and
change the target branch of this PR

Co-authored-by: Antoine <antoinelabarussias@gmail.com>
2024-05-22 12:59:36 -07:00
Andrew Dryga
f3c8c734ab feat(portal): Filtering, Fulltext Search, Pagination, Preloads (#3751)
On the domain side this PR extends `Domain.Repo` with filtering,
pagination, and ordering, along with some convention changes are
removing the code that is not needed since we have the filtering now.
This required to touch pretty much all contexts and code, but I went
through all public functions and added missing tests to make sure
nothing will be broken.

On the web side I've introduced a `<.live_table />` which is as close as
possible to being a drop-in replacement for the regular `<.table />`
(but requires to structure the LiveView module differently due to
assigns anyways). I've updated all the listing tables to use it.
2024-03-16 13:27:48 -06:00
Andrew Dryga
52b284abd9 Terraform improvements for production (#2873) 2023-12-11 19:41:01 -06:00
Andrew Dryga
42bbafc04d Merge firezone/containers into elixir/Dockerfile for better reuse and maintainability (#2267)
Upsides:
1. We don't need to maintain a separate repo and Dockerfile just for
Elixir image (permissions, runner labels, etc)
2. No need to push intermediate images to the container registry
3. No need to copy-paste alpine/erlang/elixir version and hashes from
`firezone/containers` to `elixir/dockerfile` every time they change
4. No need to cross-compile for local dev environments, better
experience building with slow internet connection
5. One command to test if our code works on our containers but a
different alpine/erlang/elixir version

Downsides:
1. Locally devs will need to compile Erlang at least once per version,
but the whole build takes ~6 minutes on my M1 Max. It also takes only 8
minutes on the free GitHub Actions runner without any cache.
2. Worse experience on slow machines

FYI: there is no performance penalty once we have cache layers, still
takes 30 seconds on CI.
2023-10-06 15:34:47 -06:00
Andrew Dryga
c5ccef88f7 Copy entire project sooner 2023-10-06 14:17:17 -06:00
Andrew Dryga
5cd1465f85 Copy web/lib for the assets pipeline 2023-10-06 14:08:40 -06:00
Andrew Dryga
8c219c64c9 Add curl to the runtime image 2023-10-06 08:35:03 -06:00
Andrew Dryga
205f95bcfb Allow default user to write to /var/firezone 2023-10-06 08:21:36 -06:00
Andrew Dryga
e5fff809c0 Streamline apps versioning for Elixir and Terraform (#2257) 2023-10-05 20:29:25 -07:00
Jamil
80234f9c71 Github Actions cache on main and scope caches for all languages/runtimes (#2233) 2023-10-04 17:29:04 -07:00
Jamil
d27da5ee3d Fix cache for Docker buildx (#1750)
~~This is an attempt to fix the CI bug
[here](https://github.com/firezone/firezone/actions/runs/5491388141/jobs/10007864417#step:4:1638)
possibly introduced in
[d9eb2d18](https://github.com/firezone/firezone/commit/d9eb2d18#diff-88bd94db0d5cfd5f0617b7c4ed48c0212597378ed7e28714c5d86c95999b4c7dR29)
and uncovered / exacerbated in Elixir 1.15~~

Edit: looks like this ended up being a couple cache issues with GitHub
actions:
1. The `elixir_api-container-build` cache would always overwrite the
`elixir_web-container-build` on subsequent builds of the same
`github.ref_name` (cache is scoped to branch name by default), leading
to the consistent error `Elixir.Web.Mailer.NoopAdapter does not exist`
whenever a branch was pushed to more than once.
2. The same thing happens with the `integration_test-basic-flow` job
because the `api` service gets built after the `web` service in
docker-compose.yml, overwriting its cache

For some reason it seems the `APPLICATION_NAME` ARG is not busting the
Docker cache properly on GitHub actions for elixir container builds, so
the fix here was to [use
`scope=`](https://docs.docker.com/build/cache/backends/gha/#scope) to
segregate the cache layers between builds of the same branch.
2023-07-10 17:30:09 +00:00
Andrew Dryga
0528c6fc18 Bump versions in Dockerfile 2023-07-04 10:01:15 -06:00
Andrew Dryga
e7d5d0579b Authentication for the live app (#1674)
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-06-27 13:11:36 -06:00
Jamil
0faf8d906c Add pnpm to runners (#1683)
Found another place where pnpm needs to be added.
2023-06-23 12:42:35 -05:00
Jamil
8d8687224b Use pnpm over yarn (#1678)
Did some research when picking a package manager for the website and
settled on `pnpm` for the following reasons:

- CLI-compatible with `npm`
- Typically faster than even `yarn` especially on Apple silicon
- Security: Pnpm uses a different dependency resolution algorithm and
different folder structure of node_modules that prevents illegal access
to packages by other packages.

I think I caught all the places, but I may be missing something, so if
this isn't a good idea we can revert back.

This PR also cleans up the actions workflows to remove dead code.
2023-06-22 10:40:32 -07:00
Andrew Dryga
d9eb2d18df Deployment for the cloud version (#1638)
TODO:
- [x] Cluster formation for all API and web nodes
- [x] Injest Docker logs to Stackdriver
- [x] Fix assets building for prod

To finish later:
- [ ] Structured logging:
https://issuetracker.google.com/issues/285950891
- [ ] Better networking policy (eg. use public postmark ranges and deny
all unwanted egress)
- [ ] OpenTelemetry collector for Google Stackdriver
- [ ] LoggerJSON.Plug integration

---------

Signed-off-by: Andrew Dryga <andrew@dryga.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-06-06 15:03:26 -06:00
Andrew Dryga
37a2d7b7f5 Move elixir code to a subfolder (#1631) 2023-05-24 15:46:51 -06:00