Skip to content

Commit

Permalink
Update Deno
Browse files Browse the repository at this point in the history
Also update documentation for easier/quicker self-hosting according to suggestions on #8
  • Loading branch information
BrunoBernardino committed Feb 16, 2025
1 parent 72c98a5 commit d2f8ece
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.do
.github
.git
.gitignore
Caddyfile
docker-compose*
Dockerfile
Makefile
render.yaml
2 changes: 1 addition & 1 deletion .dvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.2
2.1.9
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM denoland/deno:alpine-2.1.2
FROM denoland/deno:alpine-2.1.9

EXPOSE 8000

RUN apk add bash make

WORKDIR /app

# Prefer not to run as root.
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ It's not compatible with Budget Zen v2 ([end-to-end encrypted via Userbase](http

[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/BrunoBernardino/budgetzen-web)

Or check the [Development section below](#development).
Or on your own machine:

> **NOTE:** You don't need to have emails (Brevo) and subscriptions (Stripe) setup to have the app work. Those are only used for allowing others to automatically manage their account. You can simply make any `user.status = 'active'` and `user.subscription.expires_at = new Date('2100-01-01')` to "never" expire, in the database, directly.
Download/copy [`docker-compose.yml`](/docker-compose.yml) and [`.env.sample`](/.env.sample) as `.env`.

```sh
$ docker compose up -d # makes the app available at https://localhost
$ docker compose run --rm website bash -c "cd /app && make migrate-db" # initializes/updates the database (only needs to be executed the first time and on any updates)
```

> [!NOTE]
> You don't need to have emails (Brevo) and subscriptions (Stripe) setup to have the app work. Those are only used for allowing others to automatically manage their account. You can simply make any `user.status = 'active'` and `user.subscription.expires_at = new Date('2100-01-01')` to "never" expire, in the database, directly.
Alternatively, check the [Development section below](#development).

## Framework-less

Expand All @@ -39,7 +49,7 @@ Don't forget to set up your `.env` file based on `.env.sample`.
## Development

```sh
$ docker compose up # (optional) runs docker with postgres, locally
$ docker compose -f docker-compose.dev.yml up # (optional) runs docker with postgres, locally
$ sudo caddy run # (optional) runs an https proxy for the deno app
$ make migrate-db # runs any missing database migrations
$ make start # runs the app
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
postgresql:
image: postgres:15
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=fake
- POSTGRES_DB=budgetzen
restart: on-failure
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- 5432:5432
ulimits:
memlock:
soft: -1
hard: -1

volumes:
pgdata:
driver: local
46 changes: 42 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ services:
postgresql:
image: postgres:15
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=fake
- POSTGRES_DB=budgetzen
restart: on-failure
- POSTGRES_USER=${POSTGRESQL_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRESQL_PASSWORD:-fake}
- POSTGRES_DB=${POSTGRESQL_DBNAME:-budgetzen}
volumes:
- pgdata:/var/lib/postgresql/data
ports:
Expand All @@ -14,7 +13,46 @@ services:
memlock:
soft: -1
hard: -1
restart: unless-stopped

website:
image: ghcr.io/brunobernardino/budgetzen-web:main
# If you want to build the image locally, uncomment the following lines and comment the image line above
# build:
# context: .
# dockerfile: Dockerfile
ports:
- ${PORT:-8000}:8000
restart: unless-stopped
environment:
- BASE_URL=${BASE_URL:-https://localhost}
- POSTGRESQL_HOST=${POSTGRESQL_HOST:-postgresql}
- POSTGRESQL_USER=${POSTGRESQL_USER:-postgres}
- POSTGRESQL_PASSWORD=${POSTGRESQL_PASSWORD:-fake}
- POSTGRESQL_DBNAME=${POSTGRESQL_DBNAME:-budgetzen}
- POSTGRESQL_PORT=${POSTGRESQL_PORT:-5432}
- POSTGRESQL_CAFILE=${POSTGRESQL_CAFILE:-}
- BREVO_API_KEY=${BREVO_API_KEY:-}
- STRIPE_API_KEY=${STRIPE_API_KEY:-}

# any non-empty value will be considered true
- IS_UNSAFE_SELF_HOSTED="true"

depends_on:
- postgresql
- caddy

caddy:
image: caddy:2-alpine
restart: unless-stopped
command: caddy reverse-proxy --from https://localhost:443 --to http://website:8000
ports:
- 443:443
volumes:
- caddy:/data

volumes:
pgdata:
driver: local
caddy:
driver: local

0 comments on commit d2f8ece

Please sign in to comment.