All Projects β†’ docker-exec β†’ Dexec

docker-exec / Dexec

Licence: mit
🐳 Command line interface for running code in many languages via Docker.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Dexec

sql-formatter
Polyglot SQL formatter
Stars: ✭ 28 (-91.08%)
Mutual labels:  polyglot
react-polyglot-hooks
Hooks for using Polyglot.js with React.
Stars: ✭ 26 (-91.72%)
Mutual labels:  polyglot
create-bazel-workspace
Generate a new polyglot Bazel workspace with minimal configuration
Stars: ✭ 16 (-94.9%)
Mutual labels:  polyglot
kosmikoa.nvim
A dark color scheme for Neovim with support for LSP, Treesitter. This mirror is deprecated. Use the repo at https://sr.ht/~novakane/kosmikoa.nvim/
Stars: ✭ 23 (-92.68%)
Mutual labels:  polyglot
loopback-example-polyglot
Example LoopBack application with polyglot runtimes
Stars: ✭ 14 (-95.54%)
Mutual labels:  polyglot
ansible-taskrunner
Ansible Taskrunner - ansible-playbook wrapper with YAML-abstracted python click cli options!
Stars: ✭ 14 (-95.54%)
Mutual labels:  polyglot
Polyglot
πŸ”€ Multilingual and i18n support tool for Jekyll Blogs
Stars: ✭ 242 (-22.93%)
Mutual labels:  polyglot
Awesome Graal
A curated list of awesome resources for Graal, GraalVM, Truffle and related topics
Stars: ✭ 302 (-3.82%)
Mutual labels:  polyglot
bee-travels-node
πŸ‘οΈ 🐝 Ⓜ️
Stars: ✭ 30 (-90.45%)
Mutual labels:  polyglot
covector
Transparent and flexible change management for publishing packages and assets.
Stars: ✭ 28 (-91.08%)
Mutual labels:  polyglot
redux-polyglot
Polyglot.js bindings for Redux
Stars: ✭ 59 (-81.21%)
Mutual labels:  polyglot
polyglot
Create websites using any mix of programming languages or workflows πŸ’Ž
Stars: ✭ 79 (-74.84%)
Mutual labels:  polyglot
polyglot
πŸŽ“Use the R Console as an interactive learning environment
Stars: ✭ 26 (-91.72%)
Mutual labels:  polyglot
Glottologist
An easy to use translate library
Stars: ✭ 58 (-81.53%)
Mutual labels:  polyglot
Snap
Blockly for Unity Editor.
Stars: ✭ 31 (-90.13%)
Mutual labels:  polyglot
Graal
GraalVM: Run Programs Faster Anywhere πŸš€
Stars: ✭ 16,272 (+5082.17%)
Mutual labels:  polyglot
Freaky-Sources
Collection of freaky sources written on C# (mostly quines in different forms).
Stars: ✭ 12 (-96.18%)
Mutual labels:  polyglot
Enso Archive
Looking for Enso, the visual programming language? ➑️ https://github.com/enso-org/enso
Stars: ✭ 305 (-2.87%)
Mutual labels:  polyglot
ipolyglot
A polyglot kernel for Jupyter notebooks based on GraalVM.
Stars: ✭ 59 (-81.21%)
Mutual labels:  polyglot
jaws
Jaws is an invisible programming language! Inject invisible code into other languages and files! Created for security research -- see blog post
Stars: ✭ 204 (-35.03%)
Mutual labels:  polyglot

dexec Build Status Download

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

dexec demo animation

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 32-bit
Mac 64-bit 32-bit
Windows 64-bit 32-bit

Binaries for other distributions are available on Bintray.

Using Go

Install with the go get command.

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

Using Homebrew

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

$ 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:

$ 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.

$ 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.

$ 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.

$ 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.

$ 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:

$ dexec foo.cpp <input.txt
$ curl http://input | dexec foo.cpp

Include files and folders

Individual files can be mounted without being passed to the compiler, for example header files in C & C++, or input files for program execution. These can be included in the following way.

$ dexec foo.cpp --include=bar.hpp
$ dexec foo.cpp --include bar.hpp
$ dexec foo.cpp -i bar.hpp

In addition, a program may require read and/or write access to several files on the host system. The most efficient way to achieve this is to include a directory.

$ dexec foo.cpp --include=.
$ dexec foo.cpp --include .
$ dexec foo.cpp -i .

Files and directories are relative to either the current working directory, or the directory specified with the -C flag.

As with sources, included files and directories are mounted using the default Docker mount permissions (rw) and can be specified by appending :ro or :rw to the source file.

Override the image used by dexec

dexec stores a map of file extensions to Docker images and uses this to look up the right image to run for a given source file. This can be overridden in the following ways:

Override image by name/tag

$ dexec foo.c --image=dexec/lang-cpp
$ dexec foo.c --image dexec/lang-cpp
$ dexec foo.c -m dexec/lang-cpp

This will cause dexec to attempt to use the supplied image. If no image version is specified, "latest" is used.

Override image by file extension

$ dexec foo.c --extension=cpp
$ dexec foo.c --extension cpp
$ dexec foo.c -e cpp

This will cause dexec to attempt to lookup the image for the supplied extension in its map.

Force dexec to pull latest version of image

Primarily for debugging purposes, the --update command triggers a docker pull of the target image before executing the code.

$ dexec foo.cpp -u
$ dexec foo.cpp --update

Force dexec to remove all dexec images

The --clean command removes all versions of images matching /^dexec/lang-([^:\s])$/. It can be combined with source files or STDIN input if you wish to remove all containers stored locally before executing.

$ dexec --clean

Executable source with shebang

dexec can be used to make source code executable by adding a shebang that invokes it at the top of a source file.

The shebang is stripped out at execution time but the original source containing the shebang is preserved.

#!/usr/bin/env dexec
#include <iostream>
int main() {
    std::cout << "hello world" << std::endl;
}

then

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

Contributors

docker-exec/dexec

docker-exec/perl

See also

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].