Created
August 29, 2016 06:41
-
-
Save phizaz/34cd5383755dce33d6a13a3a1bcee4cf to your computer and use it in GitHub Desktop.
RemoteRun - Example: docker-compose recipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.remoterunignore | |
.remoterun_lock | |
.remoterunrc | |
.git | |
.gitignore | |
.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
host: user@host | |
remote_path: /path/to/the/project/on/your/remote | |
steps: | |
- name: sync to the remote | |
command: [rsync, -a, --exclude-from=.remoterunignore, ./, "{host}:{remote_path}"] | |
- name: build | |
remote: [docker-compose, build] | |
- name: run | |
remote: [docker-compose, up, -d] | |
- name: fetch logs | |
remote: [docker-compose, logs, -f] | |
- name: clear logs | |
remote: [docker-compose, rm, --force] | |
- name: sync back from the remote | |
command: [rsync, -a, --exclude-from=.remoterunignore, "{host}:{remote_path}/", ./] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from eventlet.green import urllib2 | |
urls = [ | |
'http://www.ryylxjw.com/data/out/207/40659650-view-wallpapers.jpg' | |
] * 10 | |
def fetch(url): | |
return urllib2.urlopen(url).read() | |
pool = eventlet.GreenPool() | |
for body in pool.imap(fetch, urls): | |
print("got body", len(body)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
python: | |
build: . | |
working_dir: /run | |
volumes: | |
- ./:/run | |
command: python crawl.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:2 | |
MAINTAINER Konpat Preechakul <[email protected]> | |
RUN pip install eventlet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RemoteRun start running at step sync to the remote | |
(1/6) running "sync to the remote" | |
exec: "rsync -a --exclude-from=.remoterunignore ./ [email protected]:~/Projects/remoterun-example" | |
(2/6) remote running "build" | |
remote exec: "docker-compose build" | |
Building python | |
Step 1 : FROM python:2 | |
---> eb867117097c | |
Step 2 : MAINTAINER Konpat Preechakul <[email protected]> | |
---> Using cache | |
---> 34899020cfe8 | |
Step 3 : RUN pip install eventlet | |
---> Using cache | |
---> a789fdc9cf25 | |
Successfully built a789fdc9cf25 | |
(3/6) remote running "run" | |
remote exec: "docker-compose up -d" | |
Creating remoterunexample_python_1 | |
(4/6) remote running "fetch logs" | |
remote exec: "docker-compose logs -f" | |
Attaching to remoterunexample_python_1 | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
python_1 | ('got body', 528599) | |
remoterunexample_python_1 exited with code 0 | |
(5/6) remote running "clear logs" | |
remote exec: "docker-compose rm --force" | |
Removing remoterunexample_python_1 ... done | |
Going to remove remoterunexample_python_1 | |
(6/6) running "sync back from the remote" | |
exec: "rsync -a --exclude-from=.remoterunignore [email protected]:~/Projects/remoterun-example/ ./" | |
RemoteRun finished! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment