bash-language-server icon indicating copy to clipboard operation
bash-language-server copied to clipboard

Add explainshell docker image to repository/docs

Open nordigen-account opened this issue 5 years ago • 18 comments

https://hub.docker.com/r/chrismwendt/codeintel-bash-with-explainshell/ doesn't seem to exist anymore.

nordigen-account avatar Feb 12 '20 13:02 nordigen-account

@chrismwendt do you know why the image was removed? :)

skovhus avatar Mar 04 '20 08:03 skovhus

I had no idea anyone was using it, and I no longer have the Dockerfile for it due to a career move 🤦‍♂

It's been ~2 years and I've paged most of this out of my memory by now. Still, in an attempt to aid the next intrepid fellow to implement this, here's what I remember:

  • The explainshell integration was merged in https://github.com/mads-hartmann/bash-language-server/pull/45
  • IIRC the Docker container ran both the bash-language-server and explainshell side-by-side, and bash-language-server would send HTTP requests to the sibling explainshell web server

chrismwendt avatar Mar 04 '20 08:03 chrismwendt

I've removed the invalid references in the documentation. Sorry for the inconvenience.

Maybe someone is up for creating a new docker image?

skovhus avatar Apr 16 '20 20:04 skovhus

Hey i still had a copy running on one of my machines, uploaded to dockerhub here if somebody wants to revive this or deconstruct into a dockerfile dockerhub image.

docker pull kevinhalpin/codeintel-bash-with-explainshell:latest

Maybe @chrismwendt or @skovhus want to host in their dockerhub accounts or maybe in this github repo docker registry. Not sure if they went GA with that feature yet. I dont mind having it in my dockerhub repo but probably not the best idea security wise

If i get some time next weekend I can try to turn this into a dockerfile for the repo

kevinhalpin avatar Jun 15 '20 06:06 kevinhalpin

If i get some time next weekend I can try to turn this into a dockerfile for the repo

That would be awesome!

skovhus avatar Jun 15 '20 07:06 skovhus

I took the above Docker image and used dive to inspect it, exporting to json. The commands used per layer, in sequential order, are below, in the event anyone else wants to take a crack at this. It looks like there's some junk data mixed in, in the form of character code escape sequences & values. I'm going to try my hand at this when I have the opportunity to.

The output at the end of this comment was created by running

