Giter VIP home page Giter VIP logo

docker-cheatset's Introduction

Docker encapsulation of cheatset

Docker Pulls

cheatset (GitHub) is a Ruby application for generating documentation sets (Docsets) for Dash.app, primarily focused on cheat sheets.

This repository is a Docker encapsulation for cheatset for those of us, who generate Docsets, but do not have a Ruby toolchain available or want the hassle of maintaining one.

Based on this repository you can either:

  • Download a prebuilt image from DockerHub, based on the contents of this repository
  • Or you can build your own based on the contents of this repository (please skip to the Build the image section)

Specification

The Docker image is based on the official Ruby Docker image, using the latest 2.5 version available of this image. See the Dockerfile for details.

It is based on the larger image, not the slim version since the dependencies of cheatset require compilation of C-based libraries.

A note on DockerHub

The images are build from the GitHub repository master branch.

The recommended use is to use the latest release with a version tag. See Changelog.md for details. Whereas the tag latest just reflect the latest build based on the master branch.

The master branch might contain changes not tagged as released yet and can be regarded as unstable or experimental. Changes such as corrections to documentation etc. will not be tagged until separately as a general rule, unless the changes are significant, but the aim is to keep the documentation relevant and up to date.

Run the Image

The prebuilt cheatset Docker image is available on DockerHub, or you can build it yourself based on this repository, see the section below on building.

$ docker pull jonasbn/cheatset:0.15.0
$ docker run --rm --volume $PWD:/tmp jonasbn/cheatset:0.15.0

And if you are want the latest build:

$ docker pull jonasbn/cheatset:latest
$ docker run --rm --volume $PWD:/tmp jonasbn/cheatset:latest

As mentioned latest can be considered unstable or experimental. Development is kept in branches, but new experimental features might make into master for wider evaluation.

With a single argument:

$ docker run --rm --volume "$PWD":/tmp -it --name cheatset jonasbn/cheatset help
Commands:
  cheatset generate FILE   # Generates cheat sheet out of a file
  cheatset help [COMMAND]  # Describe available commands or one specific command

With two arguments:

$ docker run --rm  -it --name cheatset jonasbn/cheatset help generate
Usage:
  cheatset generate FILE

Generates cheat sheet out of a file

Now lets generate something:

docker run --rm  -it --volume $PWD:/tmp --name cheatset jonasbn/cheatset generate sample.rb

And in our directory a Sample.docset directory appears.

Do note the Sample.docset was lifted from the cheatset GitHub repository and is under respective copyright under the referenced repository and available under the MIT license.

This can be imported into Dash.app:

  1. Open Dash.app
  2. If you have the "Manage Docsets" available click that (or open a tab by clicking +)
  3. Click + below the docsets
  4. Pick "Add Local Docset" and navigate to the directory of you recently generated Sample.docset
  5. Open it and it should now be listed in your left column, click on it a you should be good to go

Remember that upon regenerating you have to repeat the above steps, since changes are not automatically detected and imported, which mean that you can evaluate changes, without changing your other additions, which is also a good thing.

Using an alias

The Docker invocation is a bit tedious, so it is recommended to either create a shell wrapper or a shell alias.

# run cheatset docker image in current directory and cleanup the image afterwards
$ alias cheatset='docker run --rm --volume "$PWD":/tmp -it --name cheatset jonasbn/cheatset'

Try it out:

$ cheatset
Commands:
  cheatset generate FILE   # Generates cheat sheet out of a file
  cheatset help [COMMAND]  # Describe available commands or one specific command

Build the image

$ docker build -t jonasbn/cheatset .

Now that you have build the image, you can skip back to the "Run the image" section, which demonstrates how to use it.

Incompatibilities

Return status indicating success when unable to parse arguments

cheatset uses the Ruby Gem thor for command line argument parsing.

thor returns 0 when not able to parse the provided arguments.

There is hope that this might get addressed since 0 normally would indicate error. With the introduction of the warning from: thor.

Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `Cheatset::CLI`
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.

See also the related issue on GitHub.

Diagnostics

ERROR: "cheatset generate" was called with no arguments

The complete error:

ERROR: "cheatset generate" was called with no arguments
Usage: "cheatset generate FILE"
Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `Cheatset::CLI`
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
  1. You have to specify a Docset file (Ruby), eg. sample.rb
docker run --rm  -it --volume $PWD:/tmp --name cheatset jonasbn/cheatset generate sample.rb

See also the Incompatibilities section.

No such file or directory

Traceback (most recent call last):
        10: from /usr/local/bundle/bin/cheatset:23:in `<main>'
         9: from /usr/local/bundle/bin/cheatset:23:in `load'
         8: from /usr/local/bundle/gems/cheatset-1.4.0/bin/cheatset:6:in `<top (required)>'
         7: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
         6: from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
         5: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
         4: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
         3: from /usr/local/bundle/gems/cheatset-1.4.0/lib/cheatset/cli.rb:26:in `generate'
         2: from /usr/local/bundle/gems/cheatset-1.4.0/lib/cheatset/cli.rb:26:in `new'
         1: from /usr/local/bundle/gems/cheatset-1.4.0/lib/cheatset/dsl/context.rb:5:in `initialize'
/usr/local/bundle/gems/cheatset-1.4.0/lib/cheatset/dsl/context.rb:5:in `read': No such file or directory @ rb_sysopen - dzil.rb (Errno::ENOENT)
  1. Due to the mounting of a volume, You cannot specify an arbitrary path to the Docset file.
  2. You have to work directly in the directory containing the Docset file
docker run --rm  -it --volume $PWD:/tmp --name cheatset jonasbn/cheatset generate sample.rb

You can possibly adjust the Docker invocation accordingly.

Acknowledgements

  • Jun Xiong (@suredream), indirect contributor

  • Jakub Holý (@holyjak), contributor

  • Bogdan Popescu (@kapeli), author of cheatset and Dash.app

Resources and References

docker-cheatset's People

Contributors

dependabot[bot] avatar holyjak avatar jonasbn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

holyjak

docker-cheatset's Issues

Investigate possible issue with Snyk/Dependabot

Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading Code Scanning results
requires write access. To use Code Scanning with Dependabot, please ensure you are using the "pull_request" event for
this workflow and avoid triggering on the "push" event for Dependabot branches. See
https://docs.github.com/en/code-security/secure-coding/configuring-code-scanning#scanning-on-push for more
information on how to configure these events.

REF: https://github.com/jonasbn/docker-cheatset/actions/runs/760407030

Migrate from Debian to Alpine

We need to slim the Docker image, first shot at using alpine branch

 ¯\_(ツ)_/¯  [jonasbn:~/develop/github/docker-cheatset] alpine
± docker build -t jonasbn/cheatset:alpine .
Sending build context to Docker daemon  258.6kB
Step 1/4 : FROM ruby:2.6.6-alpine3.11
2.6.6-alpine3.11: Pulling from library/ruby
cbdbe7a5bc2a: Already exists
aa8ae8202b42: Already exists
b21786fe7c0d: Already exists
6fdcee3b171a: Pull complete
9f0c17609633: Pull complete
Digest: sha256:2e1e0df5b2dbefb277cfadc8cef3d19dd184153633b2981e3296a5e5dcc8e5b2
Status: Downloaded newer image for ruby:2.6.6-alpine3.11
 ---> 174df7e95528
Step 2/4 : RUN gem install cheatset
 ---> Running in 560d55fe70f9
Successfully installed unindent-1.0
Successfully installed crass-1.0.6
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
ERROR:  Error installing cheatset:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/nokogiri-1.10.9/ext/nokogiri
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.6.0 -r ./siteconf20200606-1-qvo4i2.rb extconf.rb
checking if the C compiler accepts ... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
	--help
	--clean
/usr/local/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:532:in `with_werror'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
	from extconf.rb:138:in `nokogiri_try_compile'
	from extconf.rb:162:in `block in add_cflags'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:643:in `with_cflags'
	from extconf.rb:161:in `add_cflags'
	from extconf.rb:416:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/bundle/extensions/x86_64-linux/2.6.0/nokogiri-1.10.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.10.9 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.6.0/nokogiri-1.10.9/gem_make.out
The command '/bin/sh -c gem install cheatset' returned a non-zero code: 1

Cannot build with version 1.4.8 of cheatset

The problem is that cheatset relies on: sanitize

sanitize latest version below version 6 is version 5.2.3

This version relies on: nokogumbo version 2.

nokogumbo is no longer maintained as a separate distribution (from this point on it is included in nokogiri), but the older versions do not work with Ruby version 3.

Please see: https://github.com/rubys/nokogumbo/blob/master/ext/nokogumbo/nokogumbo.c#L492C10-L492C26

rb_cData is no longer supported in Ruby since version 3.

REF:

So I am pondering relying on a Ruby version 2 base image.

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.