From 8083cb5a89cee2d99f5a988f165994d0243f0d1e Mon Sep 17 00:00:00 2001 From: Zaytsev Dmitriy <20444664+dzaytsev91@users.noreply.github.com> Date: Tue, 8 Sep 2020 11:54:02 +0300 Subject: [PATCH] Add Dockerfile (#4687) * added docker image * added breakdown example to README.md, removed useless packages from docker, fix .dockerignore * delete useless libs after build * remove cmake after build * Add test for dockerfile * Checkout code Co-authored-by: Zaytsev Dmitriy Co-authored-by: Colin Seymour --- .dockerignore | 2 ++ .github/workflows/ci.yml | 13 +++++++++++++ Dockerfile | 12 ++++++++++++ README.md | 30 ++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..351a306b7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git/ +test/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a90502762..98d92f9b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,3 +27,16 @@ jobs: run: bundle exec rake - name: Check Licenses run: bundle exec licensed status -c vendor/licenses/config.yml + dockerfile: + name: Test Dockerfile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Build container + run: docker build -t linguist . + - name: Analyse current directory + run: docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist > output + - name: Confirm analysis + run: | + cat output + grep Ruby output diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d0c3e0651 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ruby:alpine + +RUN apk --update add --virtual build_deps \ + build-base \ + libc-dev \ + linux-headers \ + cmake \ + && apk --no-cache add icu-dev libressl-dev \ + && gem install github-linguist \ + && apk del build_deps build-base libc-dev linux-headers cmake + +CMD ["github-linguist"] diff --git a/README.md b/README.md index b28031f98..93af31b26 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,36 @@ grammars.yml: 884 lines (884 sloc) language: YAML ``` +#### Docker + +If you have Docker installed you can build an image and run Linguist within a container: + +```console +$ docker build -t linguist . +$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist +68.57% Ruby +22.90% C +6.93% Go +1.21% Lex +0.39% Shell +$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist github-linguist --breakdown +68.57% Ruby +22.90% C +6.93% Go +1.21% Lex +0.39% Shell + +Ruby: +Gemfile +Rakefile +bin/git-linguist +bin/github-linguist +ext/linguist/extconf.rb +github-linguist.gemspec +lib/linguist.rb +… +``` + ## Troubleshooting ### My repository is detected as the wrong language