LoginSignup
18
20

More than 5 years have passed since last update.

DockerでCloud9

Last updated at Posted at 2018-07-01

Cloud9をDockerで動かしてみる。

Cloud9: https://github.com/c9/core/

READMEによると以下のステップで使えるようになるらしい。

git clone https://github.com/c9/core.git c9sdk
cd c9sdk
scripts/install-sdk.sh
node server.js

結論

https://gist.github.com/fkmt-disk/d50dca8e0841df5a14641f6db45aab9a
↑ここに置いた。

環境は以下のとおり。

2018-07-08追記

  • aws-cli, localstask, apex をDockerfileに追加
  • workspaceの設定をdocker-composeに追加

試行錯誤のログ

とりあえず手でやってみる

docker-compose.yml :

version: "3"

services:
  centos:
    image: centos:7
# 8181番を使うらしいので開けておく
docker-compose run -p 8181:8181 centos bash

git clone https://github.com/c9/core.git c9sdk
# gitがない、と言われる

yum install -y git

git clone https://github.com/c9/core.git c9sdk

cd c9sdk

scripts/install-sdk.sh
# developmentをgroupinstallしろ、と言われる

yum groupinstall -y development

scripts/install-sdk.sh
# glibc-staticを入れろ、と言われる

yum install -y glibc-static

#> scripts/install-sdk.sh: line 97: which: command not found
# のように言われているので、ついでにWhichも入れる

# ・・・whichってどのパッケージ?
yum whatprovides which

# whichはwhichらしい
yum install -y which

# 3度目のチャレンジ
scripts/install-sdk.sh
#> Success!
#> run 'node server.js -p 8080 -a :' to launch Cloud9
# やったぜ!

# 起動コマンドがREADMEと若干違う・・・
# `-p` はたぶんポートだろう。
# `-a` はなにか・・・?

# READMEに戻ってよく読むと
# `--auth Basic Auth username:password`
# とのこと。

# 起動してみる
node server.js -p 8181 -a :
#> bash: node: command not found
# そうですか。。。

# 入れる
yum install -y node
#> No package node available.
# ほう・・・

yum install -y nodejs
#> No package nodejs available.
# むう、、、epelか?

yum install -y epel-release
yum install -y nodejs

# 入った
node -v
#> v6.14.2
# 古いなぁ、、、大丈夫か?

# リトライ
node server.js -p 8181 -a :
#> Starting standalone
#> Connect server listening at http://127.0.0.1:8181
#> CDN: version standalone initialized /c9sdk/build
#> Started '/c9sdk/configs/standalone' with config 'standalone'!
#> Cloud9 is up and running

http://127.0.0.1:8181
アクセスしてみるが動いてない。。。

コンテナの外に出てポートフォワードを確認してみる。

docker-compose ps
#>         Name           Command   State           Ports         
#> ---------------------------------------------------------------
#> centos7_centos_run_1   bash      Up      0.0.0.0:8181->8181/tcp

開いてるっぽい。

READMEに立ち戻る。
--listen IP address of the server ←これか?

# コンテナの中
# リトライ
node server.js -p 8181 --listen 0.0.0.0 -a :

http://localhost:8181/
動いた。

あ、Workspace指定しないとダメだな。

Dockerfileにする

動くようなのでDockerfileにする。

Dockerfile :

FROM centos:7

RUN yum install -y epel-release

RUN yum groupinstall -y development

RUN yum install -y git glibc-static which nodejs

RUN git clone https://github.com/c9/core.git /c9sdk && cd /c9sdk && scripts/install-sdk.sh

RUN mkdir /c9sdk/workspace

WORKDIR /c9sdk/workspace

EXPOSE 8181

docker-compose :

version: "3"

services:
  cloud9:
    build:
      context: "."
    ports:
      - "8181:8181"
    command: "node /c9sdk/server.js -w /c9sdk/workspace --port 8181 --listen 0.0.0.0 --auth :"

いざ。

docker-compose up -d --build

http://localhost:8181/

screenshot.png

できましたー。

18
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
20