From 5ac660838a67d626aa445f776aad8e4f485d245c Mon Sep 17 00:00:00 2001 From: William Perron Date: Thu, 24 Oct 2024 14:59:36 -0400 Subject: [PATCH] initial commit --- .gitignore | 8 +++++++ Caddyfile | 28 +++++++++++++++++++++++ Dockerfile | 14 ++++++++++++ README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++ fly.toml | 41 ++++++++++++++++++++++++++++++++++ static/404.html | 9 ++++++++ static/index.css | 4 ++++ static/index.html | 9 ++++++++ static/robots.txt | 2 ++ 9 files changed, 172 insertions(+) create mode 100644 .gitignore create mode 100644 Caddyfile create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 fly.toml create mode 100644 static/404.html create mode 100644 static/index.css create mode 100644 static/index.html create mode 100644 static/robots.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d89383 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/node_modules/ +/public/build/ +/public/ + +.DS_Store +public/posts.json + +config-prod.toml diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..a13bc7e --- /dev/null +++ b/Caddyfile @@ -0,0 +1,28 @@ +http://localhost, http://babypool.lol, http://babypool-lol.fly.dev { + bind 0.0.0.0 + root * /usr/share/caddy/babypool.lol + file_server + encode gzip + header orig-server Caddy + + basic_auth { + wperron $2y$10$79.4ujIzCrSY9kAVUrjjNu.cZ1nShU2Y8.AkoxRzNv4DhhuRRy2.e + } + + log { + output file /var/log/caddy.log { + roll_uncompressed + roll_keep_for 168h # 7d + } + format json { + time_format rfc3339 + time_local + duration_format nano + } + } +} + +:9091 { + bind 0.0.0.0 + metrics /metrics +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..244b7b6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Download Caddy binary from GitHub releases +FROM ubuntu:24.04 as caddy_downloader +WORKDIR /dl +RUN apt update && apt install -y curl +RUN curl -sL -o caddy_2.8.4_linux_amd64.tar.gz https://github.com/caddyserver/caddy/releases/download/v2.8.4/caddy_2.8.4_linux_amd64.tar.gz +RUN tar -xzf caddy_2.8.4_linux_amd64.tar.gz && mv caddy /usr/local/bin + +FROM ubuntu:24.04 +WORKDIR /build +RUN apt update && apt install -y tzdata net-tools && apt clean +COPY --from=caddy_downloader /usr/local/bin/caddy /usr/local/bin/caddy +COPY ./static /usr/share/caddy/babypool.lol +COPY ./Caddyfile /etc/caddy/Caddyfile +CMD ["caddy", "run", "--config=/etc/caddy/Caddyfile", "--adapter=caddyfile"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..c466160 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Babypool.lol + +An _anonymous_ baby pool website. + +## How it works + +You create a new new pool, choose the games you want to include and that's it. +No need to register, enter an email or a password or anything like that. Each +pool is given an ID that you can share with whoever you want to participate, you +can optionally select a password to make sure no strangers participate, and you +are given a unique token that gives you access to see the pool's entries and +select a winner. For participants, you need to include an email address so that +you can be contacted if you win, but there's no validation step involved, and +the email addresses are purged when a pool is closed, or at most 3 months after +the expected end date has passed. + +## Games Included + +You can choose whichever games you want to include in the pool, with a minimum +of one selected of course. + +- Date +- Time of Day +- Weight +- Height +- Biological Sex + +## Technical details + +There are two tables: Pools, and Pool Entries. + +Pools table: +| Column Name | Type | Constraints | +| ----------- | -------- | ----------- | +| ID | ULID | Unique | +| admin token | String | | +| password | bcrypt | | +| games | []String | | + +`games` must a Set containing, from these possible values: `DAY`, `TIME`, +`WEIGHT`, `HEIGHT`, `BIOSEX`. + +Pool Entries: +| Column Name | Type | Constraints | +| ----------- | ------ | ----------- | +| Pool ID | ULID | FK | +| email | String | | +| guesses | JSON | | + +`guesses` must satisfy the following schema: + +``` +[]struct{ + game string // one of DAY, TIME, WEIGHT, HEIGHT, BIOSEX + val: date | time | { v: int, unit: string } | ['M', 'F'] +} +``` diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..c904330 --- /dev/null +++ b/fly.toml @@ -0,0 +1,41 @@ +# fly.toml file generated for wperron-io on 2022-05-19T10:44:27-04:00 + +app = "babypool-lol" +primary_region = "yul" + +[processes] +caddy = "caddy run --config /etc/caddy/Caddyfile --adapter caddyfile" + +[metrics] +port = 9091 +path = "/metrics" + +[env] +TZ = "America/New_York" + +[[services]] + http_checks = [] + internal_port = 80 + processes = ["caddy"] + protocol = "tcp" + script_checks = [] + + [services.concurrency] + hard_limit = 25 + soft_limit = 20 + type = "connections" + + [[services.ports]] + force_https = true + handlers = ["http"] + port = 80 + + [[services.ports]] + handlers = ["tls", "http"] + port = 443 + + [[services.tcp_checks]] + grace_period = "1s" + interval = "15s" + restart_limit = 0 + timeout = "2s" diff --git a/static/404.html b/static/404.html new file mode 100644 index 0000000..dc7e54d --- /dev/null +++ b/static/404.html @@ -0,0 +1,9 @@ + + + babypool.lol + + + +

404 Not Found

+

There ain't nothing here chief.

+ diff --git a/static/index.css b/static/index.css new file mode 100644 index 0000000..04ce436 --- /dev/null +++ b/static/index.css @@ -0,0 +1,4 @@ +body { + width: 50%; + margin: auto; +} diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..d503230 --- /dev/null +++ b/static/index.html @@ -0,0 +1,9 @@ + + + babypool.lol + + + + +

Hello Babypool.lol!

+ diff --git a/static/robots.txt b/static/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/static/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /