All Projects → bfirsh → go-dcgi

bfirsh / go-dcgi

Licence: Apache-2.0 license
CGI, but with Docker containers

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to go-dcgi

php2python
Convert PHP code to Python under CGI (beta)
Stars: ✭ 44 (+266.67%)
Mutual labels:  cgi
fano
Pascal web application framework
Stars: ✭ 21 (+75%)
Mutual labels:  cgi
googleDriveVFXServer-pipeline
Transform a Google Drive server into a VFX pipeline ready server
Stars: ✭ 15 (+25%)
Mutual labels:  cgi
rust-cgi
Create CGI programmes in Rust with hyper's http types
Stars: ✭ 28 (+133.33%)
Mutual labels:  cgi
Custom-Software-For-Xiaomi-Dafang
API and panel site for Xiaomi Dafang
Stars: ✭ 36 (+200%)
Mutual labels:  cgi
quickserv
Dangerously user-friendly web server for quick prototyping and hackathons
Stars: ✭ 275 (+2191.67%)
Mutual labels:  cgi
markdownshare.com
The code which was previously used at http://markdownshare.com/
Stars: ✭ 29 (+141.67%)
Mutual labels:  cgi
chronicle2
Chronicle is a simple blog compiler, written in Perl with minimal dependencies.
Stars: ✭ 19 (+58.33%)
Mutual labels:  cgi
bookmarks
A PySide2 based file and asset manager for animation and CG productions.
Stars: ✭ 33 (+175%)
Mutual labels:  cgi
docker-cgi-python
🐳Docker file for cgi using python2.7, 3.6, 3.7, 3.8, 3.9 and 3.10🐍
Stars: ✭ 13 (+8.33%)
Mutual labels:  cgi
trusted-cgi
Lightweight runner for lambda functions/apps in CGI like mode
Stars: ✭ 150 (+1150%)
Mutual labels:  cgi

go-dcgi

DCGI is a technique for serving web pages dynamically with Docker. As you may know, World Wide Web servers can only serve static files off disk. A DCGI server allows you to execute code in real-time, so the Web page can contain dynamic information.

For each HTTP request that a DGCI server receives, a Docker container is spun up to serve the HTTP request. Inside the Docker container is a CGI executable which handles the request. That executable could do anything – and could be written in any language or framework.

Wow! No longer do we have to build Web sites which just serve static content. For example, you could "hook up" your Unix database to the World Wide Web so people all over the world could query it. Or, you could create HTML forms to allow people to transmit information into your database engine. The possibilities are limitless.

So, what's this library for? go-dcgi is a library for writing DGCI servers. It includes a Go HTTP handler, dcgi.Handler, which serves an HTTP request by running a Docker container.

Usage

Say you've got a really simple CGI script, script.pl:

print "Content-Type: text/html\n\n";
print "<h1>Hello World!</h1>\n";

And a Dockerfile to put it inside a container:

FROM perl
ADD script.pl /code/script.pl
ENTRYPOINT ["perl", "/code/script.pl"]

Build this into a container:

$ docker build -t bfirsh/example-dcgi-app .

You can serve this container over HTTP with go-dcgi:

package main

import (
	"net/http"
	dcgi "github.com/bfirsh/go-dcgi"
	"github.com/docker/engine-api/client"
)

func main() {
	cli, err := client.NewClient("unix:///var/run/docker.sock", "v1.23", nil, nil)
	if err != nil {
		panic(err)
	}

	http.Handle("/", &dcgi.Handler{
		Image:      "bfirsh/example-dcgi-app",
		Client:     cli,
	})
	http.ListenAndServe(":80", nil)
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].