Skip to content

Commit cd2915d

Browse files
authored
Merge pull request #1 from poontology/main
add docker setup
2 parents ca7eec0 + b4a69ba commit cd2915d

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,28 @@ An offline E-hentai browser for archival purposes, keeping Hentai history around
77

88
- MySQL 5.3+ / MariaDB 10+
99

10+
- Docker (optional)
1011

11-
## Setup & Start Up
12+
## Setup & Start Up using docker-compose
13+
14+
# change dbHost to point to docker db container (or edit config.js manually)
15+
sed -i 's,localhost,mariadb,' config.js
16+
17+
# run it
18+
docker-compose up -d
19+
20+
Docker installs mariadb+node images (<1GB total, to see what they contain try `docker history mariadb:lts`), it inserts SQL on first startup (takes a minute, DB persists on restart) and then starts app which accepts connections on http://localhost:6969/
21+
22+
If you're paranoid about app making undesired outgoing connection there's an alternate startup command in docker-compose.yml which sets up a firewall within the container (ofc then you also can't run sync script from the container).
23+
24+
To interact with the containers:
25+
26+
# query db
27+
docker exec -it pandabrowser_mariadb_1 mariadb -p69 panda
28+
# run scripts
29+
docker exec -it pandabrowser_app_1 npm run fetch
30+
31+
## Setup & Start Up manually
1232

1333
1. Install the provided database file (panda_2024_01_01.sql) into MySQL, the default database name being "panda" here.
1434

docker-compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.5'
2+
3+
services:
4+
mariadb:
5+
image: mariadb:lts
6+
environment:
7+
MARIADB_ROOT_PASSWORD: 69
8+
MARIADB_DATABASE: panda
9+
# for external access
10+
#ports:
11+
# - "3306:3306"
12+
volumes:
13+
- ./panda_2024_01_01.sql.gz:/docker-entrypoint-initdb.d/1.sql.gz
14+
- ./mariadb:/var/lib/mysql
15+
app:
16+
image: node:22-alpine
17+
working_dir: /app
18+
## --[ Alternative commands (have only one uncommented) ]--
19+
command: npm start
20+
## --[ webpack-dev-server ]--
21+
#command: sh -c 'npm start & npm run dev'
22+
## to run webpack in docker edit webpack.config.js, add
23+
## under devServer `host: '0.0.0.0', disableHostCheck: true,`,
24+
## for thumbs proxy /pandathumbs same as /api, then expose 8080
25+
## --[ paranoid net setup preventing outgoing connections ]--
26+
#command: /app/docker-paranoid-net.sh "npm start"
27+
#cap_add:
28+
# - NET_ADMIN # required to config firewall within the container
29+
## --[ /commands ]--
30+
ports:
31+
- "6969:8880"
32+
#- "8080:8080"
33+
volumes:
34+
- ./:/app
35+
depends_on:
36+
- mariadb

docker-paranoid-net.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
DB_IP=$(getent hosts mariadb | cut -d' ' -f1)
4+
apk add ufw
5+
ufw default deny outgoing
6+
ufw allow out to 127.0.0.1
7+
ufw allow out to "$DB_IP" port 3306
8+
ufw allow in to any port 6969
9+
ufw enable
10+
11+
su -c "$@" node
12+

0 commit comments

Comments
 (0)