Lightweight Language Diver 2014
久井 亨 Toru Hisai @torus
(関係者の方いたらツッコミお願いします)
git push heroku master
app
tar czfv slug.tgz ./app
./
が重要!heroku run bash
はまどろっこしい仮想マシンにいろいろインストールして
イメージを作る。
FROM ubuntu:10.04
MAINTAINER Toru Hisai <toru@torus.jp>
RUN apt-get update -y
RUN apt-get install -y wget gcc
RUN apt-get install -y zlib1g-dev slib
RUN apt-get install -y make autoconf
WORKDIR /tmp
RUN wget http://prdownloads.sourceforge.net/
gauche/Gauche-0.9.4.tgz
RUN tar xvfz Gauche-0.9.4.tgz
WORKDIR Gauche-0.9.4
RUN ./configure
RUN make
RUN make check
RUN make install
(あらかじめ GitHub からクローンしておく)
ADD Gauche /tmp/Gauche
WORKDIR /tmp/Gauche
RUN ./DIST gen
RUN ./configure --prefix=/opt/gauche
RUN make
RUN make check
RUN make install
ENV PATH /opt/gauche/bin:$PATH
(あらかじめ GitHub からクローンしておく)
ADD Gauche-makiki /tmp/Gauche-makiki
WORKDIR /tmp/Gauche-makiki
RUN ./DIST gen
RUN ./configure --prefix=/opt/gauche
RUN make
RUN make check
RUN make install
(あらかじめ GitHub からクローンしておく)
ADD Gauche-gl /tmp/Gauche-gl
WORKDIR /tmp/Gauche-gl
RUN ./DIST gen
RUN ./configure --prefix=/opt/gauche
RUN make
RUN make check
RUN make install
エントリーポイントでバイナリをダンプする。
WORKDIR /opt
ENTRYPOINT tar cf - gauche
$ docker build -t gauche_heroku_app .
$ docker run gauche_heroku_app |\
(cd app && tar xvf -)
(use makiki)
(define-http-handler "/render.ppm"
(^[req app]
(random-source-randomize! default-random-source)
(let ([param-size (request-param-ref req "size")]
[param-frame (request-param-ref req "frame")])
(let ([opt-size (if param-size #`"-s ,param-size" "")]
[opt-frame (if param-frame #`"-f ,param-frame" "")]
[outfile #`"out,(random-integer 1000000).jpg"])
(respond/ok req
(with-output-to-string
(lambda ()
((global-variable-ref raytracer-mod 'main)
`(self ,@(string-split opt-size #/\s+/)
,@(string-split opt-frame #/\s+/)))))
:content-type "image/x-portable-pixmap")))))
slug.tgz: $(SOURCES) ../docker/gauche/app/gauche
rm -rf app
mkdir app
cp -R ../docker/gauche/app/gauche app/gauche
cp -R $(SOURCES) app/
tar cfz $@ ./app
をコピーしてアーカイブ。
{"process_types":
{"web":"./gauche/bin/gosh
-I ./gauche/share/gauche-0.9/0.9.4/lib
-I ./gauche/share/gauche-0.9/site/lib
-I ./gauche/lib/gauche-0.9/0.9.4/
x86_64-unknown-linux-gnu/
-I ./gauche/lib/gauche-0.9/site/
x86_64-unknown-linux-gnu/
-I ./
index.scm --port=$PORT"}}
slug.json: slug.tgz
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.heroku+json; version=3' \
-d '{"process_types":{"web":"./gauche/bin/gosh \
-I ./gauche/share/gauche-0.9/0.9.4/lib \
-I ./gauche/share/gauche-0.9/site/lib \
-I ./gauche/lib/gauche-0.9/0.9.4/x86_64-unknown-linux-gnu/ \
-I ./gauche/lib/gauche-0.9/site/x86_64-unknown-linux-gnu/ \
-I ./ index.scm --port=$$PORT"}}' \
-n https://api.heroku.com/apps/$(APPNAME)/slugs > $@
{
"blob":{
"method":"put",
"url":"https://s3-external-1.amazonaws.com/herokuslugs/heroku.com/v1/7e4d9819-833f-4aec-9d6f-af112eacd530?AWSAccessKeyId=AKIAJWLOWWHPBWQOPJZQ&Signature=Wu5b7n7S6NgxBYGXolq6AdBoqSY%3D&Expires=1406388246"
},
"buildpack_provided_description":null,
"commit":null,
"created_at":"2014-07-26T14:24:06Z",
"id":"7e4d9819-833f-4aec-9d6f-af112eacd530",
"process_types":{
"web":"./gauche/bin/gosh -I ./gauche/share/gauche-0.9/0.9.4/lib -I ./gauche/share/gauche-0.9/site/lib -I ./gauche/lib/gauche-0.9/0.9.4/x86_64-unknown-linux-gnu/ -I ./gauche/lib/gauche-0.9/site/x86_64-unknown-linux-gnu/ -I ./ index.scm --port=$PORT"
},
"size":null,
"updated_at":"2014-07-26T14:24:06Z"
}
upload-slug: slug.json
curl -X PUT \
-H "Content-Type:" \
--data-binary @slug.tgz \
`gosh extract-slug-url.scm < slug.json`
extract-slug-url.scm
は先のレスポンスから blob
の url
を取り出すhttps://s3-external-1.amazonaws.com/herokuslugs/...
LD_LIBRARY_PATH
を設定$ heroku config:set LD_LIBRARY_PATH=./gauche/lib \
--app=$APPNAME
release: upload-slug
curl -X POST \
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Content-Type: application/json" \
-d '{"slug":"'`gosh extract-slug-id.scm \
< slug.json`'"}' \
-n https://api.heroku.com/apps/$(APPNAME)/releases
extract-slug-id.scm
は先のレスポンスから Slug の ID を取り出す7e4d9819-833f-4aec-9d6f-...
(Slug のアップロードとリリース)
Table of contents | t |
---|---|
Exposé | ESC |
Autoscale | e |
Full screen slides | f |
Presenter view | p |
Source files | s |
Slide numbers | n |
Blank screen | b |
Notes | 2 |
Help | h |