dive kevinhalpin/codeintel-bash-with-explainshell:latest -j codeintel-bash-with-explainshell.json \
&& jq '.layer[].command' codeintel-bash-with-explainshell.json
"#(nop) ADD file:592c2540de1c707636622213ee30ff5b6f8be0a48bb25c97edc7204ea4df1a81 in / "
"set -xe \t\t&& echo '#!/bin/sh' > /usr/sbin/policy-rc.d \t&& echo 'exit 101' >> /usr/sbin/policy-rc.d \t&& chmod +x /usr/sbin/policy-rc.d \t\t&& dpkg-divert --local --rename --add /sbin/initctl \t&& cp -a /usr/sbin/policy-rc.d /sbin/initctl \t&& sed -i 's/^exit.*/exit 0/' /sbin/initctl \t\t&& echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup \t\t&& echo 'DPkg::Post-Invoke { \"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true\"; };' > /etc/apt/apt.conf.d/docker-clean \t&& echo 'APT::Update::Post-Invoke { \"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true\"; };' >> /etc/apt/apt.conf.d/docker-clean \t&& echo 'Dir::Cache::pkgcache \"\"; Dir::Cache::srcpkgcache \"\";' >> /etc/apt/apt.conf.d/docker-clean \t\t&& echo 'Acquire::Languages \"none\";' > /etc/apt/apt.conf.d/docker-no-languages \t\t&& echo 'Acquire::GzipIndexes \"true\"; Acquire::CompressionTypes::Order:: \"gz\";' > /etc/apt/apt.conf.d/docker-gzip-indexes \t\t&& echo 'Apt::AutoRemove::SuggestsImportant \"false\";' > /etc/apt/apt.conf.d/docker-autoremove-suggests"
"rm -rf /var/lib/apt/lists/*"
"sed -i 's/^#\\s*\\(deb.*universe\\)$/\\1/g' /etc/apt/sources.list"
"mkdir -p /run/systemd && echo 'docker' > /run/systemd/container"
"groupadd -r mongodb && useradd -r -g mongodb mongodb"
"apt-get update \t&& apt-get install -y --no-install-recommends \t\tca-certificates \t\tjq \t\tnumactl \t&& rm -rf /var/lib/apt/lists/*"
"set -ex; \t\tapt-get update; \tapt-get install -y --no-install-recommends \t\twget \t; \trm -rf /var/lib/apt/lists/*; \t\tdpkgArch=\"$(dpkg --print-architecture | awk -F- '{ print $NF }')\"; \twget -O /usr/local/bin/gosu \"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch\"; \twget -O /usr/local/bin/gosu.asc \"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc\"; \texport GNUPGHOME=\"$(mktemp -d)\"; \tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \tgpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \trm -r \"$GNUPGHOME\" /usr/local/bin/gosu.asc; \tchmod +x /usr/local/bin/gosu; \tgosu nobody true; \t\twget -O /js-yaml.js \"https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js\"; \t\tapt-get purge -y --auto-remove wget"
"mkdir /docker-entrypoint-initdb.d"
"set -ex; \texport GNUPGHOME=\"$(mktemp -d)\"; \tfor key in $GPG_KEYS; do \t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \tdone; \tgpg --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg; \trm -r \"$GNUPGHOME\"; \tapt-key list"
"echo \"deb http://$MONGO_REPO/apt/ubuntu xenial/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR multiverse\" | tee \"/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list\""
"set -x \t&& apt-get update \t&& apt-get install -y \t\t${MONGO_PACKAGE}=$MONGO_VERSION \t\t${MONGO_PACKAGE}-server=$MONGO_VERSION \t\t${MONGO_PACKAGE}-shell=$MONGO_VERSION \t\t${MONGO_PACKAGE}-mongos=$MONGO_VERSION \t\t${MONGO_PACKAGE}-tools=$MONGO_VERSION \t&& rm -rf /var/lib/apt/lists/* \t&& rm -rf /var/lib/mongodb \t&& mv /etc/mongod.conf /etc/mongod.conf.orig"
"mkdir -p /data/db /data/configdb \t&& chown -R mongodb:mongodb /data/db /data/configdb"
"#(nop) COPY file:18c5d9b642a89adf49e037d95a9e7de6b60557c77e049c9652605cf9cba57df9 in /usr/local/bin/ "
"apt-get update && apt-get install -y curl"
"curl -sL https://deb.nodesource.com/setup_8.x | bash -"
"apt-get install -y nodejs man-db netcat python python-pip git"
"pip install --upgrade pip==9.0.3"
"git clone https://github.com/chrismwendt/explainshell   && cd explainshell   && pip install -r requirements.txt   && mkdir -p /data/db2   && echo \"dbpath = /data/db2\" > /etc/mongodb.conf   && chown -R mongodb:mongodb /data/db2"
"#(nop) ADD 11c0b0c43c7c51af4e3d83ce690cf81fa725f41177fe930411b5abe7822fba28 in /tini "
"chmod +x /tini"
"curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -"
"echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list"
"apt-get update && apt-get install -y yarn"
"git clone https://github.com/chrismwendt/bash-language-server   && cd bash-language-server   && git checkout explainshell   && make build   && make install   && yarn global add file:\"$(pwd)\"/server"
"#(nop) COPY dir:4ea9422aec60af63924a8e239f2739a7fb5179c127bfc518e0f985d54ce7f5b9 in . "
"cd explainshell && ../populate-explainshell.sh"
"#(nop) COPY file:d663dcc05f335c55f2b6a020f7888502735051625e9145a6ac5ed8b300423f2a in /usr/local/bin "

