Skip to content

Commit d918e73

Browse files
committed
Added Docker deployment configuration and instructions.
1 parent 0ae78ab commit d918e73

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

Dockerfile

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM python:3 as build
2+
3+
WORKDIR /build
4+
5+
RUN apt-get -y update && apt-get -y install git g++ autoconf-archive make libtool gfortran tar gawk
6+
7+
RUN wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.6.2.tar.gz && \
8+
tar -xvzf openfst-1.6.2.tar.gz && \
9+
cd openfst-1.6.2 && \
10+
./configure --enable-static --enable-shared --enable-far --enable-ngram-fsts && \
11+
make -j $(nproc) && \
12+
make install && \
13+
ldconfig
14+
15+
RUN git clone https://github.com/mitlm/mitlm && \
16+
cd mitlm && \
17+
autoreconf -i && \
18+
./configure && \
19+
make -j $(nproc) && \
20+
make install
21+
22+
WORKDIR /build/phonetisaurus
23+
24+
COPY . ./
25+
26+
RUN pip3 install pybindgen
27+
28+
RUN ./configure --enable-python && \
29+
make -j $(nproc) && \
30+
make install
31+
32+
FROM python:3-slim
33+
34+
RUN apt-get -y update && apt-get -y install gfortran && apt-get -y clean && apt-get -y autoclean
35+
36+
WORKDIR /setup
37+
38+
COPY --from=build /build/phonetisaurus/python ./
39+
COPY --from=build /build/phonetisaurus/.libs/Phonetisaurus.so ./
40+
41+
RUN python setup.py install
42+
43+
COPY --from=build /usr/local/lib/fst /usr/local/lib/fst
44+
COPY --from=build /usr/local/lib/libfst*so*0 /usr/local/lib/
45+
COPY --from=build /usr/local/bin/phonetisaurus* /usr/local/bin/
46+
COPY --from=build /build/phonetisaurus/src/scripts/* /usr/local/bin/
47+
COPY --from=build /usr/local/bin/rnnlm /usr/local/bin/
48+
COPY --from=build /usr/local/bin/estimate-ngram /usr/local/bin/
49+
COPY --from=build /usr/local/lib/libmitlm.so.1.0.0 /usr/local/lib
50+
51+
RUN ldconfig
52+
53+
WORKDIR /work
54+
55+
ENTRYPOINT [ "/bin/bash" , "-c" ]

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,23 @@ If you need to rebuild the configure script you can do so:
271271
$ bin/phonetisaurus-g2pfst --help
272272
```
273273

274+
### Docker: ###
275+
276+
Docker images are hosted on: https://hub.docker.com/r/phonetisaurus/phonetisaurus
277+
278+
The images can be used in one of 3 ways:
279+
280+
* directly, to process files on your computer without needing to install/compile anything (apart from docker)
281+
* as a base image for another project (using the `FROM` statement)
282+
* to copy portions of the binaries or libraries into a new image (using the `COPY --from=` statement) - most of the files are in `/usr/local/bin` and `/usr/local/lib`
283+
284+
To use the program directly, you need to mount the local folder with the required files (eg. models, word lists, etc) into the Docker container under the `/work` path, as this is the default workdir in the image. Then you can call the programs directly after the name of the image, for example:
285+
```
286+
docker run --rm -it -v $PWD:/work phonetisaurus/phonetisaurus "phonetisaurus-apply -m model.fst -wl test.wlist"
287+
```
288+
289+
You can also use the `bash` program to simply enter the interactive shell and run everything from there.
290+
274291
### Misc: ###
275292
cpplint command:
276293
```

0 commit comments

Comments
 (0)