Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/docker-exec/dexec

:whale: Command line interface for running code in many languages via Docker.
https://github.com/docker-exec/dexec

docker execution go polyglot

Last synced: 17 days ago
JSON representation

:whale: Command line interface for running code in many languages via Docker.

Awesome Lists containing this project

README

        

# dexec ![Build Status](https://github.com/docker-exec/dexec/workflows/Unit%20Tests/badge.svg) [ ![Download](https://api.bintray.com/packages/dexec/release/dexec/images/download.svg) ](https://bintray.com/dexec/release/dexec/_latestVersion)

A command line utility for executing code in many different languages using the Docker Exec images, written in Go.

![dexec demo animation](https://docker-exec.github.io/images/dexec-short-1.0.1.gif)

## Installation

### Using Bintray

Download the appropriate binary for your OS and architecture, then unzip or untar and move the ```dexec``` executable to where it can be found on your PATH.

| OS | 64-bit | 32-bit |
| ------- | ------ | ------ |
| Linux | [64-bit](https://bintray.com/artifact/download/dexec/release/dexec_1.0.7_linux_amd64.tar.gz) | [32-bit](https://bintray.com/artifact/download/dexec/release/dexec_1.0.7_linux_386.tar.gz) |
| Mac | [64-bit](https://bintray.com/artifact/download/dexec/release/dexec_1.0.7_darwin_amd64.zip) | [32-bit](https://bintray.com/artifact/download/dexec/release/dexec_1.0.7_darwin_386.zip) |
| Windows | [64-bit](https://bintray.com/artifact/download/dexec/release/dexec_1.0.7_windows_amd64.zip) | [32-bit](https://bintray.com/artifact/download/dexec/release/dexec_1.0.7_windows_386.zip) |

Binaries for other distributions are available on [Bintray](https://bintray.com/dexec/release/dexec/_latestVersion).

### Using Go

Install with the ```go get``` command.

```sh
$ go get github.com/docker-exec/dexec
```

### Using Homebrew

If you're on OSX you can install the latest release of ```dexec``` with brew.

```sh
$ brew install docker-exec/formula/dexec
```

## Reference

These examples use a .cpp source file, but any of the supported languages can be used instead. Arguments can be passed in any order, using any style of the acceptable switch styles described.

The application provides help and version information as follows:

```sh
$ dexec --version
$ dexec --help
```

### Pass source files to execute

Multiple source files can be passed to the compiler or interpreter as follows. The first source file's extension is used to pick the appropriate Docker Exec image, e.g. .cpp retrieves dexec/cpp from the Docker registry.

```sh
$ dexec foo.cpp
$ dexec foo.cpp bar.cpp
```

The sources are mounted individually using the default Docker mount permissions (rw) and can be specified by appending :ro or :rw to the source file.

### Pass arguments for build

For compiled languages, arguments can be passed to the compiler.

```sh
$ dexec foo.cpp --build-arg=-std=c++11
$ dexec foo.cpp --build-arg -std=c++11
$ dexec foo.cpp -b -std=c++11
```

### Pass arguments for execution

Arguments can be passed to the executing code. Enclose arguments with single quotes to preserve whitespace.

```sh
$ dexec foo.cpp --arg=hello --arg=world --arg='hello world'
$ dexec foo.cpp --arg hello --arg world --arg 'hello world'
$ dexec foo.cpp -a hello -a world -a 'hello world'
```

### Specify location of source files

By default, ```dexec``` assumes the sources are in the directory from which it is being invoked from. It is possible to override the working directory by passing the ```-C``` flag.

```sh
$ dexec -C /path/to/sources foo.cpp bar.cpp
```

### Read from STDIN

```dexec``` will forward your terminal's STDIN to the executing code. You can redirect from a file or use pipe:

```sh
$ dexec foo.cpp
int main() {
std::cout << "hello world" << std::endl;
}
```

then

```sh
$ chmod +x foo.cpp
$ ./foo.cpp
```

## Contributors

#### [docker-exec/dexec](https://github.com/docker-exec/dexec/graphs/contributors)

* [John H. Ayad](https://github.com/johnhany97)
* [Alix Axel](https://github.com/alixaxel)
* [kroton](https://github.com/kroton)
* [John Albietz](https://github.com/inthecloud247)

#### [docker-exec/perl](https://github.com/docker-exec/perl/graphs/contributors)

* [Øyvind Skaar](https://github.com/oyvindsk)

## See also

* [Docker Exec GitHub Page](https://docker-exec.github.io/)
* [Docker Exec GitHub Repositories](https://github.com/docker-exec)
* [Docker Exec Images on Docker Hub](https://hub.docker.com/r/dexec/)
* [dexec on Bintray](https://bintray.com/dexec/release/dexec/view)