Docker on CircleCIã§chefã®cookbookãserverspecã§ãã¹ã
CircleCIèªä½ãã³ã³ãããªãã ããããã«ãã®ä¸ã§dockerã³ã³ããç«ã¦ã¦cookbookã®ãã¹ããã¦ãã¾ãã¨ããã¢ã¬ã§ãã ãDocker使ãããªãChefè¦ããªãããããã¨ãã話ã¯å¤§è³æãªãã ããæ¢åã®cookbookè³ç£ã使ããããã¨ããã¾ãããã
ã追è¨ãç¶ãã«ããã«ãã¹ãã®æéç縮ããã工夫æ¸ãã
åããã®ï¼
åãã!!!!!!!!!!! æå°éã§åããã¨ããã§ã¿ã°ãåã£ããã³ã¼ãã¯ä¸è¨ãªã³ã¯åç §ã
CircleCIä¸ã§ã
ãchefã§dockerã³ã³ããã«cookãããããserverspecã§ãã¹ãããã
ãå®ç¾ãã¦ãã¾ãã
以ä¸ããã¤ã³ããªã©
CircleCIã§dockerãã©ãæºåããã
ç¡çã«apt-get -y install docker
ã¨ããã£ã¦ã¤ã³ã¹ãã¼ã«ãã¦ããdocker ps
ããè¿ã£ã¦ããªããªãã
å ¬å¼ã«ãµãã¼ããã¦ãserviceã使ãã¨ãã¾ããã£ããä¸è¨ãªã³ã¯åç §ã
ã¨ãããã
machine: services: - docker
ã¿ããã«æ¸ãã¨ãè¦äºã«dockeråãã
ãã ããä½æ
ããruby
ã®ãã¼ã¸ã§ã³ã¯2.1.4
åºå®ã«ãªãã£ã½ãã¦ã.ruby-version
çã¯æ³£ãæ³£ã2.1.4
ã«æ»ãããããããããªãã
CirlceCIä¸ã§ããã¼ã¹ã³ã³ããã®ãã«ã
Dockerfileãã³ããããã¦ããã¦ãtestã®å段é(dependencies)ã§ãã«ãããã°ãããã ãã©ã
... dependencies: override: - docker info - docker build -t hoshinotsuyoshi/centos-sshd . test: ...
ä»å¾ãã£ã¨è¯ãããããã«ã¯ã以ä¸ã®æ§ãªãã¨ãã§ãããã
- Dockerhubã®Automated buildã使ã£ã¦ãpullããã ãã«ãã¦æéç縮
- docker imageããã£ãã·ã¥ãã(æ¹æ³æªç¢ºèª)
CirlceCIä¸ã§ãDockerã³ã³ããã¸ã®SSHãã©ãæºåããã
ä»åã¯éµã~/.ssh/config
ã«æ¸ããããªãã¨ãã³ããããã¦ãã¾ã£ã¦(ãã¹ãç¨ã«ãã使ããªãã®ã§)ã
ãã®è¨å®ãªã©ãcp
ããã§CircleCIã®~/.ssh/
ã«åæ ããã¾ããããããªæãã
test: pre: - ... - cp ./id_rsa_insecure ~/.ssh/id_rsa - sudo chown 600 ~/.ssh/id_rsa - cp ./ssh-config.circleci ~/.ssh/config override: - docker run -d -p 40022:22 hoshinotsuyoshi/centos-sshd; sleep 10 ...
ã追è¨ãããã§ãã¹ãå´ã®ãã¼ãæå®ãã¦ãã®ãã ãã¶ã¤ã±ã¦ãªãã£ããç¶ãã«æ¸ãã
ssh-config.circleci ã¨ãããã¡ã¤ã«ã®ä¸èº«ã¯ããããªæãã
docker run
ã§publishããsshç¨ã®ãã¼ãã¨åãçªå·ãæå®ãã¦ããã
Host centos-sshd HostName 0.0.0.0 User docker Port 40022 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes LogLevel FATAL
以ä¸ã§ã
ãã£ãã·ã¥ã®å¹ããæ¹ã¨ãã«èª²é¡æ®ãã¾ãããªæ°ãããããé£ãªãåãã¦ãCirlceCIãããã
ã追è¨ãç¶ãã«ããã«ãã¹ãã®æéç縮ããã工夫æ¸ãã