Skip to content

Instantly share code, notes, and snippets.

@knazarov
Last active September 26, 2016 12:54
Show Gist options
  • Save knazarov/9104385e15a2949d990fcf9f2a1579d9 to your computer and use it in GitHub Desktop.
Save knazarov/9104385e15a2949d990fcf9f2a1579d9 to your computer and use it in GitHub Desktop.
docker-compose + tarantool + nginx upstream module

This is an example of how to create a pair of containers with tarantool and nginx upstream module, using docker-compose.

#!/usr/bin/env tarantool
box.cfg{}
-- Tarantool procedure
function tnt_rest(req)
-- req.headers -- http headers
-- req.uri -- uri
return { 'ok' }
end
version: '2'
services:
tarantool:
image: tarantool/tarantool:1.7
environment:
TARANTOOL_REPLICATION_SOURCE: "tarantool"
networks:
- mynet
ports:
- "3301:3301"
volumes:
- ./app.lua:/opt/tarantool/app.lua
command: ['tarantool', '/opt/tarantool/app.lua']
nginx:
image: tarantool/tarantool-nginx
links:
- tarantool
networks:
- mynet
ports:
- "8080:8080"
volumes:
- ./tarantool.conf:/etc/nginx/conf.d/default.conf
networks:
mynet:
driver: bridge
upstream backend {
server tarantool:3301;
}
server {
listen 8080;
server_name localhost;
location /tnt_rest {
# REST mode on
tnt_http_rest_methods get post put delete; # or all
# Pass http headers and uri
tnt_pass_http_request on;
# Module on
tnt_pass backend;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment