Skip to content
Aids you creating a `Dockerfile` by transforming its history into `RUN` instructions
Shell Makefile
Branch: master
Clone or download
augustohp Hotfixes script name on installation
Sinister prefers the URI resource name which, in this case, is a short
name. Passing the --name parameters should work but there is a bug on
jamesqo/sinister#5 that prefers the URI resource name rather than the
parameters given - which means this waits the upstream merge to be
merged.

This commit uses the hotfix for this situation while upstream isn't
merged or accepted.

Related to #2
Latest commit 29e07cd Sep 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Supports custom Docker image Sep 4, 2019
test Supports custom Docker image Sep 4, 2019
.gitignore Supports custom Docker image Sep 4, 2019
LICENSE.txt Prototypes the idea Sep 4, 2019
Makefile Supports custom Docker image Sep 4, 2019
README.md Hotfixes script name on installation Sep 5, 2019
ship Supports custom Docker image Sep 4, 2019

README.md

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 <augusto.hp@gmail.com>"

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.

You can’t perform that action at this time.