Add gtranslate

This commit is contained in:
Emil Dabrowski 2022-12-19 15:44:03 +01:00
parent 76831934ff
commit a52f6367b5
5 changed files with 63 additions and 0 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "erpnext/frappe_docker"]
path = erpnext/frappe_docker
url = https://github.com/frappe/frappe_docker
[submodule "gtranslate/source-code"]
path = gtranslate/source-code
url = https://git.sr.ht/~yerinalexey/gtranslate

24
gtranslate/Containerfile Normal file
View File

@ -0,0 +1,24 @@
# Build stage
FROM golang:1.19.4-alpine3.17
WORKDIR /app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
RUN mkdir /builds
COPY . .
RUN apk add make
RUN make install
RUN make clean
RUN rm -Rf .git*
# Final stage to only keep necessary pre-built binaries and source files
FROM alpine:3.17.0
WORKDIR /app
COPY --from=0 /app /app
COPY --from=0 /usr/local/bin/gtranslate* /usr/local/bin/
EXPOSE 5000
CMD ["gtranslate-server"]

26
gtranslate/README.md Normal file
View File

@ -0,0 +1,26 @@
# Containerfile: gtranslate
[Alexey Yerin](https://git.sr.ht/~yerinalexey) is unfortunately not interested in providing [`gtranslate`](https://git.sr.ht/~yerinalexey/gtranslate) in a container format, so here's a Containerfile for anyone in need. It is a multi-stage build which means that the Golang build environment container isn't a part of the final container. The final container is therefore just a little over 20MB. Thank you Alexey for this neat little tool!
## Building
```sh
./mk-container.sh
```
## Usage
Running the server in detached mode and querying it:
```sh
>>> docker run -it --rm --publish 5000:5000/tcp --name my-gtranslate-instance git.jilits.se/jilits/gtranslate:latest
>>> curl 'http://localhost:5000/api?from=en&to=pl&text=Translate+it'
Przetłumacz to
```
Run a single query:
```sh
>>> docker run -a STDOUT --rm --name dmenugtranslate git.jilits.se/jilits/gtranslate:latest gtranslate-query en pl "Hello, this is Mr. Banana."
Witam, tu Pan Banan.
```

9
gtranslate/mk-container.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
version="0.1.0"
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
docker build "$script_dir/source-code" -f Containerfile \
-t jilits/gtranslate:latest \
-t jilits/gtranslate:$version \
-t git.jilits.se/jilits/gtranslate:latest \
-t git.jilits.se/jilits/gtranslate:$version

@ -0,0 +1 @@
Subproject commit 4244e2734bfc27679d902e477938389bee2b8840