Skip to content

Commit 664dfbb

Browse files
authored
Self hosting docker image (#3)
1 parent 4c81dac commit 664dfbb

File tree

16 files changed

+586
-105
lines changed

16 files changed

+586
-105
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and publish Docker image to Docker Hub
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags: [ 'v*' ]
7+
paths:
8+
- 'dockerimage/**'
9+
- 'backend/**'
10+
- 'frontend/**'
11+
- '.github/workflows/dockerhub-publish.yml'
12+
pull_request:
13+
branches: [ main, master ]
14+
paths:
15+
- 'dockerimage/**'
16+
- 'backend/**'
17+
- 'frontend/**'
18+
- '.github/workflows/dockerhub-publish.yml'
19+
20+
env:
21+
DOCKERHUB_REPO: rapnuss/ciphernotes
22+
23+
jobs:
24+
docker:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Log in to Docker Hub
36+
if: github.event_name != 'pull_request'
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ secrets.DOCKERHUB_USERNAME }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
42+
- name: Extract Docker metadata
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.DOCKERHUB_REPO }}
47+
tags: |
48+
type=ref,event=branch
49+
type=ref,event=tag
50+
type=sha
51+
type=raw,value=latest,enable={{is_default_branch}}
52+
53+
- name: Build and push
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
file: dockerimage/Dockerfile
58+
push: ${{ github.event_name != 'pull_request' }}
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
platforms: linux/amd64
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max
64+
65+

.vscode/settings.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"Betroffenenrechte",
1313
"bowser",
1414
"bubblewrap",
15+
"buildx",
16+
"Buildx",
1517
"CAROOT",
1618
"cascadia",
1719
"Cascadia",
@@ -22,20 +24,25 @@
2224
"clipb",
2325
"comlink",
2426
"Consolas",
27+
"createdb",
2528
"CSIC",
2629
"CTAN",
2730
"customtabs",
2831
"Dailymotion",
2932
"dasharray",
3033
"dashoffset",
34+
"datname",
3135
"dexie",
3236
"Dexie",
37+
"dockerhub",
38+
"dockerimage",
3339
"downl",
3440
"DSGVO",
3541
"Ecosia",
3642
"esnext",
3743
"Eurogamer",
3844
"genkeypair",
45+
"github",
3946
"hcaptcha",
4047
"HCAPTCHA",
4148
"healthcheck",
@@ -48,32 +55,45 @@
4855
"jszip",
4956
"keyalg",
5057
"keymap",
58+
"keypair",
5159
"keysize",
5260
"keytool",
5361
"Kotaku",
5462
"lastmod",
5563
"levenshtein",
5664
"linecap",
5765
"linejoin",
66+
"linux",
5867
"mantine",
5968
"matplotlib",
6069
"Metacritic",
6170
"nginx",
71+
"nocrypt",
6272
"Nußbaumer",
73+
"nvmrc",
74+
"openssl",
6375
"outdir",
76+
"outform",
6477
"panzoom",
6578
"passwortloser",
79+
"PGDATA",
80+
"pkcs",
81+
"PKCS",
6682
"postgres",
6783
"postgresql",
6884
"precache",
6985
"precaching",
7086
"presign",
7187
"presigner",
7288
"printcert",
89+
"psql",
90+
"pubout",
7391
"qrcode",
7492
"Qwant",
93+
"rapnuss",
7594
"replit",
7695
"rgba",
96+
"rolname",
7797
"Searchalot",
7898
"sels",
7999
"serverside",
@@ -83,9 +103,12 @@
83103
"Supportanfragen",
84104
"Swisscows",
85105
"tabler",
106+
"topk",
86107
"unarch",
87108
"urlset",
88109
"Usec",
110+
"uuid",
111+
"Vite",
89112
"Wickenburggasse",
90113
"yudiel"
91114
],

