A template nodejs application using Nuxt for a component and page rendering server. Nuxt application components load data (when rendering on the server or client) from a GraphQL search endpoint, that retrieves data from an elasticsearch endpoint.
Requires Docker and Docker Compose to be installed on the host machine.
The docker-compose command with pull down all necessary images for Node.js, Elasticsearch, and Nginx, and build the GraphQL and Nuxt server applications (npm run build as defined in each applications Dockerfile).
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Raise Default memory limit on host machine as required by the elasticsearch container. More Details.
Resolves Issue: Invalid kernel settings. Elasticsearch requires at least: vm.max_map_count = 262144.
sudo sysctl -w vm.max_map_count=262144
# Build dev dependencies
docker-compose -f docker-compose-dev.yml build
# Build prod dependencies
docker-compose build
# Using docker-compose >= 1.23.0
docker-compose build --parallel
# Dev
docker-compose -f docker-compose-dev.yml up -d
# Prod
docker-compose up -d
The app should now be available on localhost port 80: http://localhost.
ab -n 5000 -c 50 http://localhost/search
ab -n 12000 -c 100 -T 'application/json' -p example-search-query.json http://localhost/graphql
curl -X PUT "localhost:9200/my-index?pretty" -H 'Content-Type: application/json' -d'
{
"settings" : {
"number_of_shards" : 2
},
"mappings" : {
"properties" : {
"title" : { "type" : "text" }
}
}
}
'
curl http://localhost:9200/_cat/indices
curl -XPOST http://localhost:9200/my-index/1 -d '{"title":"Hello world"}' -H "Content-Type: application/json"
ab -n 12000 -c 100 http://localhost:9200/my-index/_search?q=title:hello