1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-27 11:26:22 -07:00

Use single template json file, make necessary changes to the configuration for docker in build-images.sh, and add /etc/gochan/ as a volume

This commit is contained in:
Eggbertx 2025-04-20 00:14:16 -07:00
parent bb8f9dcc93
commit 3702ab6deb
8 changed files with 63 additions and 174 deletions

View file

@ -3,13 +3,17 @@ FROM golang:1.24-alpine3.20
WORKDIR /opt/gochan
COPY . .
COPY docker/gochan-docker.json /etc/gochan/gochan.json
COPY examples/configs/gochan.example.json /opt/gochan/gochan-init.json
ARG GOCHAN_DBTYPE
ARG GOCHAN_DBHOST
ARG GOCHAN_PORT="80"
ARG GOCHAN_SITE_HOST="127.0.0.1"
ARG GOCHAN_DB_TYPE
ARG GOCHAN_DB_HOST
ENV DBTYPE=${GOCHAN_DBTYPE}
ENV DBHOST=${GOCHAN_DBHOST}
ENV GOCHAN_PORT=${GOCHAN_PORT}
ENV SITE_HOST=${GOCHAN_SITE_HOST}
ENV DB_TYPE=${GOCHAN_DB_TYPE}
ENV DB_HOST=${GOCHAN_DB_HOST}
COPY docker/build-image.sh .

View file

@ -3,30 +3,42 @@
set -euo pipefail
apk add ffmpeg python3 git gcc openssl exiftool musl-dev nodejs npm
CFG_DBTYPE=$DBTYPE
CFG_DB_TYPE=$DB_TYPE
if [ "$DBTYPE" = "mariadb" ]; then
if [ "$DB_TYPE" = "mariadb" ]; then
apk add mariadb-client
CFG_DBTYPE=mysql
elif [ "$DBTYPE" = "mysql" ]; then
CFG_DB_TYPE=mysql
elif [ "$DB_TYPE" = "mysql" ]; then
apk add mysql-client
elif [ "$DBTYPE" = "postgres" ]; then
elif [ "$DB_TYPE" = "postgres" ]; then
apk add postgresql16-client
elif [ "$DBTYPE" = "sqlite3" ]; then
elif [ "$DB_TYPE" = "sqlite3" ]; then
apk add sqlite sqlite-dev sqlite-libs
elif [ -z "$DBTYPE" ]; then
echo "DBTYPE is not set"
elif [ -z "$DB_TYPE" ]; then
echo "DB_TYPE is not set"
exit 1
else
echo "Unrecognized DBTYPE '$DBTYPE'"
echo "Unrecognized DB_TYPE '$DB_TYPE'"
exit 1
fi
sed -i /etc/gochan/gochan.json \
-e 's/"DBhost": .*/"DBhost": "'$DBHOST'",/' \
-e 's/"DBtype": .*/"DBtype": "'$CFG_DBTYPE'",/'
sed -i /opt/gochan/gochan-init.json \
-e 's/"ListenAddress": .*/"ListenAddress": "gochan-server",/' \
-e 's/"UseFastCGI": .*/"UseFastCGI": false,/' \
-e 's/"DocumentRoot": .*/"DocumentRoot": "\/var\/www\/gochan",/' \
-e 's/"TemplateDir": .*/"TemplateDir": "\/opt\/gochan\/templates",/' \
-e 's/"LogDir": .*/"LogDir": "\/var\/log\/gochan",/' \
-e 's/"SiteHost": .*/"SiteHost": "'$SITE_HOST'",/' \
-e 's/"Port": .*/"Port": '$GOCHAN_PORT',/' \
-e 's/"DBhost": .*/"DBhost": "'$DB_HOST'",/' \
-e 's/"DBtype": .*/"DBtype": "'$CFG_DB_TYPE'",/' \
-e 's/"DBpassword": .*/"DBpassword": "gochan",/'
rm -f /opt/gochan/gochan.json
mkdir -p /etc/gochan
mkdir -p /var/log/gochan
mkdir -p /var/www/gochan
npm --prefix frontend/ install
npm --prefix frontend/ run build-ts
echo "Building gochan executable"

