bldg14 / eventual

A simple event calendar
https://eventual-client.fly.dev
MIT License
0 stars 0 forks source link

Setup auto deploy for client #38

Closed kevinfalting closed 11 months ago

kevinfalting commented 11 months ago

Overview

This enables the auto-deploy to fly.io of our client as a separate image from the server.

Related Issues / PRs

Resolves: #37

Thought Process

I attempted to make a distroless build of this, but that ended up being a little more complex than I liked and I couldn't get it to work on the fly servers. I've documented that journey in the linked issue. Otherwise, this uses an official non-privileged version of the nginx image to serve the static files.

I went through a few different iterations of how I might serve the client. Since the production build of the client results in static files, I decided to use nginx to serve these files from a directory. I utilized a multi-step build Dockerfile for this so the resulting image is only what nginx requires to run. There are still some debugging utilities in the image that should be removed, but that's a task for another time.

The create-react-app deployment docs seem to suggest using https://www.npmjs.com/package/serve package, and perhaps we will move to that some day, but I decided to use nginx for now. I was having trouble building a distroless image that used that package so it got skipped.

Testing Steps

You can build and run locally:

$ docker build -t eventual.client -f Dockerfile.client .
$ docker run -it --rm -p 8080:8080 eventual.client

Then navigate to http://localhost:8080

Or you can deploy to fly.io:

$ flyctl deploy --remote-only --config ./fly.client.toml

Then navigate to https://eventual-client.fly.dev/

Since I've updated the server name in it's fly.server.toml file, you can also deploy it via:

$ flyctl deploy --remote-only --config ./fly.server.toml

And navigate to https://eventual-server.fly.dev/api/v1/events

Risks

This is low risk, I expect the deploy to happen on merge to main and there be no problems, but if there are, we'll check out the logs and fix it.