init
This commit is contained in:
commit
80edaeb8e2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
data
|
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@ -0,0 +1,32 @@
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk update
|
||||
|
||||
RUN apk add alpine-sdk
|
||||
|
||||
# Install microhttpd
|
||||
RUN apk add autoconf automake libtool pkgconf git texinfo
|
||||
|
||||
WORKDIR /root
|
||||
RUN git clone https://git.gnunet.org/libmicrohttpd.git
|
||||
WORKDIR /root/libmicrohttpd
|
||||
RUN ./bootstrap
|
||||
RUN ./configure
|
||||
RUN make
|
||||
RUN make install
|
||||
|
||||
# Compile code
|
||||
RUN apk add sqlite-dev argon2-dev libsodium-dev curl-dev xxd
|
||||
|
||||
RUN git clone https://git.sr.ht/~kikoodx/betterboxd /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./build.sh .
|
||||
|
||||
RUN ./build.sh
|
||||
|
||||
COPY ./docker-run.sh .
|
||||
COPY ./initdb.sh .
|
||||
|
||||
ENTRYPOINT ["sh", "/app/docker-run.sh"]
|
37
build.sh
Executable file
37
build.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#! /bin/sh -e
|
||||
# This file is automatically generated with: tup generate build.sh
|
||||
export tup_vardict="$(cd $(dirname $0) && pwd)/tup-generate.vardict"
|
||||
(mkdir gen)
|
||||
(xxd -i theme.css gen/theme.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/db.o src/db.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/fetch.o src/fetch.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_admin.o src/handler_admin.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_admin_newuser.o src/handler_admin_newuser.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_admin_setpass.o src/handler_admin_setpass.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_film.o src/handler_film.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_film_fetch.o src/handler_film_fetch.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_film_poster.o src/handler_film_poster.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_film_poster_set.o src/handler_film_poster_set.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_film_rate.o src/handler_film_rate.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_filmlist.o src/handler_filmlist.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_index.o src/handler_index.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_login.o src/handler_login.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_logout.o src/handler_logout.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_person.o src/handler_person.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_personlist.o src/handler_personlist.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_theme.o src/handler_theme.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_user.o src/handler_user.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/handler_userlist.o src/handler_userlist.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/hash.o src/hash.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/main.o src/main.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/request.o src/request.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/router.o src/router.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/session.o src/session.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/sessionmanager.o src/sessionmanager.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/string.o src/string.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/tmdb.o src/tmdb.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/userinfo.o src/userinfo.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/_.o vendors/_.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/cJSON.o vendors/cJSON.c)
|
||||
(gcc -g3 -std=c2x -Wall -Wextra -iquoteinc -iquotevendors -include_.h -Dnullptr=NULL -c -o build/theme.o gen/theme.c)
|
||||
(gcc -o betterboxd build/db.o build/fetch.o build/handler_admin.o build/handler_admin_newuser.o build/handler_admin_setpass.o build/handler_film.o build/handler_film_fetch.o build/handler_film_poster.o build/handler_film_poster_set.o build/handler_film_rate.o build/handler_filmlist.o build/handler_index.o build/handler_login.o build/handler_logout.o build/handler_person.o build/handler_personlist.o build/handler_theme.o build/handler_user.o build/handler_userlist.o build/hash.o build/main.o build/request.o build/router.o build/session.o build/sessionmanager.o build/string.o build/tmdb.o build/userinfo.o build/_.o build/cJSON.o build/theme.o -lmicrohttpd -lsqlite3 -lcurl -largon2 -lsodium -lm)
|
57
create-tables.sql
Normal file
57
create-tables.sql
Normal file
@ -0,0 +1,57 @@
|
||||
CREATE TABLE film (
|
||||
rowid INTEGER PRIMARY KEY NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
ogtitle TEXT,
|
||||
year INT NOT NULL,
|
||||
poster INTEGER,
|
||||
lastfetch INTEGER,
|
||||
CONSTRAINT fk_film_poster FOREIGN KEY (poster) REFERENCES poster(rowid) ON DELETE SET NULL
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE poster (
|
||||
rowid INTEGER PRIMARY KEY NOT NULL,
|
||||
film INTEGER NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
CONSTRAINT fk_poster_film FOREIGN KEY (film) REFERENCES film(rowid) ON DELETE CASCADE
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE person (
|
||||
rowid INTEGER PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
birth INT,
|
||||
death INT,
|
||||
picture TEXT,
|
||||
lastfetch INTEGER
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE crew (
|
||||
film INTEGER NOT NULL,
|
||||
person INTEGER NOT NULL,
|
||||
role TEXT NOT NULL,
|
||||
PRIMARY KEY (film, person, role),
|
||||
CONSTRAINT fk_crew_film FOREIGN KEY (film) REFERENCES film(rowid) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_crew_person FOREIGN KEY (person) REFERENCES person(rowid) ON DELETE CASCADE
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE user (
|
||||
rowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
name TEXT UNIQUE NOT NULL,
|
||||
pass TEXT NOT NULL,
|
||||
salt TEXT NOT NULL,
|
||||
perm INT NOT NULL DEFAULT 0
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE rating (
|
||||
user INTEGER NOT NULL,
|
||||
film INTEGER NOT NULL,
|
||||
value INTEGER NOT NULL,
|
||||
time TEXT NOT NULL,
|
||||
PRIMARY KEY (user, film),
|
||||
CONSTRAINT fk_rating_user FOREIGN KEY (user) REFERENCES user(rowid) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_rating_film FOREIGN KEY (film) REFERENCES film(rowid) ON DELETE CASCADE
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO user
|
||||
(name, perm, pass, salt)
|
||||
VALUES
|
||||
('admin', 1, 'c487293be46cee0c75db63f11cf20c756efdc45c7fb024b517bdfb837ab68c33', 'uwubebou'); /* uwu */
|
11
docker-compose.yaml
Normal file
11
docker-compose.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
services:
|
||||
betterboxd:
|
||||
container_name: betterboxd
|
||||
volumes:
|
||||
- ./data:/app/db/
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- PORT=8080
|
||||
- TMDB_KEY=PRIVATE_KEY
|
||||
build: .
|
9
docker-run.sh
Executable file
9
docker-run.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
DB=/app/db/main.db
|
||||
if [ ! -f $DB ]; then
|
||||
echo "Gen DB"
|
||||
/app/initdb.sh
|
||||
mkdir -p /app/db
|
||||
mv /app/main.db $DB
|
||||
fi
|
||||
./betterboxd $PORT $TMDB_KEY $DB
|
Loading…
Reference in New Issue
Block a user