├── images ├── PWD-5555.png ├── code_gif.gif ├── lang_sel.png └── python_sample0.png ├── static └── TIME2CODE-grey.png ├── .gitignore ├── time2deploy.sh ├── docker-compose.yml ├── code.txt ├── FortranSample.md ├── Sample.md ├── Dockerfile.nofaas ├── minikube.sh ├── deploy_pwk.sh ├── Dockerfile ├── time2code-faas-cli-functions.yml ├── LICENSE ├── ide.py ├── time2code-server-k8s.yml ├── handler.py ├── QuickCodeTutorial.md ├── ide_server.py ├── templates ├── alloy_server.html ├── base_test_server.html ├── base_test.html ├── boostrap_server.html ├── index-tut.html ├── index-tutorial.html ├── index.html └── index-panel.html ├── QuickCodeTutorial_PWK.md ├── CONTRIBUTING.md ├── ide-server.py ├── README.md ├── k8s_templates ├── str8_k8s.yml ├── faas_function_k8s.yml └── aci-beta.yml └── time2code-swarm-deploy.yml /images/PWD-5555.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/PWD-5555.png -------------------------------------------------------------------------------- /images/code_gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/code_gif.gif -------------------------------------------------------------------------------- /images/lang_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/lang_sel.png -------------------------------------------------------------------------------- /images/python_sample0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/images/python_sample0.png -------------------------------------------------------------------------------- /static/TIME2CODE-grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JockDaRock/Time2Code/HEAD/static/TIME2CODE-grey.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Example user template template 3 | ### Example user template 4 | 5 | # IntelliJ project files 6 | .idea 7 | *.iml 8 | out 9 | gen 10 | .time2code-faas-cli-minikube.yml 11 | -------------------------------------------------------------------------------- /time2deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Deploying Time2Code on FaaS" 4 | curl -O https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time2code-swarm-deploy.yml 5 | docker stack deploy time2code --compose-file time2code-swarm-deploy.yml -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.0" 2 | services: 3 | time2codeserver: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile.nofaas 7 | image: jockdarock/time2codeserver:latest 8 | networks: 9 | - time2net 10 | ports: 11 | - "5555:5555" 12 | networks: 13 | time2net: 14 | driver: overlay -------------------------------------------------------------------------------- /code.txt: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | url = "https://sandboxapicem.cisco.com/api/v1/ticket" 5 | 6 | payload = {"username": "devnetuser", "password": "Cisco123!"} 7 | data = json.dumps(payload) 8 | print(data) 9 | headers = {"content-type": "application/json"} 10 | 11 | response = requests.post(url, data=data, headers=headers, verify=False) 12 | 13 | print(response.text) -------------------------------------------------------------------------------- /FortranSample.md: -------------------------------------------------------------------------------- 1 | # Test out your code 2 | 3 | ## Random instructions 4 | 5 | Like any programming language, we need to start with Hello World. Click the code 6 | 7 | ```fortran 8 | program hello 9 | Print *, "Hello World!" 10 | end program Hello 11 | ``` 12 | 13 | Then click the `RUN IT` button at the bottom navigation bar. 14 | 15 | Wait a sec... 16 | 17 | dot dot dot 18 | 19 | and your code is complete. 20 | 21 | -------------------------------------------------------------------------------- /Sample.md: -------------------------------------------------------------------------------- 1 | # Test out your code 2 | 3 | ## Random instructions 4 | 5 | Stick this code in the right panel. 6 | 7 | ```python 8 | import requests 9 | 10 | url = "https://httpbin.org/get" 11 | 12 | r = requests.get(url) 13 | 14 | print(r.status_code) 15 | print(r.headers) 16 | print(r.text) 17 | ``` 18 | 19 | Then click the `RUN IT` button at the bottom navigation bar. 20 | 21 | Wait a sec... 22 | 23 | dot dot dot 24 | 25 | and the your code complete. 26 | 27 | -------------------------------------------------------------------------------- /Dockerfile.nofaas: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | RUN apk add -Uuv --no-cache python3 \ 4 | && apk upgrade -v --available --no-cache \ 5 | && apk add ca-certificates && pip3 install --no-cache-dir --upgrade pip setuptools wheel \ 6 | && pip3 install requests flask markdown pymdown.extensions Pygments 7 | 8 | WORKDIR /root/ 9 | 10 | COPY static ./static 11 | COPY ide-server.py . 12 | COPY templates ./templates 13 | 14 | EXPOSE 5555 15 | 16 | CMD ["python3", "ide-server.py"] -------------------------------------------------------------------------------- /minikube.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | git clone https://github.com/alexellis/faas-netes 4 | 5 | curl -sSL cli.get-faas.com | sudo sh 6 | 7 | kubectl apply -f faas-netes/faas.yml,faas-netes/monitoring.yml,./time2code-server-k8s.yml 8 | 9 | sed "s/localhost:31112/$(minikube ip):31112/" time2code-faas-cli-functions.yml > .time2code-faas-cli-minikube.yml 10 | 11 | echo "Load the Code execution Functions with the faas-cli and then navigate to this site http://$(minikube ip):31114 in your favorite browser." 12 | -------------------------------------------------------------------------------- /deploy_pwk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | yum update -y && yum install -y git 4 | 5 | kubeadm init --apiserver-advertise-address $(hostname -i) && \ 6 | kubectl apply -n kube-system -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" 7 | 8 | cd /root/ 9 | git clone https://github.com/alexellis/faas-netes.git \ 10 | && cd faas-netes && kubectl apply -f faas.yml,rbac.yml,monitoring.yml 11 | 12 | cd /root/ 13 | curl -sSL cli.get-faas.com | sh 14 | git clone https://github.com/JockDaRock/Time2Code.git \ 15 | && cd Time2Code && git checkout dev 16 | faas-cli -action deploy -f ~/Time2Code/time2code-faas-cli-functions.yml 17 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | RUN apk add -Uuv --no-cache python3 \ 4 | && apk upgrade -v --available --no-cache \ 5 | && apk add ca-certificates && pip3 install --no-cache-dir --upgrade pip setuptools wheel \ 6 | && pip3 install requests flask markdown 7 | 8 | # ADD https://github.com/alexellis/faas/releases/download/0.6.15/fwatchdog /usr/bin 9 | ADD https://github.com/openfaas-incubator/of-watchdog/releases/download/0.2.1/of-watchdog /usr/bin/fwatchdog 10 | 11 | 12 | RUN chmod +x /usr/bin/fwatchdog 13 | 14 | WORKDIR /root/ 15 | 16 | # COPY ide.py . 17 | COPY ide_server.py . 18 | COPY handler.py . 19 | COPY templates ./templates 20 | 21 | ENV fprocess="python3 handler.py" 22 | ENV cgi_headers="true" 23 | ENV cgi_body="true" 24 | ENV mode="serializing" 25 | ENV content_type="text/html" 26 | 27 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 28 | 29 | CMD ["fwatchdog"] -------------------------------------------------------------------------------- /time2code-faas-cli-functions.yml: -------------------------------------------------------------------------------- 1 | provider: 2 | name: faas 3 | gateway: http://localhost:31112 4 | 5 | functions: 6 | time2code: 7 | fprocess: python3 handler.py 8 | image: jockdarock/time2code:master 9 | golang: 10 | fprocess: python3 time2go.py 11 | image: jockdarock/time2go:latest 12 | 13 | python3: 14 | fprocess: python3 time2py.py 15 | image: jockdarock/time2py:latest 16 | 17 | powershell: 18 | fprocess: python3 time2powershell.py 19 | image: jockdarock/time2powershell:latest 20 | 21 | nodejs: 22 | fprocess: python3 time2nodejs.py 23 | image: jockdarock/time2nodejs:latest 24 | 25 | csharp-experimental: 26 | fprocess: python3 time2CSharp.py 27 | image: jockdarock/time2csharp:latest 28 | 29 | fortran: 30 | fprocess: python3 time2fortran.py 31 | image: jockdarock/time2fortran:latest 32 | 33 | ruby: 34 | fprocess: python3 time2ruby.py 35 | image: jockdarock/time2ruby:latest 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kristopher Jock Reed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ide.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template, Markup 2 | import requests 3 | from urllib.parse import urlparse 4 | import markdown 5 | from wsgiref.handlers import CGIHandler 6 | 7 | app = Flask(__name__) 8 | 9 | 10 | @app.route('/') 11 | def time2code(): 12 | url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md" 13 | r = requests.get(url) 14 | mark = r.text 15 | 16 | content = Markup(markdown.markdown(mark)) 17 | return render_template('index-panel.html', markd=content) 18 | 19 | 20 | class ProxyFix(object): 21 | def __init__(self, app): 22 | self.app = app 23 | 24 | def __call__(self, environ, start_response): 25 | environ['SERVER_NAME'] = "localhost" 26 | environ['SERVER_PORT'] = "8080" 27 | environ['REQUEST_METHOD'] = "GET" 28 | environ['SCRIPT_NAME'] = "" 29 | environ['PATH_INFO'] = "/" 30 | environ['QUERY_STRING'] = "" 31 | environ['SERVER_PROTOCOL'] = "HTTP/1.1" 32 | return self.app(environ, start_response) 33 | 34 | if __name__ == '__main__': 35 | app.wsgi_app = ProxyFix(app.wsgi_app) 36 | CGIHandler().run(app) 37 | -------------------------------------------------------------------------------- /time2code-server-k8s.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: time2codeserver 5 | spec: 6 | type: LoadBalancer 7 | ports: 8 | - name: time2codeserver-5555 9 | port: 5555 10 | protocol: TCP 11 | targetPort: 5555 12 | selector: 13 | app: time2codeserver 14 | component: time2codeserver 15 | 16 | --- 17 | apiVersion: extensions/v1beta1 18 | kind: Deployment 19 | metadata: 20 | name: time2codeserver 21 | spec: 22 | replicas: 3 23 | rollbackTo: 24 | revision: 0 25 | selector: 26 | matchLabels: 27 | app: time2codeserver 28 | component: time2codeserver 29 | strategy: 30 | rollingUpdate: 31 | maxSurge: 3 32 | maxUnavailable: 1 33 | type: RollingUpdate 34 | template: 35 | metadata: 36 | labels: 37 | app: time2codeserver 38 | component: time2codeserver 39 | spec: 40 | containers: 41 | - image: jockdarock/time2codeserver:latest 42 | name: time2codeserver 43 | imagePullPolicy: Always 44 | env: 45 | - name: time2code_provider_url 46 | value: "http://time2codeserver.default:5555" 47 | ports: 48 | - containerPort: 5555 49 | protocol: TCP 50 | restartPolicy: Always 51 | -------------------------------------------------------------------------------- /handler.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from wsgiref.handlers import CGIHandler 3 | import os 4 | from ide_server import app 5 | 6 | query_params = os.getenv("Http_Query", default="") 7 | whole_path = os.getenv("Http_Path", default="/ip") 8 | split_path = whole_path.split('/') 9 | if len(split_path) > 3: 10 | route_path = '/' + '/'.join(split_path[3:]) 11 | else: 12 | route_path = "/" 13 | http_method = os.getenv("Http_Method", default="GET") 14 | 15 | 16 | class ProxyFix(object): 17 | def __init__(self, app): 18 | self.app = app 19 | 20 | def __call__(self, environ, start_response): 21 | environ['SERVER_NAME'] = "127.0.0.1" 22 | environ['SERVER_PORT'] = "8080" 23 | environ['REQUEST_METHOD'] = http_method 24 | environ['SCRIPT_NAME'] = "" 25 | environ['PATH_INFO'] = route_path 26 | environ['QUERY_STRING'] = query_params 27 | environ['SERVER_PROTOCOL'] = "HTTP/1.1" 28 | environ['Http_X_Forwarded_For'] = os.getenv("Http_X_Forwarded_For", "127.0.0.1") 29 | return self.app(environ, start_response) 30 | 31 | 32 | class HeaderRewriterFix(object): 33 | 34 | def __init__(self, app, remove_headers=None, add_headers=None): 35 | self.app = app 36 | self.remove_headers = set(x.lower() for x in (remove_headers or ())) 37 | self.add_headers = list(add_headers or ()) 38 | 39 | def __call__(self, environ, start_response): 40 | def rewriting_start_response(status, headers, exc_info=None): 41 | new_headers = [] 42 | return start_response(status, new_headers, exc_info) 43 | return self.app(environ, rewriting_start_response) 44 | 45 | if __name__ == '__main__': 46 | app.wsgi_app = ProxyFix(app.wsgi_app) 47 | app.wsgi_app = HeaderRewriterFix(app.wsgi_app, remove_headers=['Status']) 48 | CGIHandler().run(app) 49 | -------------------------------------------------------------------------------- /QuickCodeTutorial.md: -------------------------------------------------------------------------------- 1 | ## Code Tutorial 2 | 3 | This is a quick tutorial to highlight the tutorial page feature of Time2Code. It is generated from MarkDown pages on GitHub. 4 | 5 | I will do a few quick HTTP Request code examples you can try in a few languages. 6 | 7 | ### Golang 8 | 9 | Select the Golang code language from the menu button on the bottom navbar. 10 | 11 | ![](https://raw.githubusercontent.com/JockDaRock/Time2Code/master/images/lang_sel.png) 12 | 13 | Then enter the Code below in the **IDE** on the **right**. 14 | 15 | ```golang 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "net/http" 21 | "io/ioutil" 22 | ) 23 | 24 | func main() { 25 | 26 | url := "http://api.open-notify.org/iss-now.json" 27 | 28 | req, _ := http.NewRequest("GET", url, nil) 29 | 30 | req.Header.Add("cache-control", "no-cache") 31 | 32 | res, _ := http.DefaultClient.Do(req) 33 | 34 | defer res.Body.Close() 35 | body, _ := ioutil.ReadAll(res.Body) 36 | 37 | fmt.Println(res) 38 | fmt.Println(string(body)) 39 | 40 | } 41 | ``` 42 | Click the **RUN IT** button and watch as your code is executed quickly. 43 | 44 | Click the **CLEAR TERM** button once you are done and Repeat the same steps as above for the NodeJS and Python examples. 45 | 46 | **AND Dont forget to select the appropriate code langauge when running the different code snippets.** 47 | 48 | ### NodeJS 49 | 50 | ```node 51 | var request = require("request"); 52 | 53 | var options = { method: 'GET', 54 | url: 'http://api.open-notify.org/iss-now.json', 55 | headers: { 'cache-control': 'no-cache' } }; 56 | 57 | request(options, function (error, response, body) { 58 | if (error) throw new Error(error); 59 | 60 | console.log(body); 61 | }); 62 | ``` 63 | 64 | ### Python 65 | 66 | 67 | ```python 68 | import requests 69 | 70 | url = "http://api.open-notify.org/iss-now.json" 71 | 72 | r = requests.get(url) 73 | 74 | print(r.text) 75 | ``` 76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | -------------------------------------------------------------------------------- /ide_server.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template, Markup 2 | import requests 3 | from urllib.parse import urlparse 4 | import markdown 5 | import os 6 | import subprocess 7 | import socket 8 | 9 | 10 | app = Flask(__name__) 11 | 12 | 13 | @app.route('/') 14 | def time2code(): 15 | text = request.args.get('code') 16 | lang = request.args.get('lang') 17 | straight_text = request.args.get('straight_text') 18 | code_text = "" 19 | 20 | if text: 21 | r_text = requests.get(text + "?raw=true") 22 | code_text = r_text.text 23 | elif straight_text: 24 | code_text = straight_text 25 | else: 26 | code_text = "" 27 | 28 | if lang: 29 | code_lang = lang 30 | else: 31 | code_lang = "python3" 32 | 33 | return render_template('index.html', code_text=code_text, code_lang=code_lang) 34 | 35 | 36 | @app.route('/tutorial') 37 | def tutorial(): 38 | text = request.args.get('code') 39 | lang = request.args.get('lang') 40 | straight_text = request.args.get('straight_text') 41 | get_tut = request.args.get('tut') 42 | code_text = "" 43 | tut_url = "" 44 | mark = "" 45 | 46 | if get_tut: 47 | tut_url = get_tut + "?raw=true" 48 | r_tut = requests.get(tut_url) 49 | mark = r_tut.text 50 | else: 51 | tut_url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md?raw=true" 52 | r_tut = requests.get(tut_url) 53 | mark = r_tut.text 54 | 55 | if text: 56 | r_text = requests.get(text + "?raw=true") 57 | code_text = r_text.text 58 | elif straight_text: 59 | code_text = straight_text 60 | 61 | if lang: 62 | code_lang = lang 63 | else: 64 | code_lang = "python3" 65 | 66 | content = Markup(markdown.markdown(mark, extensions=['pymdownx.github', 'pymdownx.highlight'])) 67 | return render_template('index-tutorial.html', markdown=content, code_text=code_text, code_lang=code_lang) 68 | 69 | 70 | if __name__ == '__main__': 71 | app.run(host="0.0.0.0", port=5555, debug=True) 72 | 73 | -------------------------------------------------------------------------------- /templates/alloy_server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Base Test Une 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 | 17 | 22 |
23 |
24 |
25 |
26 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /QuickCodeTutorial_PWK.md: -------------------------------------------------------------------------------- 1 | ## Code Tutorial 2 | 3 | This is a quick tutorial to highlight the tutorial page feature of Time2Code. It is generated from MarkDown pages on GitHub. 4 | 5 | I will do a few quick HTTP Request code examples you can try in a few languages. 6 | 7 | If you are viewing this on GitHub you will need to get Time2Code started before you can do anything else. 8 | 9 | First click the **Try in PWD** Button. 10 | 11 | [![Try in PWD](https://cdn.rawgit.com/play-with-docker/stacks/cff22438/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/JockDaRock/Time2Code/master/time2code-swarm-deploy.yml&stack_name=time2code) 12 | 13 | Once Time2Code is started up click the 5555 tab at the top of the Play-With-Docker site. 14 | 15 | ![](https://raw.githubusercontent.com/JockDaRock/Time2Code/master/images/PWD-5555.png) 16 | 17 | Add `/tutorial?tut=https://github.com/JockDaRock/Time2Code/blob/master/QuickCodeTutorial.md` to the URL in the browser. 18 | 19 | Continue with the instructions below... 20 | 21 | ### Golang 22 | 23 | Select the Golang code language from the menu button on the bottom navbar. 24 | 25 | ![](https://raw.githubusercontent.com/JockDaRock/Time2Code/master/images/lang_sel.png) 26 | 27 | Then enter the Code below in the **IDE** on the **right**. 28 | 29 | ```Golang 30 | package main 31 | 32 | import ( 33 | "fmt" 34 | "net/http" 35 | "io/ioutil" 36 | ) 37 | 38 | func main() { 39 | 40 | url := "http://api.open-notify.org/iss-now.json" 41 | 42 | req, _ := http.NewRequest("GET", url, nil) 43 | 44 | req.Header.Add("cache-control", "no-cache") 45 | 46 | res, _ := http.DefaultClient.Do(req) 47 | 48 | defer res.Body.Close() 49 | body, _ := ioutil.ReadAll(res.Body) 50 | 51 | fmt.Println(res) 52 | fmt.Println(string(body)) 53 | 54 | } 55 | ``` 56 | Click the **RUN IT** button and watch as your code is executed quickly. 57 | 58 | Click the **CLEAR TERM** button once you are done and Repeat the same steps as above for the NodeJS and Python examples. 59 | 60 | **AND Dont forget to select the appropriate code language when running the different code snippets.** 61 | 62 | ### NodeJS 63 | 64 | ```NodeJS 65 | var request = require("request"); 66 | 67 | var options = { method: 'GET', 68 | url: 'http://api.open-notify.org/iss-now.json', 69 | headers: { 'cache-control': 'no-cache' } }; 70 | 71 | request(options, function (error, response, body) { 72 | if (error) throw new Error(error); 73 | 74 | console.log(body); 75 | }); 76 | ``` 77 | 78 | ### Python 79 | 80 | 81 | ```Python 82 | import requests 83 | 84 | url = "http://api.open-notify.org/iss-now.json" 85 | 86 | r = requests.get(url) 87 | 88 | print(r.text) 89 | ``` 90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | ### Guidelines 4 | 5 | Here are a few guidelines for contributing: 6 | 7 | * If you have found a bug please raise an issue and fill out the whole template. 8 | * Don't raise PRs for typos, these aren't necessary - just raise an Issue 9 | * If you would like to contribute to the codebase please raise an issue to propose the change and fill out the whole template. 10 | * If the documentation can be improved / translated etc please raise an issue to discuss. 11 | 12 | * Please always provide a summary of what you changed, how you did it and how it can be tested. 13 | 14 | ### Community 15 | 16 | This project is written in mostly HTML and Javascript on the frontend, Python-Flask for serving the WebIDE Pages, and Python for the code execution management on the OpenFaaS framework. If you'd like to help in any way then that would be more than welcome whatever your level of experience. 17 | 18 | ### License 19 | 20 | This project is licensed under the MIT License. 21 | 22 | #### Sign your work 23 | 24 | The sign-off is a simple line at the end of the explanation for a patch. Your 25 | signature certifies that you wrote the patch or otherwise have the right to pass 26 | it on as an open-source patch. The rules are pretty simple: if you can certify 27 | the below (from [developercertificate.org](http://developercertificate.org/)): 28 | 29 | ``` 30 | Developer Certificate of Origin 31 | Version 1.1 32 | 33 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 34 | 1 Letterman Drive 35 | Suite D4700 36 | San Francisco, CA, 94129 37 | 38 | Everyone is permitted to copy and distribute verbatim copies of this 39 | license document, but changing it is not allowed. 40 | 41 | Developer's Certificate of Origin 1.1 42 | 43 | By making a contribution to this project, I certify that: 44 | 45 | (a) The contribution was created in whole or in part by me and I 46 | have the right to submit it under the open source license 47 | indicated in the file; or 48 | 49 | (b) The contribution is based upon previous work that, to the best 50 | of my knowledge, is covered under an appropriate open source 51 | license and I have the right under that license to submit that 52 | work with modifications, whether created in whole or in part 53 | by me, under the same open source license (unless I am 54 | permitted to submit under a different license), as indicated 55 | in the file; or 56 | 57 | (c) The contribution was provided directly to me by some other 58 | person who certified (a), (b) or (c) and I have not modified 59 | it. 60 | 61 | (d) I understand and agree that this project and the contribution 62 | are public and that a record of the contribution (including all 63 | personal information I submit with it, including my sign-off) is 64 | maintained indefinitely and may be redistributed consistent with 65 | this project or the open source license(s) involved. 66 | ``` 67 | 68 | Then you just add a line to every git commit message: 69 | 70 | Signed-off-by: Joe Smith 71 | 72 | Use your real name (sorry, no pseudonyms or anonymous contributions.) 73 | 74 | If you set your `user.name` and `user.email` git configs, you can sign your 75 | commit automatically with `git commit -s`. 76 | 77 | * Please sign your commits with `git commit -s` so that commits are traceable. -------------------------------------------------------------------------------- /ide-server.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template, Markup 2 | import requests 3 | from urllib.parse import urlparse 4 | import markdown 5 | import os 6 | import subprocess 7 | import socket 8 | 9 | 10 | app = Flask(__name__) 11 | 12 | try: 13 | # Looking for the IP address on the K8s 14 | faas = "faas-netesd.default" 15 | ip = socket.getaddrinfo(faas, 0, 0, 0, 0) 16 | faas_port = 8080 17 | swarm_tag = "" 18 | except Exception: 19 | # finds Docker swarm host IP upon no K8s 20 | p1 = subprocess.Popen(["/sbin/ip", "route"], stdout=subprocess.PIPE) 21 | p2 = subprocess.Popen(["awk", "/default/ { print $3 }"], stdin=p1.stdout, stdout=subprocess.PIPE) 22 | faas = (p2.stdout).read().decode("utf-8").replace("\n", "") 23 | faas_port = 8080 24 | swarm_tag = "time2code_" 25 | 26 | 27 | @app.route('/') 28 | def time2code(): 29 | text = request.args.get('code') 30 | lang = request.args.get('lang') 31 | straight_text = request.args.get('straight_text') 32 | code_text = "" 33 | 34 | if text: 35 | r_text = requests.get(text + "?raw=true") 36 | code_text = r_text.text 37 | elif straight_text: 38 | code_text = straight_text 39 | else: 40 | code_text = "" 41 | 42 | if lang: 43 | code_lang = lang 44 | else: 45 | code_lang = "python3" 46 | 47 | return render_template('index-panel.html', code_text=code_text, code_lang=code_lang) 48 | 49 | 50 | @app.route('/code', methods=['POST']) 51 | def code(): 52 | if request.method == 'POST': 53 | data = request.data 54 | lang = request.args.get('lang') 55 | hosturl = urlparse(request.url) 56 | host = hosturl.hostname 57 | # url = "http://%s:%s/function/time2py" % host 58 | url = "http://%s:%s/function/%s%s" % (faas, faas_port, swarm_tag, lang) 59 | # print(url) 60 | headers = {"Content-Type": "text/plain"} 61 | 62 | code_exec = requests.post(url, data=data, headers=headers) 63 | 64 | resp = code_exec.text 65 | 66 | # print(resp) 67 | 68 | return resp 69 | 70 | 71 | @app.route('/tutorial') 72 | def tutorial(): 73 | text = request.args.get('code') 74 | lang = request.args.get('lang') 75 | straight_text = request.args.get('straight_text') 76 | get_tut = request.args.get('tut') 77 | code_text = "" 78 | tut_url = "" 79 | mark = "" 80 | 81 | if get_tut: 82 | tut_url = get_tut + "?raw=true" 83 | r_tut = requests.get(tut_url) 84 | mark = r_tut.text 85 | else: 86 | tut_url = "https://raw.githubusercontent.com/JockDaRock/Time2Code/master/Sample.md?raw=true" 87 | r_tut = requests.get(tut_url) 88 | mark = r_tut.text 89 | 90 | if text: 91 | r_text = requests.get(text + "?raw=true") 92 | code_text = r_text.text 93 | elif straight_text: 94 | code_text = straight_text 95 | 96 | if lang: 97 | code_lang = lang 98 | else: 99 | code_lang = "python3" 100 | 101 | content = Markup(markdown.markdown(mark, extensions=['pymdownx.github', 'pymdownx.highlight'])) 102 | return render_template('index-tut.html', markdown=content, code_text=code_text, code_lang=code_lang) 103 | 104 | 105 | if __name__ == '__main__': 106 | app.run(host="0.0.0.0", port=5555, debug=True) 107 | 108 | -------------------------------------------------------------------------------- /templates/base_test_server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Base Test Une 5 | 6 | 7 | 8 | 9 | 25 |
26 | 27 |
28 | 33 |
34 | 35 |
36 |
37 | 82 | 83 | 84 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /templates/base_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Base Test Une 5 | 6 | 7 | 8 | 9 | 25 |
26 | 27 |
28 | 33 |
34 | 35 |
36 |
37 | 82 | 83 | 84 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Time2Code 2 | A portable, scalable web based code editor to integrate into your code learning experiences. 3 | 4 | The goal is to make deploying your own web based code editor easier and more fun. 5 | 6 | ![](/images/code_gif.gif) 7 | 8 | ## Tech Overview 9 | * The Code execution backend is built off of the serverless [FaaS](http://docs.get-faas.com/) Framework for scalability and ability to support many languages. Support for [k8s](https://kubernetes.io/) is ready through [faas-netes](https://github.com/alexellis/faas-netes) and appears to be working well. 10 | 11 | * UI Modelled after the wonderful [Play-with-Moby Site](http://play-with-moby.com) and the wonderful work the guys at [Play-With-Docker](https://github.com/play-with-docker/play-with-docker) do to make our Docker Learning Experiences Better. 12 | 13 | * Function handling and code execution are being handled by Python processes. Python handles the STDIN of all of the function requests and then passes it to the desired language for interpretation and execution or compilation and execution. 14 | 15 | * Web site is being driven by the [Flask](http://flask.pocoo.org/) Framework 16 | 17 | * Code editor is built from [Ace Editor](https://ace.c9.io/) project. 18 | 19 | * Terminal is built from [XTermJS](https://xtermjs.org/). 20 | 21 | ## Up and Running 22 | 23 | ### Docker Swarm 24 | 25 | The following snippet will initialize your swarm, Time2Code, FaaS and Time2code functions. 26 | 27 | ```sh 28 | $ docker swarm init --advertise-addr eth0 && \ 29 | git clone https://github.com/JockDaRock/Time2Code && \ 30 | cd Time2Code && \ 31 | bash time2deploy.sh && \ 32 | docker service ls 33 | ``` 34 | 35 | If you are on your laptop navigate to http://127.0.0.1:5555 and start coding. 36 | 37 | ### Kubernetes - minikube 38 | 39 | > Note: Revisiting this and revamping kubernetes deployment... 40 | 41 | You will need to have [minikube installed](https://kubernetes.io/docs/tasks/tools/install-minikube/) before you begin. 42 | 43 | Type the following snippets will get minikube started and faas-netes loaded into the kube cluster. 44 | 45 | `$ git clone https://github.com/JockDaRock/Time2Code` 46 | 47 | `$ minikube start` or `$ minikube start --vm-driver=xhyve` 48 | 49 | Then run the following bash script to load FaaS and Time2Code... 50 | 51 | `$ bash ./minikube.sh' 52 | 53 | Once the script is complete it will provide you with the url, like this http://192.168.99.100:31114/, to reach the Time2Code web editor. **BEFORE** you start using it, you will need to deploy the code execution functions after the FaaS services have started. It might take a minute or two for all of the necessary Kube pods to be Running. Keep checking the pods with `kubectl get pods`. 54 | 55 | To deploy the functions use the following command in your terminal. 56 | 57 | `$ faas-cli -action deploy -f ./time2code-faas-cli-minikube.yml` 58 | 59 | Once the kube pods for the code execution are running you can get to coding :)! 60 | 61 | ![](images/python_sample0.png) 62 | 63 | ## Latest News 64 | 65 | [Time2Code: Functions as Service and Code as a Function](https://medium.com/@JockDaRock/time2code-functions-as-service-and-code-as-a-function-3d9125fc49fb) 66 | 67 | More to come... 68 | 69 | 70 | 71 | ## Coding Languages Currently Supported 72 | 73 | * Python, Golang, Powershell, NodeJS, ... more coming very soon. 74 | 75 | * Currently working on... I am currently working C# code execution. Most of my tests are running well, but need to iron out some necessary dependencies and other issues. 76 | 77 | #### Repos for language specific code execution handlers 78 | * [Python](https://github.com/JockDaRock/Time2Py) 79 | * [Golang](https://github.com/JockDaRock/Time2Go) 80 | * [NodeJS](https://github.com/JockDaRock/Time2NodeJS) 81 | * [Powershell](https://github.com/JockDaRock/Time2Powershell) (WIP) 82 | * [C#](https://github.com/JockDaRock/Time2CSharp) (WIP) 83 | * Fortran 84 | 85 | 86 | ## Roadmap and Contributing 87 | 88 | Currently in progress: 89 | 90 | * Adding markdown and instruction functionality to accompany code execution. - check and check 91 | 92 | * Add language dependency builder for code execution functions. 93 | 94 | * Kubernetes Support - check and check 95 | 96 | Time2Code is written mostly in HTML and Javascript on the FrontEnd, Python and Flask to handle the WebIDE pages, and Python on the backend to handle code language execution on the OpenFaaS framework. This project is MIT licensed - contributions are welcomed whether that means providing feedback, testing existing and new features or hacking on the source. This project is still in early stages so I need people to generally try functionality and provide feedback. I need help building new code execution handlers for different languages or suggestions for languages to add. I also need help reducing the image sizes for the Microsoft languages handlers ([Powershell](https://github.com/JockDaRock/Time2Powershell) and [C#](https://github.com/JockDaRock/Time2CSharp)). 97 | 98 | -------------------------------------------------------------------------------- /k8s_templates/str8_k8s.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: time2codeserver 5 | spec: 6 | type: LoadBalancer 7 | ports: 8 | - name: time2codeserver-5555 9 | port: 5555 10 | protocol: TCP 11 | targetPort: 5555 12 | selector: 13 | app: time2codeserver 14 | component: time2codeserver 15 | 16 | --- 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: gateway 21 | labels: 22 | app: gateway 23 | spec: 24 | type: LoadBalancer 25 | ports: 26 | - port: 8080 27 | protocol: TCP 28 | targetPort: 8080 29 | selector: 30 | app: gateway 31 | --- 32 | apiVersion: v1 33 | kind: Service 34 | metadata: 35 | name: faas-netesd 36 | labels: 37 | app: faas-netesd 38 | spec: 39 | type: LoadBalancer 40 | ports: 41 | - port: 8080 42 | protocol: TCP 43 | targetPort: 8080 44 | selector: 45 | app: faas-netesd 46 | --- 47 | apiVersion: v1 48 | kind: Service 49 | metadata: 50 | name: prometheus 51 | labels: 52 | app: prometheus 53 | spec: 54 | type: LoadBalancer 55 | ports: 56 | - port: 9090 57 | protocol: TCP 58 | targetPort: 9090 59 | selector: 60 | app: prometheus 61 | --- 62 | apiVersion: v1 63 | kind: Service 64 | metadata: 65 | name: alertmanager 66 | labels: 67 | app: alertmanager 68 | spec: 69 | type: LoadBalancer 70 | ports: 71 | - port: 9093 72 | protocol: TCP 73 | targetPort: 9093 74 | selector: 75 | app: alertmanager 76 | 77 | 78 | 79 | --- 80 | apiVersion: extensions/v1beta1 81 | kind: Deployment 82 | metadata: 83 | name: time2codeserver 84 | spec: 85 | replicas: 3 86 | rollbackTo: 87 | revision: 0 88 | selector: 89 | matchLabels: 90 | app: time2codeserver 91 | component: time2codeserver 92 | strategy: 93 | rollingUpdate: 94 | maxSurge: 3 95 | maxUnavailable: 1 96 | type: RollingUpdate 97 | template: 98 | metadata: 99 | labels: 100 | app: time2codeserver 101 | component: time2codeserver 102 | spec: 103 | containers: 104 | - image: jockdarock/time2codeserver:latest 105 | name: time2codeserver 106 | imagePullPolicy: Always 107 | env: 108 | - name: time2code_provider_url 109 | value: "http://time2codeserver.default.svc.cluster.local:5555" 110 | ports: 111 | - containerPort: 5555 112 | protocol: TCP 113 | restartPolicy: Always 114 | --- 115 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 116 | kind: Deployment 117 | metadata: 118 | name: faas-netesd 119 | spec: 120 | replicas: 1 121 | template: 122 | metadata: 123 | labels: 124 | app: faas-netesd 125 | spec: 126 | containers: 127 | - name: faas-netesd 128 | image: functions/faas-netesd:0.3.4 129 | imagePullPolicy: Always 130 | ports: 131 | - containerPort: 8080 132 | protocol: TCP 133 | --- 134 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 135 | kind: Deployment 136 | metadata: 137 | name: gateway 138 | spec: 139 | replicas: 1 140 | template: 141 | metadata: 142 | labels: 143 | app: gateway 144 | spec: 145 | containers: 146 | - name: gateway 147 | image: functions/gateway:0.6.13 148 | imagePullPolicy: Always 149 | env: 150 | - name: functions_provider_url 151 | value: "http://faas-netesd.default.svc.cluster.local:8080/" 152 | ports: 153 | - containerPort: 8080 154 | protocol: TCP 155 | --- 156 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 157 | kind: Deployment 158 | metadata: 159 | name: prometheus 160 | spec: 161 | replicas: 1 162 | template: 163 | metadata: 164 | labels: 165 | app: prometheus 166 | spec: 167 | containers: 168 | - name: prometheus 169 | image: functions/prometheus:latest-k8s 170 | command: ["prometheus","-config.file=/etc/prometheus/prometheus.yml", "-storage.local.path=/prometheus", "-storage.local.memory-chunks=10000", "--alertmanager.url=http://alertmanager.default:9093"] 171 | imagePullPolicy: Always 172 | ports: 173 | - containerPort: 9090 174 | protocol: TCP 175 | --- 176 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 177 | kind: Deployment 178 | metadata: 179 | name: alertmanager 180 | spec: 181 | replicas: 1 182 | template: 183 | metadata: 184 | labels: 185 | app: alertmanager 186 | spec: 187 | containers: 188 | - name: alertmanager 189 | image: functions/alertmanager:latest-k8s 190 | imagePullPolicy: Always 191 | command: ["/bin/alertmanager","-config.file=/alertmanager.yml", "-storage.path=/alertmanager"] 192 | ports: 193 | - containerPort: 9003 194 | protocol: TCP 195 | --- 196 | -------------------------------------------------------------------------------- /k8s_templates/faas_function_k8s.yml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: csharp-experimental 5 | spec: 6 | replicas: 0 7 | rollbackTo: 8 | revision: 0 9 | selector: 10 | matchLabels: 11 | app: time2code 12 | component: csharp-experimental 13 | strategy: 14 | rollingUpdate: 15 | maxSurge: 1000 16 | maxUnavailable: 0 17 | type: RollingUpdate 18 | template: 19 | metadata: 20 | labels: 21 | app: time2code 22 | component: csharp-experimental 23 | spec: 24 | containers: 25 | - env: 26 | - name: fprocess 27 | value: python3 time2CSharp.py 28 | - name: https_proxy 29 | value: $https_proxy 30 | - name: no_proxy 31 | value: gateway 32 | - name: read_timeout 33 | value: "60" 34 | - name: write_timeout 35 | value: "60" 36 | image: jockdarock/time2csharp:latest 37 | imagePullPolicy: Always 38 | name: csharp-experimental 39 | nodeSelector: 40 | dedicated: aci-connector 41 | 42 | --- 43 | apiVersion: extensions/v1beta1 44 | kind: Deployment 45 | metadata: 46 | name: golang 47 | spec: 48 | replicas: 1 49 | rollbackTo: 50 | revision: 0 51 | selector: 52 | matchLabels: 53 | app: time2code 54 | component: golang 55 | strategy: 56 | rollingUpdate: 57 | maxSurge: 1000 58 | maxUnavailable: 1 59 | type: RollingUpdate 60 | template: 61 | metadata: 62 | labels: 63 | app: time2code 64 | component: golang 65 | spec: 66 | containers: 67 | - env: 68 | - name: fprocess 69 | value: python3 time2go.py 70 | - name: https_proxy 71 | value: $https_proxy 72 | - name: no_proxy 73 | value: gateway 74 | - name: read_timeout 75 | value: "60" 76 | - name: write_timeout 77 | value: "60" 78 | image: jockdarock/time2go:latest 79 | imagePullPolicy: Always 80 | name: golang 81 | nodeSelector: 82 | dedicated: aci-connector 83 | 84 | --- 85 | apiVersion: extensions/v1beta1 86 | kind: Deployment 87 | metadata: 88 | name: nodejs 89 | spec: 90 | replicas: 0 91 | rollbackTo: 92 | revision: 0 93 | selector: 94 | matchLabels: 95 | app: time2code 96 | component: nodejs 97 | strategy: 98 | rollingUpdate: 99 | maxSurge: 1000 100 | maxUnavailable: 0 101 | type: RollingUpdate 102 | template: 103 | metadata: 104 | labels: 105 | app: time2code 106 | component: nodejs 107 | spec: 108 | containers: 109 | - env: 110 | - name: fprocess 111 | value: python3 time2nodejs.py 112 | - name: https_proxy 113 | value: $https_proxy 114 | - name: no_proxy 115 | value: gateway 116 | - name: read_timeout 117 | value: "60" 118 | - name: write_timeout 119 | value: "60" 120 | image: jockdarock/time2nodejs:latest 121 | imagePullPolicy: Always 122 | name: nodejs 123 | nodeSelector: 124 | dedicated: aci-connector 125 | 126 | --- 127 | apiVersion: extensions/v1beta1 128 | kind: Deployment 129 | metadata: 130 | name: powershell 131 | spec: 132 | replicas: 0 133 | rollbackTo: 134 | revision: 0 135 | selector: 136 | matchLabels: 137 | app: time2code 138 | component: powershell 139 | strategy: 140 | rollingUpdate: 141 | maxSurge: 1000 142 | maxUnavailable: 0 143 | type: RollingUpdate 144 | template: 145 | metadata: 146 | labels: 147 | app: time2code 148 | component: powershell 149 | spec: 150 | containers: 151 | - env: 152 | - name: fprocess 153 | value: python3 time2powershell.py 154 | - name: https_proxy 155 | value: $https_proxy 156 | - name: no_proxy 157 | value: gateway 158 | - name: read_timeout 159 | value: "60" 160 | - name: write_timeout 161 | value: "60" 162 | image: jockdarock/time2powershell:latest 163 | imagePullPolicy: Always 164 | name: powershell 165 | volumeMounts: null 166 | volumes: null 167 | nodeSelector: 168 | dedicated: aci-connector 169 | 170 | --- 171 | apiVersion: extensions/v1beta1 172 | kind: Deployment 173 | metadata: 174 | name: python 175 | spec: 176 | replicas: 0 177 | rollbackTo: 178 | revision: 0 179 | selector: 180 | matchLabels: 181 | app: time2code 182 | component: python 183 | strategy: 184 | rollingUpdate: 185 | maxSurge: 1000 186 | maxUnavailable: 0 187 | type: RollingUpdate 188 | template: 189 | metadata: 190 | labels: 191 | app: time2code 192 | component: python 193 | spec: 194 | containers: 195 | - env: 196 | - name: fprocess 197 | value: python3 time2py.py 198 | - name: https_proxy 199 | value: $https_proxy 200 | - name: no_proxy 201 | value: gateway 202 | - name: read_timeout 203 | value: "60" 204 | - name: write_timeout 205 | value: "60" 206 | image: jockdarock/time2py:latest 207 | imagePullPolicy: Always 208 | name: python 209 | volumeMounts: null 210 | volumes: null 211 | nodeSelector: 212 | dedicated: aci-connector -------------------------------------------------------------------------------- /time2code-swarm-deploy.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | # Setup FaaS Framework First 4 | # Core API services for FaaS are pinned, HA is provided for functions. 5 | gateway: 6 | volumes: 7 | - "/var/run/docker.sock:/var/run/docker.sock" 8 | ports: 9 | - 8080:8080 10 | image: functions/gateway:0.6.13 11 | networks: 12 | - functions 13 | environment: 14 | dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD 15 | read_timeout: "60" 16 | write_timeout: "60" 17 | deploy: 18 | placement: 19 | constraints: [node.role == manager] 20 | 21 | prometheus: 22 | image: functions/prometheus:latest # autobuild from Dockerfile in repo. 23 | command: "-config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000 --alertmanager.url=http://alertmanager:9093" 24 | ports: 25 | - 9090:9090 26 | depends_on: 27 | - gateway 28 | - alertmanager 29 | environment: 30 | no_proxy: "gateway" 31 | networks: 32 | - functions 33 | deploy: 34 | placement: 35 | constraints: [node.role == manager] 36 | 37 | alertmanager: 38 | image: functions/alertmanager:latest # autobuild from Dockerfile in repo. 39 | environment: 40 | no_proxy: "gateway" 41 | command: 42 | - '-config.file=/alertmanager.yml' 43 | networks: 44 | - functions 45 | ports: 46 | - 9093:9093 47 | deploy: 48 | placement: 49 | constraints: [node.role == manager] 50 | 51 | # Code execution functions on FaaS 52 | # Python Code Execution 53 | python3: 54 | image: jockdarock/time2py:latest 55 | labels: 56 | function: "true" 57 | depends_on: 58 | - gateway 59 | networks: 60 | - functions 61 | environment: 62 | fprocess: "python3 time2py.py" 63 | no_proxy: "gateway" 64 | https_proxy: $https_proxy 65 | read_timeout: "60" 66 | write_timeout: "60" 67 | 68 | # Golang Code Execution 69 | golang: 70 | image: jockdarock/time2go:latest 71 | labels: 72 | function: "true" 73 | depends_on: 74 | - gateway 75 | networks: 76 | - functions 77 | environment: 78 | fprocess: "python3 time2go.py" 79 | no_proxy: "gateway" 80 | https_proxy: $https_proxy 81 | read_timeout: "60" 82 | write_timeout: "60" 83 | 84 | # Powershell Code Execution 85 | powershell: 86 | image: jockdarock/time2powershell:latest 87 | labels: 88 | function: "true" 89 | depends_on: 90 | - gateway 91 | networks: 92 | - functions 93 | environment: 94 | fprocess: "python3 time2powershell.py" 95 | no_proxy: "gateway" 96 | https_proxy: $https_proxy 97 | read_timeout: "60" 98 | write_timeout: "60" 99 | 100 | # DotNet / C# Code Execution 101 | csharp-experimental: 102 | image: jockdarock/time2csharp:latest 103 | labels: 104 | function: "true" 105 | depends_on: 106 | - gateway 107 | networks: 108 | - functions 109 | environment: 110 | fprocess: "python3 time2CSharp.py" 111 | no_proxy: "gateway" 112 | https_proxy: $https_proxy 113 | read_timeout: "60" 114 | write_timeout: "60" 115 | 116 | # NodeJS Code Execution 117 | nodejs: 118 | image: jockdarock/time2nodejs:latest 119 | labels: 120 | function: "true" 121 | depends_on: 122 | - gateway 123 | networks: 124 | - functions 125 | environment: 126 | fprocess: "python3 time2nodejs.py" 127 | no_proxy: "gateway" 128 | https_proxy: $https_proxy 129 | read_timeout: "60" 130 | write_timeout: "60" 131 | 132 | # Fortran Code Execution 133 | fortran: 134 | image: jockdarock/time2fortran:latest 135 | labels: 136 | function: "true" 137 | depends_on: 138 | - gateway 139 | networks: 140 | - functions 141 | environment: 142 | fprocess: "python3 time2fortran.py" 143 | no_proxy: "gateway" 144 | https_proxy: $https_proxy 145 | read_timeout: "60" 146 | write_timeout: "60" 147 | 148 | # Fortran Code Execution 149 | ruby: 150 | image: jockdarock/time2ruby:latest 151 | labels: 152 | function: "true" 153 | depends_on: 154 | - gateway 155 | networks: 156 | - functions 157 | environment: 158 | fprocess: "python3 time2ruby.py" 159 | no_proxy: "gateway" 160 | https_proxy: $https_proxy 161 | read_timeout: "60" 162 | write_timeout: "60" 163 | 164 | # Time2Code Code Editor / Flask Web Server 165 | time2codeserver: 166 | depends_on: 167 | - gateway 168 | build: 169 | context: . 170 | dockerfile: Dockerfile.nofaas 171 | deploy: 172 | replicas: 2 173 | image: jockdarock/time2codeserver:latest 174 | networks: 175 | - functions 176 | ports: 177 | - "5555:5555" 178 | 179 | networks: 180 | functions: 181 | driver: overlay 182 | 183 | -------------------------------------------------------------------------------- /templates/boostrap_server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Bootstrap Example 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Hello World!

