TL;DR
- imageの指定方法は、下記のフォーマット
openresty/openresty:<openresty-version>-<image-version>-<flavor>
- flavorとはosのことでcentos, alpine などが入る
- 今回はこんな感じになった
openresty/openresty:1.13.6.2-0-centos
- 上記方法でイメージを作れば、すぐにluaを実行可能
設定方法
nginxでluaを実行するために必要な部分のみ抜粋。全体は下記のurlから探してほしい。
docker-compose.yml
volumesで自分の手元のnginx設定をcontainerにマウントした。
version: '3' services: nginx: build: ./docker/nginx container_name: pomodoro-web image: pomodoro-web volumes: - ./docker/nginx/conf.d:/etc/nginx/conf.d ports: - 8080:80
Dockerfile
手元のnginx設定をaddしている。 この設定ファイルはdocker-composeでmountしているから、開発環境ではいらないかも。
FROM openresty/openresty:1.13.6.2-0-centos ADD conf.d/app.conf /etc/nginx/conf.d/app.conf CMD ["/usr/bin/openresty", "-g", "daemon off;"]
nginx app.conf
普通に hello world
server { listen 80; server_name localhost; keepalive_timeout 5; location /hellolua { content_by_lua ' ngx.header["Content-Type"] = "text/plain"; ngx.say("hello world"); '; } }
実行確認
➜ pomodoro git:(master) ✗ curl http://127.0.0.1:8080/hellolua hello world
ということで、問題なく動作していることを確認したぞ!!