backend/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dist
22
node_modules
3+
.bun-version
34
.dockerignore
45
.env
56
.env.example
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
CREATE TYPE "public"."note_type" AS ENUM('note', 'todo', 'label', 'file');--> statement-breakpoint
2+
CREATE TYPE "public"."subscription_type" AS ENUM('free', 'plus', 'pro');--> statement-breakpoint
3+
CREATE TABLE "notes" (
4+
"id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "notes_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
5+
"user_id" bigint NOT NULL,
6+
"clientside_id" varchar(36) NOT NULL,
7+
"type" "note_type" DEFAULT 'note' NOT NULL,
8+
"cipher_text" text,
9+
"iv" varchar(16),
10+
"version" integer DEFAULT 1 NOT NULL,
11+
"serverside_created_at" bigint NOT NULL,
12+
"serverside_updated_at" bigint NOT NULL,
13+
"clientside_created_at" bigint NOT NULL,
14+
"clientside_updated_at" bigint NOT NULL,
15+
"clientside_deleted_at" bigint,
16+
"committed_size" integer DEFAULT 0 NOT NULL,
17+
CONSTRAINT "user_client_id" UNIQUE("user_id","clientside_id")
18+
);
19+
--> statement-breakpoint
20+
CREATE TABLE "sessions" (
21+
"id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "sessions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
22+
"user_id" bigint NOT NULL,
23+
"access_token_hash" varchar(64) NOT NULL,
24+
"access_token_salt" varchar(32) NOT NULL,
25+
"created_at" bigint NOT NULL
26+
);
27+
--> statement-breakpoint
28+
CREATE TABLE "users" (
29+
"id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
30+
"email" varchar(255) NOT NULL,
31+
"password_hash" varchar(255),
32+
"is_admin" boolean DEFAULT false NOT NULL,
33+
"login_code" varchar(6),
34+
"login_code_created_at" bigint,
35+
"login_tries_left" integer DEFAULT 0 NOT NULL,
36+
"created_at" bigint NOT NULL,
37+
"updated_at" bigint NOT NULL,
38+
"sync_token" varchar(24),
39+
"confirm_code" varchar(6),
40+
"confirm_code_created_at" bigint,
41+
"confirm_code_tries_left" integer DEFAULT 0 NOT NULL,
42+
"new_email" varchar(255),
43+
"subscription" "subscription_type" DEFAULT 'free' NOT NULL,
44+
"successful_login_at" bigint,
45+
CONSTRAINT "users_email_unique" UNIQUE("email")
46+
);
47+
--> statement-breakpoint
48+
ALTER TABLE "notes" ADD CONSTRAINT "notes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
49+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;

backend/drizzle/0001_migrate_to_bigint_ids.sql

Lines changed: 0 additions & 91 deletions
This file was deleted.

backend/drizzle/meta/0000_snapshot.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "30ed7634-b16d-4176-b067-561c5f6d48a9",
2+
"id": "b828c258-78b3-4758-b8f7-9fda1add2a07",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -228,6 +228,19 @@
228228
"primaryKey": false,
229229
"notNull": true
230230
},
231+
"password_hash": {
232+
"name": "password_hash",
233+
"type": "varchar(255)",
234+
"primaryKey": false,
235+
"notNull": false
236+
},
237+
"is_admin": {
238+
"name": "is_admin",
239+
"type": "boolean",
240+
"primaryKey": false,
241+
"notNull": true,
242+
"default": false
243+
},
231244
"login_code": {
232245
"name": "login_code",
233246
"type": "varchar(6)",
@@ -297,6 +310,12 @@
297310
"primaryKey": false,
298311
"notNull": true,
299312
"default": "'free'"
313+
},
314+
"successful_login_at": {
315+
"name": "successful_login_at",
316+
"type": "bigint",
317+
"primaryKey": false,
318+
"notNull": false
300319
}
301320
},
302321
"indexes": {},

backend/drizzle/meta/_journal.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"version": "5",
2+
"version": "7",
33
"dialect": "postgresql",
44
"entries": [
55
{
66
"idx": 0,
7-
"version": "5",
8-
"when": 1732487460000,
9-
"tag": "0001_migrate_to_bigint_ids",
7+
"version": "7",
8+
"when": 1756705234111,
9+
"tag": "0000_warm_blink",
1010
"breakpoints": true
1111
}
1212
]

0 commit comments

Comments
 (0)