社å isuconã§æ°åã«ããã³ãã³ã«ãããã®ã§ãå½¹ç«ããã¨ãã¦ç¤¾å ã«å± å ´æããªããªãããã§ããmix3ã§ãã
@acidlemon ä½ mirage ãã使ã£ã¦ãã¹ãç°å¢ãç«ã¦ã¾ãããã¼ãã¿ãããªãã¨ãå²ã¨å½ããåã«ãªãã¤ã¤ãã£ã¦ä»é¢ãã£ã¦ãããã¸ã§ã¯ãããããã¯ããããããªãã¨ãããã¨ãããã¾ãã¦ã(CentOS6ã ã¨ä¸é½åãããã£ã½ãã¦CentOS7ã«ç§»è¡ãããªãããã¯ãªã¢ãã¦ããã ãã©)
ãããç°å¢ä½ãããããããããã¨ãªã£ã¦ãå°ããªãããã«ç·´ç¿ãã¦ãããã¨æãç«ã£ã¦ãæã¦ä½ãã¦ããããvpsã®ä¸ã¤ãdockerå°ç¨ã«ãã¦ã¿ããã¤ãã§ã«CoreOSãªããã使ã£ã¦ã¿ãã
ISOã®ã¢ãããã¼ããã¦ãªã¢ã¼ãã³ã³ã½ã¼ã«ãéã
ã¨ããã¾ã§ã¯ ãããã®VPSã«CoreOSãã¤ã³ã¹ãã¼ã«ãã¦Dockerå°ç¨æ©ã«ãã - Qiita ãåèã«ãã
sshã§ç¹ã
ã¨ãã㯠CoreOSããããVPSãµã¼ãã«å ¥ãããã¨ãã¦åµã£ãã®ã§ã¡ã¢ - Qiita ãåèã« /etc/systemd/network/static.network ãä½ããã«ä»¥ä¸ãå®è¡ãã
sudo ifconfig <network port> <ip address> netmask <netmask>
sudo route add default gw <default gateway IP>
$ sudo vi /etc/resolv.conf
nameserver <DNS1>
cloud-config
ã CoreOSããããVPSãµã¼ãã«å ¥ãããã¨ãã¦åµã£ãã®ã§ã¡ã¢ - Qiita ãåèã«ãã
#cloud-config
coreos:
units:
- name: static.network
content: |
[Match]
Name=eth0
[Network]
Address=<IPã¢ãã¬ã¹>/<ãµãããããã¹ã¯>
Gateway=<ã²ã¼ãã¦ã§ã¤>
DNS=<DNS1>
DNS=<DNS2>
ssh_authorized_keys:
- ssh-rsa ABCDABCDABCDABCDABCDABCDABCDABCDABCD...
CoreOS ã®ã¤ã³ã¹ãã¼ã«ã¨ reboot
ã¤ã³ã¹ãã¼ã«ã¯ ãããã®VPSã«CoreOSãã¤ã³ã¹ãã¼ã«ãã¦Dockerå°ç¨æ©ã«ãã - Qiita ãåèã«ä»¥ä¸ã®ããã«ããã è¨äºã§ã¯ -C alpha ã ãã© -C stable ã«ãã¦ãããã
$ sudo coreos-install -d /dev/vda -c cloud-config -C stable
reboot 㯠VPS ã®ç®¡çç»é¢ããã sudo reboot ã¨ãããã¨å度 LiveCD 㧠boot ããã¦ãã¾ãã
ãã°ã¤ã³
cloud-configã®è¨å®ã«ãã£ã¦å ¬ééµãè¨å®ããã¦ãã¯ããªã®ã§ãããã§ãã°ã¤ã³åºæ¥ãããã«ãªã£ã¦ãããºã
Docker ç¡ã㧠mirage ãåããã¦ã¿ã
ææ°ã® mirage ãè½ã¨ãã¦ãã https://github.com/acidlemon/mirage/releases/download/v0.2.0/mirage-v0.2.0-linux-amd64.zip
解åããã cp config_sample.yml config.yml ãã¦ç·¨é
host:
# web api host
# you can use API and Web interface through this host
# webapi: docker.dev.example.net
webapi: mirage.sakura
# host suffix
# if you access to foo.dev.example.net, mirage search "foo" subdomain container
reverse_proxy_suffix: .sakura
listen:
# listen address
# default is only listen from localhost
foreign_address: 0.0.0.0
# listen port and reverse proxy port
http:
# listen 8080 and transport to container's 5000 port
- listen: 80
target: 5000
# not implemented
# we recommend to use frontend http(like nginx) to SSL termination
# HTTPS:
# - 443
docker:
# if you use docker through http, specify like "http://localhost:4243"
endpoint: unix:///var/run/docker.sock
# if you specify this, fill the form as default value on web interface.
# default_image: myapp:latest
storage:
datadir: ./data
htmldir: ./html
㧠./mirage ã¨ãã¦èµ·åãã㨠mirage.sakura ã§ã¢ã¯ã»ã¹ãã㨠*.sakura ã§åå解決ã§ããããã«ãªã£ã¦ããã° mirage ã® web interface ãè¦ãã
dnsmasq
ãã¡ã¤ã³æã£ã¦ãå ´åã¯ã*ãã§Aã¬ã³ã¼ãè¨å®ã㦠mirage.sakura, .sakura ãããã«åããã¦è¨å®ããã°è¯ããã¨æããæã£ã¦ãªãå ´å㯠dnsmasq 使ãã¨è¯ãæãã«åå解決ãè¨å®ã§ããã®ã§ããããã
brew install dnsmasq ãã¦æ示ã«å¾ã£ã¦èµ·åãã
$ brew install dnsmasq
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
$ sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
è¨å®ã¯ãã£ãã® *.sakura ã§ããã°ãããªæãã§è¯ããã¨æãã
$ sudo vim /etc/resolver/sakura
nameserver 127.0.0.1
$ vim /usr/local/etc/dnsmasq.conf
address=/sakura/<IP>
Docker 㧠mirage ãèµ·åãã
mirage 㯠Dockerfile ãç¨æããã¦ã㦠Docker ã§èµ·åãããã¨ãã§ããã®ã§è©¦ãã¦ã¿ãã
Dockerfile 㨠config.yml ãæã£ã¦ã㦠config.yml ãå°ãå¤æ´ãã
host:
# web api host
# you can use API and Web interface through this host
# webapi: docker.dev.example.net
webapi: mirage.sakura
# host suffix
# if you access to foo.dev.example.net, mirage search "foo" subdomain container
reverse_proxy_suffix: .sakura
listen:
# listen address
# default is only listen from localhost
foreign_address: 0.0.0.0
# listen port and reverse proxy port
http:
# listen 8080 and transport to container's 5000 port
- listen: 8080
target: 5000
# not implemented
# we recommend to use frontend http(like nginx) to SSL termination
# HTTPS:
# - 443
docker:
# if you use docker through http, specify like "http://localhost:4243"
endpoint: unix:///var/run/docker.sock
# if you specify this, fill the form as default value on web interface.
# default_image: myapp:latest
storage:
datadir: /mirage
htmldir: /opt/mirage/html
ã³ã³ãããèµ·åããã¨ãã®ãã¼ããã©ã¯ã¼ãã®è¨å®ã« listen port ãåããã¦ããã®ã¨ storage ãDocker ç¨ã®ãã®ã«åããã¦ããã
ãã¨ã¯ docker build, docker run ããã ã
$ docker build -t acidlemon/mirage:latest .
$ docker run -d --name mirage -p 80:8080 acidlemon/mirage:latest
ãã¨ã¯ mirage ã使ãã ã
äºç¿å®ç§ãã§ï¼å®ç§ã¨ã¯è¨ã£ã¦ããªãï¼