16 |

Resize the browser window to see the effect.

17 |
18 | 23 |
24 | {{ markd }} 25 |
26 |
27 |
29 |

Editor

30 |
31 |
32 | 45 |
print("Hello")
46 | 51 |
52 |
53 |
54 | 55 | 56 |
57 |
58 |
59 |
60 | 104 | 105 | 106 | 144 |
145 |
146 |
147 | 148 | 149 |
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /k8s_templates/aci-beta.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: time2codeserver 5 | spec: 6 | type: LoadBalancer 7 | ports: 8 | - name: time2codeserver-5555 9 | port: 5555 10 | protocol: TCP 11 | targetPort: 5555 12 | selector: 13 | app: time2codeserver 14 | component: time2codeserver 15 | 16 | --- 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: gateway 21 | labels: 22 | app: gateway 23 | spec: 24 | type: LoadBalancer 25 | ports: 26 | - port: 8080 27 | protocol: TCP 28 | targetPort: 8080 29 | selector: 30 | app: gateway 31 | --- 32 | apiVersion: v1 33 | kind: Service 34 | metadata: 35 | name: faas-netesd 36 | labels: 37 | app: faas-netesd 38 | spec: 39 | type: LoadBalancer 40 | ports: 41 | - port: 8080 42 | protocol: TCP 43 | targetPort: 8080 44 | selector: 45 | app: faas-netesd 46 | --- 47 | apiVersion: v1 48 | kind: Service 49 | metadata: 50 | name: prometheus 51 | labels: 52 | app: prometheus 53 | spec: 54 | type: LoadBalancer 55 | ports: 56 | - port: 9090 57 | protocol: TCP 58 | targetPort: 9090 59 | selector: 60 | app: prometheus 61 | --- 62 | apiVersion: v1 63 | kind: Service 64 | metadata: 65 | name: alertmanager 66 | labels: 67 | app: alertmanager 68 | spec: 69 | type: LoadBalancer 70 | ports: 71 | - port: 9093 72 | protocol: TCP 73 | targetPort: 9093 74 | selector: 75 | app: alertmanager 76 | 77 | 78 | 79 | --- 80 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 81 | kind: Deployment 82 | metadata: 83 | name: alertmanager 84 | spec: 85 | replicas: 1 86 | template: 87 | metadata: 88 | labels: 89 | app: alertmanager 90 | spec: 91 | containers: 92 | - name: alertmanager 93 | image: functions/alertmanager:latest-k8s 94 | imagePullPolicy: Always 95 | imagePullPolicy: Always 96 | command: ["/bin/alertmanager","-config.file=/alertmanager.yml", "-storage.path=/alertmanager"] 97 | ports: 98 | - containerPort: 9003 99 | protocol: TCP 100 | restartPolicy: Always 101 | volumes: null 102 | 103 | --- 104 | apiVersion: extensions/v1beta1 105 | kind: Deployment 106 | metadata: 107 | name: csharp-experimental 108 | spec: 109 | replicas: 0 110 | rollbackTo: 111 | revision: 0 112 | selector: 113 | matchLabels: 114 | app: time2code 115 | component: csharp-experimental 116 | strategy: 117 | rollingUpdate: 118 | maxSurge: 1000 119 | maxUnavailable: 0 120 | type: RollingUpdate 121 | template: 122 | metadata: 123 | labels: 124 | app: time2code 125 | component: csharp-experimental 126 | spec: 127 | containers: 128 | - env: 129 | - name: fprocess 130 | value: python3 time2CSharp.py 131 | - name: https_proxy 132 | value: $https_proxy 133 | - name: no_proxy 134 | value: gateway 135 | - name: read_timeout 136 | value: "60" 137 | - name: write_timeout 138 | value: "60" 139 | image: jockdarock/time2csharp:latest 140 | imagePullPolicy: Always 141 | name: csharp-experimental 142 | nodename: aci-connector 143 | 144 | --- 145 | apiVersion: extensions/v1beta1 146 | kind: Deployment 147 | metadata: 148 | name: gateway 149 | spec: 150 | replicas: 1 151 | rollbackTo: 152 | revision: 0 153 | selector: 154 | matchLabels: 155 | app: time2code 156 | component: gateway 157 | strategy: 158 | rollingUpdate: 159 | maxSurge: 10 160 | maxUnavailable: 1 161 | type: RollingUpdate 162 | template: 163 | metadata: 164 | labels: 165 | app: time2code 166 | component: gateway 167 | spec: 168 | containers: 169 | - env: 170 | - name: dnsrr 171 | value: "true" 172 | - name: read_timeout 173 | value: "60" 174 | - name: write_timeout 175 | value: "60" 176 | - name: functions_provider_url 177 | value: "http://faas-netesd.default:8080/" 178 | image: functions/gateway:0.5.8-alpha 179 | imagePullPolicy: Always 180 | name: gateway 181 | ports: 182 | - containerPort: 8080 183 | protocol: TCP 184 | restartPolicy: Always 185 | 186 | --- 187 | apiVersion: extensions/v1beta1 188 | kind: Deployment 189 | metadata: 190 | name: golang 191 | spec: 192 | replicas: 1 193 | rollbackTo: 194 | revision: 0 195 | selector: 196 | matchLabels: 197 | app: time2code 198 | component: golang 199 | strategy: 200 | rollingUpdate: 201 | maxSurge: 1000 202 | maxUnavailable: 1 203 | type: RollingUpdate 204 | template: 205 | metadata: 206 | labels: 207 | app: time2code 208 | component: golang 209 | spec: 210 | containers: 211 | - env: 212 | - name: fprocess 213 | value: python3 time2go.py 214 | - name: https_proxy 215 | value: $https_proxy 216 | - name: no_proxy 217 | value: gateway 218 | - name: read_timeout 219 | value: "60" 220 | - name: write_timeout 221 | value: "60" 222 | image: jockdarock/time2go:latest 223 | imagePullPolicy: Always 224 | name: golang 225 | nodename: aci-connector 226 | 227 | --- 228 | apiVersion: extensions/v1beta1 229 | kind: Deployment 230 | metadata: 231 | name: nodejs 232 | spec: 233 | replicas: 0 234 | rollbackTo: 235 | revision: 0 236 | selector: 237 | matchLabels: 238 | app: time2code 239 | component: nodejs 240 | strategy: 241 | rollingUpdate: 242 | maxSurge: 1000 243 | maxUnavailable: 0 244 | type: RollingUpdate 245 | template: 246 | metadata: 247 | labels: 248 | app: time2code 249 | component: nodejs 250 | spec: 251 | containers: 252 | - env: 253 | - name: fprocess 254 | value: python3 time2nodejs.py 255 | - name: https_proxy 256 | value: $https_proxy 257 | - name: no_proxy 258 | value: gateway 259 | - name: read_timeout 260 | value: "60" 261 | - name: write_timeout 262 | value: "60" 263 | image: jockdarock/time2nodejs:latest 264 | imagePullPolicy: Always 265 | name: nodejs 266 | nodename: aci-connector 267 | 268 | --- 269 | apiVersion: extensions/v1beta1 270 | kind: Deployment 271 | metadata: 272 | name: powershell 273 | spec: 274 | replicas: 0 275 | rollbackTo: 276 | revision: 0 277 | selector: 278 | matchLabels: 279 | app: time2code 280 | component: powershell 281 | strategy: 282 | rollingUpdate: 283 | maxSurge: 1000 284 | maxUnavailable: 0 285 | type: RollingUpdate 286 | template: 287 | metadata: 288 | labels: 289 | app: time2code 290 | component: powershell 291 | spec: 292 | containers: 293 | - env: 294 | - name: fprocess 295 | value: python3 time2powershell.py 296 | - name: https_proxy 297 | value: $https_proxy 298 | - name: no_proxy 299 | value: gateway 300 | - name: read_timeout 301 | value: "60" 302 | - name: write_timeout 303 | value: "60" 304 | image: jockdarock/time2powershell:latest 305 | imagePullPolicy: Always 306 | name: powershell 307 | volumeMounts: null 308 | volumes: null 309 | nodename: aci-connector 310 | 311 | --- 312 | apiVersion: extensions/v1beta1 313 | kind: Deployment 314 | metadata: 315 | name: prometheus 316 | spec: 317 | replicas: 1 318 | template: 319 | metadata: 320 | labels: 321 | app: prometheus 322 | spec: 323 | containers: 324 | - name: prometheus 325 | image: functions/prometheus:latest-k8s 326 | imagePullPolicy: Always 327 | command: ["prometheus","-config.file=/etc/prometheus/prometheus.yml", "-storage.local.path=/prometheus", "-storage.local.memory-chunks=10000", "--alertmanager.url=http://alertmanager.default:9093"] 328 | imagePullPolicy: Always 329 | ports: 330 | - containerPort: 9090 331 | protocol: TCP 332 | 333 | --- 334 | apiVersion: extensions/v1beta1 335 | kind: Deployment 336 | metadata: 337 | name: python 338 | spec: 339 | replicas: 0 340 | rollbackTo: 341 | revision: 0 342 | selector: 343 | matchLabels: 344 | app: time2code 345 | component: python 346 | strategy: 347 | rollingUpdate: 348 | maxSurge: 1000 349 | maxUnavailable: 0 350 | type: RollingUpdate 351 | template: 352 | metadata: 353 | labels: 354 | app: time2code 355 | component: python 356 | spec: 357 | containers: 358 | - env: 359 | - name: fprocess 360 | value: python3 time2py.py 361 | - name: https_proxy 362 | value: $https_proxy 363 | - name: no_proxy 364 | value: gateway 365 | - name: read_timeout 366 | value: "60" 367 | - name: write_timeout 368 | value: "60" 369 | image: jockdarock/time2py:latest 370 | imagePullPolicy: Always 371 | name: python 372 | volumeMounts: null 373 | volumes: null 374 | nodename: aci-connector 375 | 376 | --- 377 | apiVersion: extensions/v1beta1 378 | kind: Deployment 379 | metadata: 380 | name: time2codeserver 381 | spec: 382 | replicas: 3 383 | rollbackTo: 384 | revision: 0 385 | selector: 386 | matchLabels: 387 | app: time2code 388 | component: time2codeserver 389 | strategy: 390 | rollingUpdate: 391 | maxSurge: 10 392 | maxUnavailable: 2 393 | type: RollingUpdate 394 | template: 395 | metadata: 396 | labels: 397 | app: time2code 398 | component: time2codeserver 399 | spec: 400 | containers: 401 | - image: jockdarock/time2codeserver:latest 402 | name: time2codeserver 403 | imagePullPolicy: Always 404 | env: 405 | - name: time2code_provider_url 406 | value: "http://time2codeserver.default:5555" 407 | ports: 408 | - containerPort: 5555 409 | protocol: TCP 410 | volumeMounts: null 411 | restartPolicy: Always 412 | volumes: null -------------------------------------------------------------------------------- /templates/index-tut.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 159 | 160 | 161 | 162 | 163 | 164 | 167 | 183 |
184 |
185 | 186 |
187 | 188 |
{{ markdown }}
189 | 199 | 200 |
201 | 202 |
203 |
204 | 205 |
206 |
{{ code_text }}
207 | 208 |
209 |
210 | 211 |
212 |
213 |
214 |
215 |
216 |
217 | 218 |
219 | 220 | 221 | 222 | 223 | 224 | 237 | 238 | 287 | 288 | 289 | 290 | 348 | 349 | 350 | 351 | 352 | 353 | -------------------------------------------------------------------------------- /templates/index-tutorial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 159 | 160 | 161 | 162 | 163 | 164 | 167 | 183 |
184 |
185 | 186 |
187 | 188 |
{{ markdown }}
189 | 199 | 200 |
201 | 202 |
203 |
204 | 205 |
206 |
{{ code_text }}
207 | 208 |
209 |
210 | 211 |
212 |
213 |
214 |
215 |
216 |
217 | 218 |
219 | 220 | 221 | 222 | 223 | 224 | 237 | 238 | 287 | 288 | 289 | 290 | 348 | 349 | 350 | 351 | 352 | 353 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 239 | 240 | 241 | 242 | 243 | 244 | 262 | 263 | 264 |
265 |
266 |
267 | 268 |
269 |
270 |
271 |
272 | 275 |
276 |
277 | 278 | 279 | 280 | 281 | 282 | 295 | 296 | 297 | 298 | 343 | 344 | 345 | 346 | 391 | 392 | 393 | 394 | 395 | 396 | -------------------------------------------------------------------------------- /templates/index-panel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 239 | 240 | 241 | 242 | 243 | 244 | 262 | 263 | 264 |
265 |
266 |
267 | 268 |
269 |
270 |
271 |
272 | 275 |
276 |
277 | 278 | 279 | 280 | 281 | 282 | 295 | 296 | 297 | 298 | 343 | 344 | 345 | 346 | 391 | 392 | 393 | 394 | 395 | 396 | --------------------------------------------------------------------------------