Jekotia avatar Jun 25 '20 16:06 Jekotia

@Jekotia Thanks for trying to recover it.

skovhus avatar Jul 06 '20 04:07 skovhus

docker container run --name explainshell --restart always -p 5000:5000 -d spaceinvaderone/explainshell

wscherphof avatar Jul 14 '20 14:07 wscherphof

@wscherphof Thank you so much! They should honestly update the explainshell repo with that Docker image since the one there doesn't work because of Python 2 being phased out and it causing something with NLTK to not be available.

tarasivashchuk avatar Dec 01 '20 23:12 tarasivashchuk

@wscherphof (or anybody) any chance we can get a Dockerfile committed to this repo? It would be great to have this essential piece in a format that is auditable, modifiable, and that actually documents what is happening here. Could also lead to even fewer steps for the end user down the road.

mscottnelson avatar Apr 26 '21 16:04 mscottnelson

@skovhus Ran docker history

docker history --format "{{.CreatedBy}}" spaceinvaderone/explainshell --no-trunc > ~/Downloads/explainshell_docker_history_20230109.txt

to get the raw Dockerfile commands executed by the image.

Can clean it up and open a PR if you'd like.

explainshell_docker_history_20230109.txt

pythoninthegrass avatar Jan 09 '23 17:01 pythoninthegrass

Actually, looks like I forgot about this https://github.com/idank/explainshell/blob/master/Dockerfile.

FROM python:2.7

RUN apt-get update \
  && apt-get install man-db -y \
  && apt-get clean

ADD ./requirements.txt /tmp/requirements.txt

RUN pip install --upgrade pip \
  && python --version \
  && pip install -r /tmp/requirements.txt \
  && rm -rf ~/.cache/pip/*

ADD ./ /opt/webapp/
WORKDIR /opt/webapp
EXPOSE 5000

CMD ["make", "serve"]

Think that would be sufficient, but Python 2.7 has been EOL for almost exactly 2 years ¯\_(ツ)_/¯

pythoninthegrass avatar Jan 09 '23 17:01 pythoninthegrass

Thanks. They actually publish an office image now: https://github.com/idank/explainshell/pull/308

I haven’t tested it, but let us do that and link to this in our README. :)

skovhus avatar Jan 09 '23 18:01 skovhus

@skovhus were you able to get this working? I tried using their current latest tag (sha-b9c2000), but got following error:

[Warn  - 10:01:39 PM] 22:01:39.972 WARNING ⛔️ getExplainshellDocumentation exception: invalid json response body at http://localhost:5000/api/explain?cmd=in reason: Unexpected token < in JSON at position 0

Though I am not sure if this is an issue on my side as I am running explainshell next to my devcontainer with docker-compose... I assume it does as I am able to get the default index page at least from devcontainer:

curl localhost:5000
<!DOCTYPE html>
<html>
    <head>
        <title>explainshell.com - match command-line arguments to their help text</title>
...
    </body>
</html>

ggirard07 avatar May 26 '23 22:05 ggirard07

Used it: docker container run --name explainshell --restart always -p 5000:5000 -d ghcr.io/idank/idank/explainshell:master. It works good.

alealexpro100 avatar Jun 04 '23 12:06 alealexpro100

@skovhus If you're interested. I can take the official ~~shellcheck~~ explainshell repo, pack it up into a nice docker image for x64 / arm and publish as a docker image with proper tags and all.

seebeen avatar Jan 20 '24 19:01 seebeen

@seebeen note that this issue is about explainshell, and not shellcheck.

skovhus avatar Jan 22 '24 06:01 skovhus

That's what I meant - was dead tired when I wrote the comment 😅

seebeen avatar Jan 22 '24 10:01 seebeen