View file

@ -4,14 +4,17 @@ services:
context: ..
dockerfile: docker/Dockerfile
args:
- GOCHAN_DBTYPE=mariadb
- GOCHAN_DBHOST=gochan-mariadb:3306
- GOCHAN_PORT=80
- GOCHAN_SITE_HOST=127.0.0.1
- GOCHAN_DB_TYPE=mariadb
- GOCHAN_DB_HOST=gochan-mariadb:3306
container_name: gochan-server
ports:
- "80:80"
volumes:
- ./volumes/gochan/log:/var/log/gochan
- ./volumes/gochan/www:/var/www/gochan
- ./volumes/gochan/config:/etc/gochan
networks:
- gochan-bridge
depends_on:

View file

@ -4,14 +4,17 @@ services:
context: ..
dockerfile: docker/Dockerfile
args:
- GOCHAN_DBTYPE=mysql
- GOCHAN_DBHOST=gochan-mysql:3306
- GOCHAN_PORT=80
- GOCHAN_SITE_HOST=127.0.0.1
- GOCHAN_DB_TYPE=mysql
- GOCHAN_DB_HOST=gochan-mysql:3306
container_name: gochan-server
ports:
- "80:80"
volumes:
- ./volumes/gochan/log:/var/log/gochan
- ./volumes/gochan/www:/var/www/gochan
- ./volumes/gochan/config:/etc/gochan
networks:
- gochan-bridge
depends_on:

View file

@ -4,14 +4,17 @@ services:
context: ..
dockerfile: docker/Dockerfile
args:
- GOCHAN_DBTYPE=postgres
- GOCHAN_DBHOST=gochan-postgres:5432
- GOCHAN_PORT=80
- GOCHAN_SITE_HOST=127.0.0.1
- GOCHAN_DB_TYPE=postgres
- GOCHAN_DB_HOST=gochan-postgres:5432
container_name: gochan-server
ports:
- "80:80"
volumes:
- ./volumes/gochan/log:/var/log/gochan
- ./volumes/gochan/www:/var/www/gochan
- ./volumes/gochan/config:/etc/gochan
networks:
- gochan-bridge
depends_on:

View file

@ -4,8 +4,10 @@ services:
context: ..
dockerfile: docker/Dockerfile
args:
- GOCHAN_DBTYPE=sqlite3
- GOCHAN_DBHOST=\/var\/lib\/gochan\/gochan.db
- GOCHAN_PORT=80
- GOCHAN_SITE_HOST=127.0.0.1
- GOCHAN_DB_TYPE=sqlite3
- GOCHAN_DB_HOST=\/var\/lib\/gochan\/gochan.db
container_name: gochan-server
ports:
- "80:80"
@ -13,3 +15,4 @@ services:
- ./volumes/gochan/log:/var/log/gochan
- ./volumes/gochan/www:/var/www/gochan
- ./volumes/gochan/db:/var/lib/gochan
- ./volumes/gochan/config:/etc/gochan

View file

