Skip to content

Instantly share code, notes, and snippets.

@phizaz
Created August 29, 2016 06:41
Show Gist options
  • Save phizaz/34cd5383755dce33d6a13a3a1bcee4cf to your computer and use it in GitHub Desktop.
Save phizaz/34cd5383755dce33d6a13a3a1bcee4cf to your computer and use it in GitHub Desktop.
RemoteRun - Example: docker-compose recipe
.remoterunignore
.remoterun_lock
.remoterunrc
.git
.gitignore
.DS_Store
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}/", ./]
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))
version: '2'
services:
python:
build: .
working_dir: /run
volumes:
- ./:/run
command: python crawl.py
FROM python:2
MAINTAINER Konpat Preechakul <[email protected]>
RUN pip install eventlet
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