[Docker] Add iqdb/s to composer

Closes #315
This commit is contained in:
Earlopain 2021-11-18 01:13:38 +01:00
parent b2b5938d5c
commit 71aab10d18
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
5 changed files with 67 additions and 2 deletions

View File

@ -1,2 +1,2 @@
unicorn: bin/rails server -p 9000 -b 0.0.0.0 unicorn: bin/rails server -p 9000 -b 0.0.0.0
jobs: bundle exec sidekiq -c 1 -q low_prio -q tags -q default -q high_prio -q video -q iqdb jobs: bundle exec sidekiq -c 1 -q low_prio -q tags -q default -q high_prio -q video

View File

@ -429,7 +429,7 @@ fart'
# base_url - where to serve files from (default: http://#{hostname}/data) # base_url - where to serve files from (default: http://#{hostname}/data)
# hierarchical: false - store files in a single directory # hierarchical: false - store files in a single directory
# hierarchical: true - store files in a hierarchical directory structure, based on the MD5 hash # hierarchical: true - store files in a hierarchical directory structure, based on the MD5 hash
StorageManager::Local.new(base_url: "#{CurrentUser.root_url}/", base_dir: "#{Rails.root}/public/data", hierarchical: false) StorageManager::Local.new(base_url: "#{CurrentUser.root_url}/", base_dir: "#{Rails.root}/public/data", hierarchical: true)
# Store files on one or more remote host(s). Configure SSH settings in # Store files on one or more remote host(s). Configure SSH settings in
# ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start) # ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start)

View File

@ -17,6 +17,8 @@ services:
DANBOORU_REDIS_URL: redis://redis DANBOORU_REDIS_URL: redis://redis
DANBOORU_ELASTICSEARCH_HOST: elastic DANBOORU_ELASTICSEARCH_HOST: elastic
DANBOORU_MEMCACHED_SERVERS: memcached DANBOORU_MEMCACHED_SERVERS: memcached
DANBOORU_IQDBS_SERVER: http://iqdb:4567
DANBOORU_IQDB_ENABLED: true
# These are just development secrets, do not use them in production # These are just development secrets, do not use them in production
SECRET_TOKEN: 1c58518a891eff4520cadc59afa9e378a9325f1247544ff258096e497f095f45 SECRET_TOKEN: 1c58518a891eff4520cadc59afa9e378a9325f1247544ff258096e497f095f45
SESSION_SECRET_KEY: 44b4f44e9f253c406cbe727d403d500c1cecff943e4d2aea8f5447f28846fffe SESSION_SECRET_KEY: 44b4f44e9f253c406cbe727d403d500c1cecff943e4d2aea8f5447f28846fffe
@ -25,6 +27,7 @@ services:
- redis - redis
- memcached - memcached
- elastic - elastic
- iqdb
nginx: nginx:
image: nginx:stable-alpine image: nginx:stable-alpine
@ -70,9 +73,28 @@ services:
- ES_JAVA_OPTS=-Xms1g -Xmx1g - ES_JAVA_OPTS=-Xms1g -Xmx1g
volumes: volumes:
- elastic_data:/usr/share/elasticsearch/data - elastic_data:/usr/share/elasticsearch/data
iqdb:
build: ./docker/iqdb
environment:
- IQDB_HOSTNAME=localhost
- IQDB_PORT=62125
# Hardcoded in iqdbs Procfile
- IQDB_DATABASE_FILE=/home/vagrant/iqdbs/e621.db
- SINATRA_PORT=4567
- IMAGES_FOLDER=/data
- REDIS_URL=redis://redis
# Sinatra only binds to localhost in development, but to 0.0.0.0 for anything else
- APP_ENV=docker
depends_on:
- redis
volumes:
- post_data:/data
- iqdb_data:/home/vagrant/iqdbs
volumes: volumes:
post_data: post_data:
iqdb_data:
elastic_data: elastic_data:
db_data: db_data:
redis_data: redis_data:

30
docker/iqdb/Dockerfile Normal file
View File

@ -0,0 +1,30 @@
FROM ruby:2.7.3-alpine
ADD https://api.github.com/repos/zwagoth/iqdbs/git/refs/heads/master /tmp/iqdbs_version.json
COPY iqdb.patch /tmp/iqdb.patch
ENV IQDB_VERSION=20161008
RUN apk --no-cache add build-base git libjpeg-turbo-dev gd-dev bash \
# iqdbs
&& cd /tmp \
&& wget -q https://iqdb.org/code/iqdb-$IQDB_VERSION.tar.bz2 \
&& tar xjf iqdb-$IQDB_VERSION.tar.bz2 \
&& cd iqdb \
&& patch -N -i /tmp/iqdb.patch \
&& make EXTRADEFS="-include stdint.h" -j$(nproc) \
&& cp iqdb /usr/bin \
# iqdb
&& git clone https://github.com/zwagoth/iqdbs /iqdbs \
&& bundler install --gemfile /iqdbs/Gemfile \
# cleanup
&& rm /tmp/iqdb-$IQDB_VERSION.tar.bz2 \
&& rm -rf /tmp/iqdb \
&& apk del build-base git
# shoreman
RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh \
&& chmod +x /usr/bin/shoreman
WORKDIR /iqdbs
CMD [ "shoreman" ]

13
docker/iqdb/iqdb.patch Normal file
View File

@ -0,0 +1,13 @@
diff --git a/imglib.h b/imglib.h
index 2a03f93..e5468c4 100644
--- a/imglib.h
+++ b/imglib.h
@@ -98,7 +98,7 @@ union image_id_index {
bool operator==(const image_id_index& other) const { return id == other.id; }
bool operator!=(const image_id_index& other) const { return id != other.id; }
- operator size_t&() { return index; }
+ //operator size_t&() { return index; }
operator imageId&() { return id; }
};