diff --git a/Procfile b/Procfile index 679459050..24e845160 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ 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 diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 59e86162e..27cc8bfa6 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -429,7 +429,7 @@ fart' # base_url - where to serve files from (default: http://#{hostname}/data) # hierarchical: false - store files in a single directory # 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 # ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start) diff --git a/docker-compose.yml b/docker-compose.yml index 215d2fbd1..bdd809b99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,8 @@ services: DANBOORU_REDIS_URL: redis://redis DANBOORU_ELASTICSEARCH_HOST: elastic 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 SECRET_TOKEN: 1c58518a891eff4520cadc59afa9e378a9325f1247544ff258096e497f095f45 SESSION_SECRET_KEY: 44b4f44e9f253c406cbe727d403d500c1cecff943e4d2aea8f5447f28846fffe @@ -25,6 +27,7 @@ services: - redis - memcached - elastic + - iqdb nginx: image: nginx:stable-alpine @@ -70,9 +73,28 @@ services: - ES_JAVA_OPTS=-Xms1g -Xmx1g volumes: - 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: post_data: + iqdb_data: elastic_data: db_data: redis_data: diff --git a/docker/iqdb/Dockerfile b/docker/iqdb/Dockerfile new file mode 100644 index 000000000..329027000 --- /dev/null +++ b/docker/iqdb/Dockerfile @@ -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" ] diff --git a/docker/iqdb/iqdb.patch b/docker/iqdb/iqdb.patch new file mode 100644 index 000000000..ec02e0e9f --- /dev/null +++ b/docker/iqdb/iqdb.patch @@ -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; } + }; + \ No newline at end of file