-
Notifications
You must be signed in to change notification settings - Fork 407
/
docker-compose.yaml
221 lines (198 loc) · 7.38 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# This is a Docker Compose file that will launch a minimal Danbooru instance.
# This is suitable as a quick demo or for personal use, but is not recommended
# for a large public-facing site.
#
# ## Quickstart
#
# First run `bin/setup`. Then run `docker compose up` to start a Danbooru instance on http://localhost:3000.
#
# Run `docker compose down` to stop the instance.
#
# Run `docker volume rm danbooru-data danbooru-images iqdb-data` to delete all
# your data if you no longer need it.
#
# See below for more commands for running your instance.
#
# ## Configuration
#
# To configure your instance, edit the files `.env.local` or `config/danbooru_local_config.rb`
# outside the container.
#
# Start by copying either `config/danbooru_default_config.rb` to `config/danbooru_local_config.rb`,
# or `.env` to `.env.local`. Then edit the files as needed.
#
# See `config/danbooru_default_config.rb` for the default settings.
#
# ## Usage
#
# # Start a Danbooru instance on http://localhost:3000.
# docker compose up
#
# # Stop the instance.
# docker compose down
#
# # Upgrade the instance to the latest version of Danbooru.
# docker compose pull
# docker compose restart
#
# # Backup the database and images.
# docker compose run --rm -T danbooru bin/rails danbooru:database:backup > danbooru-database.pg_dump
# docker compose run --rm -T danbooru bin/rails danbooru:images:backup > danbooru-images.tar
# docker compose cp iqdb:/iqdb/data/iqdb.sqlite ./
#
# # Restore the database and images from backup.
# docker compose down
# docker volume rm danbooru-data danbooru-images iqdb-data
# docker compose run --rm -T danbooru bin/rails danbooru:database:restore < danbooru-database.pg_dump
# docker compose run --rm -T danbooru bin/rails danbooru:images:restore < danbooru-images.tar
# docker compose cp ./iqdb.sqlite iqdb:/iqdb/data/iqdb.sqlite
#
# # Delete all the data for the instance.
# docker compose down
# docker volume rm danbooru-data danbooru-images iqdb-data
#
# # Start a Bash shell inside the instance (for debugging).
# docker compose run --rm danbooru bash
#
# # Start a Rails console inside the instance (for debugging)
# docker compose run --rm danbooru bin/rails console
#
# # Start a Postgres shell inside the instance (for debugging)
# docker compose run --rm danbooru bin/rails dbconsole -p
#
# # Start two instances of Danbooru at the same time, one named `danbooru-latest` and the other
# # `danbooru-production`. Good for comparing two different versions of Danbooru.
# DANBOORU_PORT=3000 DANBOORU_IMAGE=ghcr.io/danbooru/danbooru:latest docker compose -p danbooru-latest up
# DANBOORU_PORT=3001 DANBOORU_IMAGE=ghcr.io/danbooru/danbooru:production docker compose -p danbooru-production up
# docker compose -p danbooru-latest down --volumes
# docker compose -p danbooru-production down --volumes
#
# # Show the logs for the Danbooru container.
# docker compose logs -f danbooru
#
# References:
#
# * https://docs.docker.com/get-docker/
# * https://docs.docker.com/compose/install/
# * https://docs.docker.com/compose/release-notes
# You can change the name to run multiple Danbooru instances simultaneously.
# This doesn't change the name of the site, it only affects the name used by Docker Compose.
name: danbooru
x-base-template: &base-template
# You can set DANBOORU_IMAGE to `ghcr.io/danbooru/danbooru:master` to get the latest unstable release,
# or e.g. `ghcr.io/danbooru/danbooru:production-2024.01.12-055003-utc` to get a specific stable version.
#
# See https://github.com/danbooru/danbooru/pkgs/container/danbooru for a list of versions
image: ${DANBOORU_IMAGE:-ghcr.io/danbooru/danbooru:production}
read_only: true
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/up"]
start_period: 120s
interval: 10s
retries: 1
environment:
# The public URL of your site. You can set this if you have a domain name for your site.
DANBOORU_CANONICAL_URL: ${DANBOORU_CANONICAL_URL:-}
# Set this to true if you're running behind a reverse proxy, such as Cloudflare.
DANBOORU_REVERSE_PROXY: ${DANBOORU_REVERSE_PROXY:-false}
# You should set DANBOORU_SECRET_KEY_BASE to a random secret string. If you
# don't set this, you will be logged out every time you restart the instance.
#
# Keep this secret. If someone finds this out, they will be able to log in as any user.
# DANBOORU_SECRET_KEY_BASE: "<random secret password>"
# Don't change the options below.
RAILS_ENV: production
DATABASE_URL: postgresql://danbooru@postgres/danbooru?pool=100
DANBOORU_REDIS_URL: redis://redis:6379
DANBOORU_IQDB_URL: http://iqdb:5588
DANBOORU_AUTOTAGGER_URL: http://autotagger:5000
DANBOORU_IMAGE_STORAGE_PATH: /images
tmpfs:
- /tmp
volumes:
- danbooru-images:/images
configs:
- source: danbooru_local_config
target: /danbooru/config/danbooru_local_config.rb
- source: env_local
target: /danbooru/.env.local
services:
danbooru:
<<: *base-template
depends_on:
postgres:
condition: service_healthy
command: ["bash", "-c", "bin/rails db:prepare && bin/rails server -b 0.0.0.0"]
cron:
<<: *base-template
depends_on:
danbooru:
condition: service_healthy
command: ["bin/rails", "danbooru:cron"]
jobs:
<<: *base-template
depends_on:
danbooru:
condition: service_healthy
command: ["bin/good_job", "start"]
# https://github.com/danbooru/iqdb
# https://hub.docker.com/repository/docker/evazion/iqdb
iqdb:
image: evazion/iqdb
volumes:
- "iqdb-data:/iqdb/data"
command: ["http", "0.0.0.0", "5588", "/iqdb/data/iqdb.sqlite"]
redis:
image: redis
postgres:
image: ghcr.io/danbooru/postgres:16.1
shm_size: 1gb
environment:
POSTGRES_USER: danbooru
POSTGRES_HOST_AUTH_METHOD: trust
healthcheck:
test: ["CMD", "pg_isready", "-U", "danbooru"]
start_period: 30s
interval: 1s
retries: 1
volumes:
- "danbooru-data:/var/lib/postgresql/data"
nginx:
image: ${DANBOORU_IMAGE:-ghcr.io/danbooru/danbooru:production}
command: ["openresty", "-e", "/dev/stderr"]
environment:
# The external port to listen on. You can set this to 80 if you have nothing else listening on port 80.
DANBOORU_PORT: "${DANBOORU_PORT:-3000}"
# If your instance is running behind a reverse proxy (such as Cloudflare, Ngrok, etc), then set this to true.
#
# If you get a `HTTP Origin header didn't match request.base_url` error when creating a new account, then set this to true.
DANBOORU_REVERSE_PROXY: ${DANBOORU_REVERSE_PROXY:-false}
# Used by Nginx to determine the root directory if we're running in a subdirectory (e.g. http://example.com/danbooru).
DANBOORU_CANONICAL_URL: ${DANBOORU_CANONICAL_URL:-}
ports:
- "${DANBOORU_PORT:-3000}:3000"
depends_on:
danbooru:
condition: service_started
configs:
- source: nginx
target: /usr/local/nginx/conf/nginx.conf
volumes:
- "danbooru-images:/images"
autotagger:
image: ghcr.io/danbooru/autotagger:latest
configs:
danbooru_local_config:
file: config/danbooru_local_config.rb
env_local:
file: .env.local
nginx:
file: config/nginx.conf
volumes:
danbooru-images:
name: ${COMPOSE_PROJECT_NAME}-images
danbooru-data:
name: ${COMPOSE_PROJECT_NAME}-data
iqdb-data:
name: ${COMPOSE_PROJECT_NAME}-iqdb-data