diff --git a/README.md b/README.md index 9eb9c9540..ad4ac60da 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/danbooru b/bin/danbooru new file mode 100755 index 000000000..5922dbc5d --- /dev/null +++ b/bin/danbooru @@ -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}" diff --git a/config/docker/docker-compose.simple.yaml b/config/docker/docker-compose.simple.yaml new file mode 100644 index 000000000..495526bca --- /dev/null +++ b/config/docker/docker-compose.simple.yaml @@ -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