Add Elasticsearch to Docker Compose (#5978)

* Copy .ruby-version into Dockerfile
* Add Elasticsearch to Docker Compose
This commit is contained in:
Michael Kohl 2020-02-11 23:45:16 +07:00 committed by GitHub
parent 30e2fd5017
commit 38e980917d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

3
.gitignore vendored
View file

@ -69,3 +69,6 @@ docs/.static/api/
# asdf
.tool-versions
# ES docker volume
docker_data/

View file

@ -7,10 +7,12 @@ services:
depends_on:
- db
- redis
- elasticsearch
environment:
RAILS_ENV: development
DATABASE_URL: postgres://postgres:mysecretpassword@db:5432/postgres
YARN_INTEGRITY_ENABLED: "false"
ELASTICSEARCH_URL: http://elasticsearch:9200
volumes:
- .:/usr/src/app
command: bundle exec rails server -b 0.0.0.0 -p 3000
@ -33,3 +35,23 @@ services:
image: "redis"
ports:
- "6379:6379"
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.2
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.type=single-node"
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- xpack.graph.enabled=false
- xpack.watcher.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./docker_data/elasticsearch/data:/usr/share/elasticsearch/data
ports:
- "9200:9200"

View file

@ -71,6 +71,7 @@ and start the container again_
1. run `docker-compose build`
1. run `docker-compose run web rails db:setup`
1. run `docker-compose run web yarn`
1. run `docker-compose run web rails search:setup`
1. run `docker-compose up`
1. That's it! Navigate to <http://localhost:3000>
@ -84,3 +85,11 @@ Please execute the script itself to view all additional options:
```shell
./docker-run.sh
```
## Known Problems & Solutions
- Should you experience problems with the ElasticSearch container, try to
increase the memory and/or swap allocation for Docker. On macOS this can be
done via the GUI:
![docker gui](https://user-images.githubusercontent.com/47985/74210448-b63b7c80-4c83-11ea-959b-02249b2a6952.png)