Add scripts for a single-command Danbooru deployment.

Add a Docker Compose file that launches a minimal Danbooru instance in a
Docker container with a single command. This is suitable as a quick demo
or for personal use, not for public-facing sites.

To use it, just run `bin/danbooru`. This is a wrapper script that
installs Docker Compose then uses it to start Danbooru.

This will generate a lot of debug output and take several minutes while
it builds the Docker containers. Be patient. When it's done, you should
have an empty booru accessible at http://localhost.
This commit is contained in:
evazion
2021-03-23 20:11:19 -05:00
parent 9c07d710f4
commit 08270973f1
3 changed files with 114 additions and 0 deletions

View File

@@ -1,5 +1,25 @@
[![codecov](https://codecov.io/gh/danbooru/danbooru/branch/master/graph/badge.svg)](https://codecov.io/gh/danbooru/danbooru) [![Discord](https://img.shields.io/discord/310432830138089472?label=Discord)](https://discord.gg/eSVKkUF)
## Quickstart
Clone this repository and run `bin/danbooru` to start a basic Danbooru instance:
```sh
git clone https://github.com/danbooru/danbooru
cd danbooru
./bin/danbooru
```
This will install [Docker Compose](https://docs.docker.com/compose/) and use it
to start Danbooru. This will take several minutes and produce lots of output.
When it's done, Danbooru will be running at http://localhost.
Alternatively, if you already have Docker Compose installed, you can just do:
```sh
docker-compose -f config/docker/docker-compose.simple.yaml up
```
## Installation
It is recommended that you install Danbooru on a Debian-based system

50
bin/danbooru Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
#
# This script starts Danbooru by installing Docker and Docker Compose, then
# starting Danbooru in a container. Danbooru will be available at http://localhost.
#
# Usage:
#
# bin/danbooru up # start Danbooru
# bin/danbooru down # stop and remove Danbooru container.
# bin/danbooru help # show Docker Compose help
#
# Alternatively, if you already have Docker installed, you can just do:
#
# docker-compose -f config/docker/docker-compose.simple.yaml up
#
# This script is just a wrapper for that command.
install_docker_compose() {
if docker-compose version > /dev/null; then
return
fi
if apt --version; then
sudo apt install docker docker-compose
elif dnf --version; then
sudo dnf install docker docker-compose
elif pacman --version; then
sudo pacman -Sy docker docker-compose
else
echo "Error: Couldn't automatically install docker-compose. Install docker-compose manually."
exit 1
fi
}
start_docker() {
if docker version > /dev/null; then
return
fi
sudo systemctl start docker
}
docker_compose() {
COMPOSE_FILE="$(dirname "$(realpath "$0")")/../config/docker/docker-compose.simple.yaml"
docker-compose -f "$COMPOSE_FILE" "$@"
}
install_docker_compose
start_docker
docker_compose "${@:-up}"

View File

@@ -0,0 +1,44 @@
# A Docker Compose file that launches a minimal Danbooru instance. This is
# suitable as a quick demo or for personal use, not for public-facing sites.
#
# Usage:
#
# $ docker-compose -f config/docker/docker-compose.simple.yaml up
# $ docker-compose -f config/docker/docker-compose.simple.yaml down
version: "3.7"
services:
danbooru:
# image: evazion/danbooru
build:
context: ../..
dockerfile: config/docker/Dockerfile.danbooru
ports:
- "80:3000"
environment:
- RAILS_ENV=development
- DATABASE_URL=postgresql://danbooru@postgres/danbooru
- DANBOORU_CANONICAL_URL=http://localhost
volumes:
- "danbooru-images:/home/danbooru/app/public/data"
depends_on:
- postgres
entrypoint: ["bash", "-c", "bin/rails db:setup 2> /dev/null; bin/rails server -b 0.0.0.0"]
user: root
postgres:
# image: evazion/postgres
build:
context: .
dockerfile: Dockerfile.postgres
environment:
POSTGRES_USER: danbooru
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- "danbooru-data:/var/lib/postgresql/data"
volumes:
danbooru-images:
name: danbooru-images
danbooru-data:
name: danbooru-data