@ -1,146 +0,0 @@
{
"ListenAddress": "gochan-server",
"Port": 80,
"UseFastCGI": false,
"DocumentRoot": "/var/www/gochan",
"TemplateDir": "/opt/gochan/templates",
"LogDir": "/var/log/gochan",
"Plugins": null,
"PluginSettings": null,
"SiteHeaderURL": "",
"WebRoot": "/",
"SiteHost": "127.0.0.1",
"DBtype": "mysql",
"DBhost": "gochan-mariadb:3306",
"DBname": "gochan",
"DBusername": "gochan",
"DBpassword": "gochan",
"DBprefix": "",
"DBTimeoutSeconds": 15,
"DBMaxOpenConnections": 10,
"DBMaxIdleConnections": 10,
"DBConnMaxLifetimeMin": 3,
"DebugMode": true,
"RandomSeed": "c,b25Y]]\"?:Q#^|f",
"FirstPage": [
"index.html",
"firstrun.html",
"1.html"
],
"Username": "",
"CookieMaxAge": "1y",
"StaffSessionDuration": "3mo",
"Lockdown": false,
"LockdownMessage": "This imageboard has temporarily disabled posting. We apologize for the inconvenience",
"SiteName": "Gochan",
"SiteSlogan": "",
"Modboard": "",
"MaxRecentPosts": 12,
"RecentPostsWithNoFile": false,
"EnableAppeals": true,
"MinifyHTML": true,
"MinifyJS": true,
"GeoIPType": "",
"GeoIPOptions": null,
"Captcha": {
"Type": "",
"OnlyNeededForThreads": false,
"SiteKey": "",
"AccountSecret": ""
},
"FingerprintVideoThumbnails": false,
"FingerprintHashLength": 0,
"InheritGlobalStyles": false,
"Styles": [
{
"Name": "Pipes",
"Filename": "pipes.css"
},
{
"Name": "BunkerChan",
"Filename": "bunkerchan.css"
},
{
"Name": "Burichan",
"Filename": "burichan.css"
},
{
"Name": "Clear",
"Filename": "clear.css"
},
{
"Name": "Dark",
"Filename": "dark.css"
},
{
"Name": "Photon",
"Filename": "photon.css"
},
{
"Name": "Yotsuba",
"Filename": "yotsuba.css"
},
{
"Name": "Yotsuba B",
"Filename": "yotsubab.css"
},
{
"Name": "Windows 9x",
"Filename": "win9x.css"
}
],
"DefaultStyle": "pipes.css",
"Banners": [
{
"Filename": "gochan_go-parody.png",
"Width": 300,
"Height": 100
}
],
"MaxLineLength": 150,
"ReservedTrips": {
"thischangesto": "this",
"andthischangesto": "this"
},
"RepliesOnBoardPage": 3,
"StickyRepliesOnBoardPage": 1,
"NewThreadsRequireUpload": false,
"CyclicalThreadNumPosts": 500,
"BanColors": {
"admin": "#0000A0",
"somemod": "blue"
},
"BanMessage": "USER WAS BANNED FOR THIS POST",
"EmbedWidth": 200,
"EmbedHeight": 164,
"EnableEmbeds": true,
"ImagesOpenNewTab": true,
"NewTabOnOutlinks": true,
"DisableBBcode": false,
"RejectDuplicateImages": false,
"ThumbWidth": 200,
"ThumbHeight": 200,
"ThumbWidthReply": 125,
"ThumbHeightReply": 125,
"ThumbWidthCatalog": 50,
"ThumbHeightCatalog": 50,
"AllowOtherExtensions": null,
"StripImageMetadata": "none",
"ExiftoolPath": "",
"DateTimeFormat": "Mon, January 02, 2006 3:04 PM",
"ShowPosterID": false,
"EnableSpoileredImages": true,
"EnableSpoileredThreads": true,
"Worksafe": true,
"ThreadPage": 0,
"Cooldowns": {
"threads": 30,
"replies": 7,
"images": 7
},
"RenderURLsAsLinks": true,
"ThreadsPerPage": 15,
"EnableGeoIP": false,
"EnableNoFlag": false,
"CustomFlags": null
}

View file

@ -15,8 +15,15 @@ linkwww static
linkwww favicon.png
linkwww firstrun.html
if [ "$DBTYPE" != "sqlite3" ]; then
echo "pinging database $DBHOST, DBTYPE: '$DBTYPE'"
./docker/wait-for.sh "$DBHOST" -t 30
mkdir -p /etc/gochan
if [ ! -e "/etc/gochan/gochan.json" ]; then
echo "gochan.json not found in /etc/gochan/, moving /opt/gochan/gochan-init.json to /etc/gochan/gochan.json"
mv /opt/gochan/gochan-init.json /etc/gochan/gochan.json
fi
if [ "$DB_TYPE" != "sqlite3" ]; then
echo "pinging database $DB_HOST, DBTYPE: '$DB_TYPE'"
./docker/wait-for.sh "$DB_HOST" -t 30
fi
gochan