Skip to content

Commit

Permalink
Merge pull request #32 from tamada/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
tamada committed Jun 17, 2021
2 parents 07d6704 + 08deb84 commit 8b83133
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 5 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM alpine:3.10.1

ARG version=1.0.0

LABEL maintainer="Haruaki Tamada" \
description="Similarities and distances calculator among vectors"

RUN adduser -D scv \
&& apk --no-cache add --update --virtual .builddeps curl tar \
# && curl -s -L -O https://github.com/tamada/scv/realeases/download/v${version}/scv-${version}_linux_amd64.tar.gz \
&& curl -s -L -o scv-${version}_linux_amd64.tar.gz https://www.dropbox.com/s/3rxslv4jufwgh3r/scv-1.0.0_linux_amd64.tar.gz?dl=0 \
&& tar xfz scv-${version}_linux_amd64.tar.gz \
&& mv scv-${version} /opt \
&& ln -s /opt/scv-${version} /opt/scv \
&& ln -s /opt/scv-${version}/scv /usr/local/bin/scv \
&& rm scv-${version}_linux_amd64.tar.gz \
&& apk del --purge .builddeps

ENV HOME="/home/scv"

WORKDIR /home/scv
USER scv

ENTRYPOINT [ "/opt/scv/scv" ]
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ setup:
test: setup
$(GO) test -covermode=count -coverprofile=coverage.out $$(go list ./...)

define __create_dist()
define __create_dist
mkdir -p dist/$(1)_$(2)/$(DIST)
GOOS=$1 GOARCH=$2 go build -o dist/$(1)_$(2)/$(DIST)/$(NAME)$(3) main.go args.go printer.go input.go
cp -r README.md LICENSE dist/$(1)_$(2)/$(DIST)
tar cvfz dist/$(DIST)_$(1)_$(2).tar.gz -C dist/$(1)_$(2) $(DIST)
cp -r README.md LICENSE completions dist/$(1)_$(2)/$(DIST)
tar cfz dist/$(DIST)_$(1)_$(2).tar.gz -C dist/$(1)_$(2) $(DIST)
echo "Done $(1)_$(2)"
endef

dist: all
Expand All @@ -28,4 +29,4 @@ build: main.go args.go printer.go input.go vector
go build -o $(NAME) -v main.go args.go printer.go input.go

clean:
@rm -f nml *~
@rm -f scv *~
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
[![Coverage Status](https://coveralls.io/repos/github/tamada/scv/badge.svg?branch=setup_ci)](https://coveralls.io/github/tamada/scv?branch=setup_ci)
[![Go Report Card](https://goreportcard.com/badge/github.com/tamada/scv)](https://goreportcard.com/report/github.com/tamada/scv)
[![codebeat badge](https://codebeat.co/badges/5221e6ba-da64-45c1-8b13-f833f678e3b9)](https://codebeat.co/projects/github-com-tamada-scv-main)

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=spdx)](https://github.com/tamada/scv/blob/main/LICENSE)
[![Version](https://img.shields.io/badge/Version-1.0.0-blue.svg)](https://github.com/tamada/scv/releases/tag/v1.0.0)

[![Docker](https://img.shields.io/badge/Docker-ghcr.io%2Ftamada%2Fscvt%3A1.0.0-green?logo=docker)](https://github.com/users/tamada/packages/container/package/scv)


Similarities and distance Calculator among Vectors.

Expand All @@ -16,6 +21,8 @@ There are several algorithms to calculate the similarities of two bectors; howev

## :runner: Usage

### :question: CLI help message

```sh
scv [OPTIONS] <VECTORS...>
OPTIONS
Expand Down Expand Up @@ -44,6 +51,26 @@ jaccard(distance, similarity) = 0.3333
dice(distance, similarity) = 0.5000
```

### :whale: Docker

[![Docker](https://img.shields.io/badge/Docker-ghcr.io%2Ftamada%2Fscvt%3A1.0.0-green?logo=docker)](https://github.com/users/tamada/packages/container/package/scv)

```sh
docker run -it ghcr.io/tamada/scv:latest gives some strings for comparing
```

If `scv` reads some files, `-v` option should be specified.

```sh
docker run -v $PWD:/home/scv -it ghcr.io/tamada/scv:latest -f json testdata/*.json
```

#### versions

- `1.0.0`, `latest`

## :anchor: Install

## :smile: About

### :man_office_worker: Authors :woman_office_worker:
Expand All @@ -56,4 +83,6 @@ dice(distance, similarity) = 0.5000

### :jack_o_lantern: Icon

![Icon](https://github.com/tamada/scv/blob/main/docs/static/images/scv.png)
![Icon](https://github.com/tamada/scv/blob/main/docs/static/images/scale.png)

This image is obtained from [iconscount.com](https://iconscout.com/icon/scale-217).
33 changes: 33 additions & 0 deletions completions/bash/scv.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
__scv() {
local i cur prev opts cmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=""
opts=""

case "${prev}" in
--algorithm | -a)
COMPREPLY=($(compgen -W "simpson jaccard dice cosine pearson euclidean manhattan chebyshev levenshtein" -- "${cur}"))
return 0
;;
--format | -f)
COMPREPLY=($(compgen -W "default xml json" -- "${cur}"))
return 0
;;
--input-type | -t)
COMPREPLY=($(compgen -W "string json byte_file term_file" -- "${cur}"))
return 0
;;
esac
opts="-a --algorithm -f --format -t --input-type -h --help"
if [[ "$cur" =~ ^\- ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
else
compopt -o filenames
COMPREPLY=($(compgen -d -- "$cur"))
fi
}

complete -F __scv -o bashdefault -o default scv
Binary file added docs/static/images/scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/static/images/scale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b83133

Please sign in to comment.