src Change sql backend to postgres 10 months ago
terraform Split terraform into multiple files 10 months ago
.dockerignore Change sql backend to postgres 10 months ago
.env.example Change sql backend to postgres 10 months ago
.gitignore Remove old sqlite db, oops 10 months ago
.prettierignore Initial commit 10 months ago
.prettierrc.json Initial commit 10 months ago
Dockerfile Initial commit 10 months ago
README.md Add readme 10 months ago
bun.lockb Change sql backend to postgres 10 months ago
deploy.sh Initial commit 10 months ago
docker-compose.local.yml Change sql backend to postgres 10 months ago
drizzle.config.ts Change sql backend to postgres 10 months ago
package.json Change sql backend to postgres 10 months ago
tsconfig.json Initial commit 10 months ago
README.md

Bun + hono + drizzle + gcp

This is a proof of concept for the following technologies:

Live version: https://hono-app-mkulnruqtq-ey.a.run.app/

Development

To work locally, first install bun and then all the dependencies. For the database you can use the docker-compose file.

bun install

# copy env variables and set them accordingly
cp .env.example .env
docker-compose -f docker-compose.local.yml up -d

bun run dev

Infrastructure

The terraform file and therefore the deployment consists of the following three main services:

  • Artifact Registry
    • Used to store the docker image for Cloud Run
    • Images can be pushed by hand (or ideally by CI/CD)
  • Cloud Run
    • This is the runtime of this webserver
    • It runs docker images and is publicly exposed
    • HTTPS and Domain per default
  • Cloud SQL
    • Postgres database
    • There is an admin user, it can be used to connect to it from the internet

Deployment

Infrastructure changes will be applied by terraform, each Cloud Run Revision can be triggered by hand (or ideally by CI/CD).

To get started, make sure the gcloud client as well as the docker login is installed.

First deployment

There is a 60-second delay between the creation of the Artifact Registry and Cloud run, this is because Cloud Run requires the Docker image to already be present. So use this time to push the first version.

New revision

To deploy a new revision, execute bun run deploy or bash deploy.sh. This will first build an image, pushes it to the Registry and then triggers a new revision on Cloud Run.

Terraform state

The terraform state is currently stored local. To enable collaboration, this should be stored in a central storage bucket.