Skip to content

Instantly share code, notes, and snippets.

@xtrasimplicity
Last active January 8, 2022 01:25
Show Gist options
  • Save xtrasimplicity/662d7bc33d6875bbd0a454110a289496 to your computer and use it in GitHub Desktop.
Save xtrasimplicity/662d7bc33d6875bbd0a454110a289496 to your computer and use it in GitHub Desktop.
Thinking Sphinx + Rails + Docker
---
version: '3'
services:
db:
image: mariadb:latest
app:
image: myApp
environment:
DATABASE_HOST: mysql
DATABASE_USERNAME:
DATABASE_PASSWORD:
DATABASE_NAME:
RAILS_ENV:
SPHINX_HOST: search
depends_on:
- dbsearch
- search
search:
image: myApp
command: /app/bin/start-sphinx
environment:
DATABASE_HOST: mysql
DATABASE_USERNAME:
DATABASE_PASSWORD:
DATABASE_NAME:
RAILS_ENV:
SPHINX_HOST: 0.0.0.0
depends_on:
- db
FROM debian AS build
WORKDIR /tmp
RUN apt-get update && \
apt-get install --no-install-recommends -y curl && \
curl http://sphinxsearch.com/files/sphinx-3.2.1-f152e0b-linux-amd64.tar.gz -o sphinx.tar.gz && \
mkdir sphinx && \
tar xfz sphinx.tar.gz -C sphinx/ && \
rm sphinx.tar.gz && \
rm -rf /var/lib/apt/lists/*
FROM ruby:2.6
COPY --from=build /tmp/sphinx/sphinx* /opt/sphinx
ENV PATH="/opt/sphinx/bin:$PATH"
COPY . /app
# Run bundler, etc.
COPY bin/start-app /usr/local/bin/start-app
COPY bin/start-sphinx /usr/local/bin/start-sphinx
CMD ["/app/bin/start-app"]
# bin/start-app
#!/bin/bash
bundle exec rake ts:configure
bundle exec rackup -o 0.0.0.0 -s puma -p 3000 -E $RAILS_ENV
# bin/start-sphinx
#!/bin/bash
bundle exec rake ts:configure
exec searchd --nodetach --config /app/config/sphinx.conf
# config/thinking_sphinx.yml
default: &default
address: <%= ENV.fetch('SPHINX_HOST') { 'search' } %>
mysql41: 9312
skip_running_check: true
configuration_file: 'config/sphinx.conf'
development:
<<: *default
test:
<<: *default
production:
<<: *default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment