Coder Social home page Coder Social logo

augustohp / ship Goto Github PK

View Code? Open in Web Editor NEW
54.0 3.0 4.0 9 KB

Aids you creating a `Dockerfile` by transforming its (interactive shell) history into `RUN` instructions

License: MIT License

Shell 88.69% Makefile 11.31%
docker shell posix-sh developer-tools

ship's Introduction

SHIP: Shell Helper To Initialize (Dockerfiles) in a new Project

Let's create a new image, on an existing repository, to install bash:

host      $ cd <repository path>
host      $ ship alpine:latest
container $ apk add --no-cache bash
container $ exit
Dockerfile written successfully!
host      $ cat Dockerfile
# Generated by https://github.com/augustohp/ship
FROM alpine:latest
LABEL maintainer="Augusto Pascutti <[email protected]>"

RUN apk add --no-cache bash

What happened?

  1. The container specified was executed in iterative mode
  2. bash (prefered) or ash shell are detected and history configured
  3. The current directory was mounted at /home/developer
  4. The history of the container was converted to RUN instructions in the Dockefile
  5. Your Git credentials become LABEL maintainer, if they are available

Supported images are (other images might work if they have bash available):

  • alpine
  • ubuntu/debian
  • fedora

Installation

This is a single-file script, you can rename it freely to anything memorable for you. An easy one-line install is available through sinister:

sh <(curl -sSL https://git.io/fjjvu) --name ship --local --chmod 755 --url https://git.io/fjhO5

The above one-liner will install the script just for the current user. If you want it globally, remove --local option.

You should be able to execute ship now, for example ship --help:

Usage: ship [-o <filename>] [-f] <image>
       ship <-d | --detect-shell> <image>
       ship <-h | --help>
       ship <-v | --version>

Eases the creation of a Dockerfile by transforming the history
into RUN instructions.

Arguments:
  image                    The name of Dockerimage to be executed. 
                           The image must have bash installed.
Options:
  -o | --out <filename>    The name of the Dockerfile to be creared.
                           Default: Dockerfile.
  -f | --force             Re-creates Dockerfile if it
                           already exists.
  -d | --detect-shell      Outputs the shell available in the image.
                           Shells tested: bash ash

Requirements, trying to be minimal, are:

Development

There is a Makefile to automate checks on the script:

Feel free to hack the ship script. It uses sh not bash to run, so try to avoid bashisms. Almost everything inside the script is on a function to be friendly even if you've never done any shell-scripting before.

Please, feel free to report bugs, ideas or feature requests through an issue.

ship's People

Contributors

augustohp avatar boldewyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ship's Issues

Accept all `docker run` options

An example of workflow I am interested in:

  1. Someone appears with a doubt and some code I can run, it doesn't have Docker;
  2. I clone the repository and start a container for it:
    $ docker run -di --name www-php -v "${PWD}:/var/www" -w "/var/wwww" -p 8080:80 php:7.2-apache
    
  3. Now a bunch of dependencies are installed, amounting to a history like:
    $ docker exec -it www-php bash
    $ pecl install xdebug-2.6.0
    $ docker-php-ext-enable xdebug
    $ php bin/setup.php
    

The idea would be to use ship instead of docker run, enabling us to create a Dockerfile while we discover what is needed.

File name become the url path

When I'm installing the script with sinister, the name becomes fjhO5

Example:

$ sh <(curl -sSL http://git.io/sinister) --local --chmod 755 --url https://git.io/fjhO5
fjhO5 was installed successfully

I saw that sinister has the parameter --name, but it didn't work well.

So just used mv

sh <(curl -sSL http://git.io/sinister) --local --chmod 755 --url https://git.io/fjhO5 && mv ~/bin/fjhO5 ~/bin/ship

But it will not be sustainable hehe.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.