diff --git a/.gitignore b/.gitignore index c5382831..e6c85eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ nyaa-master.exe *.swp .vscode templates/*.html.go +*.backup +tags diff --git a/deploy/.env b/deploy/.env new file mode 100644 index 00000000..ae962270 --- /dev/null +++ b/deploy/.env @@ -0,0 +1,2 @@ +PANTSU_EXTERNAL_PORT=9999 +PANTSU_INTERNAL_PORT=9999 diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 00000000..3430a2c0 --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,5 @@ +FROM golang:1.8.1 + +RUN mkdir -p /nyaa + +WORKDIR /nyaa diff --git a/deploy/docker-compose.sqlite.yml b/deploy/docker-compose.sqlite.yml new file mode 100644 index 00000000..407b81c1 --- /dev/null +++ b/deploy/docker-compose.sqlite.yml @@ -0,0 +1,19 @@ +version: '3' +services: + pantsu: + build: + context: .. + dockerfile: deploy/Dockerfile + command: ./deploy/init.sh + env_file: + - sqlite.env + environment: + - PANTSU_INTERNAL_PORT=${PANTSU_INTERNAL_PORT} + ports: + # 0.0.0.0 makes it accessible to the network + # You may want to remove it to make pantsu available only + # to localhost + - 0.0.0.0:${PANTSU_EXTERNAL_PORT}:${PANTSU_INTERNAL_PORT} + volumes: + - "${GOPATH}:/go/" + - "./..:/nyaa" diff --git a/deploy/init.sh b/deploy/init.sh new file mode 100755 index 00000000..fc208a92 --- /dev/null +++ b/deploy/init.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -ex + +go get github.com/ewhal/nyaa +go build +./nyaa -host 0.0.0.0 \ + -port "${PANTSU_INTERNAL_PORT}" \ + -dbtype "${PANTSU_DBTYPE}" \ + -dbparams "${PANTSU_DBPARAMS}" diff --git a/deploy/postgres.env b/deploy/postgres.env new file mode 100644 index 00000000..03ed4d59 --- /dev/null +++ b/deploy/postgres.env @@ -0,0 +1,7 @@ +POSTGRES_USER="nyaapantsu" +POSTGRES_PASSWORD="nyaapantsu" +POSTGRES_DB="nyaa_db" + +PANTSU_DBTYPE="postgres" +PANTSU_DBPARAMS="host=pantsu_db user=${POSTGRES_USER} dbname=${POSTGRES_DB} sslmode=disable password=${POSTGRES_PASSWORD}" +PANTSU_POSTGRES_DBFILE="nyaa_psql.backup" diff --git a/deploy/restore.sh b/deploy/restore.sh new file mode 100644 index 00000000..be905eeb --- /dev/null +++ b/deploy/restore.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" < "${PANTSU_POSTGRES_DBFILE}" diff --git a/deploy/sqlite.env b/deploy/sqlite.env new file mode 100644 index 00000000..bf7c7893 --- /dev/null +++ b/deploy/sqlite.env @@ -0,0 +1,2 @@ +PANTSU_DBTYPE="sqlite3" +PANTSU_DBPARAMS="./nyaa.db"