Skip to content

Commit

Permalink
Add Dockerfile (github-linguist#4687)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Colin Seymour <[email protected]>
  • Loading branch information
3 people authored Sep 8, 2020
1 parent 61fc3f0 commit 8083cb5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git/
test/
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8083cb5

Please sign in to comment.