Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/augustohp/ship

Aids you creating a `Dockerfile` by transforming its (interactive shell) history into `RUN` instructions
https://github.com/augustohp/ship

developer-tools docker posix-sh shell

Last synced: 23 days ago
JSON representation

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

Awesome Lists containing this project

README

        

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

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

[bash]: https://www.gnu.org/software/bash/

host $ cd
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 "

RUN apk add --no-cache bash

What happened?

1. The container specified was executed in iterative mode
1. `bash` (prefered) or `ash` shell are detected and history configured
1. The current directory was mounted at `/home/developer`
1. The `history` of the container was converted to `RUN` instructions in the `Dockefile`
1. 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][]:

[sinister]: https://github.com/jamesqo/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 ] [-f]
ship <-d | --detect-shell>
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 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:

* [Docker][]
* If [Git][] is available, you get the `maintainer` label in the `Dockerfile`
* A [POSIX (compatible) Shell][posix] (`bash`, for example)

[posix]: https://unix.stackexchange.com/questions/58249/what-is-difference-between-posix-bash-and-other-shells-for-scripting
[docker]: https://docs.docker.com/install/
[git]: https://git-scm.com

## Development

There is a `Makefile` to automate checks on the script:

* `make lint` runs [shellcheck][]
* `make test` runs [bats][] tests

[shellcheck]: https://github.com/koalaman/shellcheck
[bats]: https://github.com/sstephenson/bats

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.

[bashisms]: https://mywiki.wooledge.org/Bashism

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

[issue]: https://github.com/augustohp/ship/issues/new