2

I am trying to follow the 2 steps mentioned below:

1) Downloaded source code of

https://sourceforge.net/projects/hunspell/files/Hyphen/2.8/hyphen-2.8.8.tar.gz/download

2) Compiled it and you will get binary named example:

hyphen-2.8.8$ ./example ~/dev/smc/hyphenation/hi_IN/hyph_hi_IN.dic ~/hi_sample.text

I have downloaded and uncompressed the tar file. My question is how to create a dockerfile to automate this?

There are only 3 commands involved:

./configure
make all-recursive
make install

I can select the official python image as a base container. But how do I write the commands in a docker file?

2
  • 1
    The link you posted automatically downloaded some tar.gz file from sourceforge.net. You might want to change that link so it points to the download page. I'm sure I am not the only person that is very distrusting of anything coming from sourceforge. Commented Dec 30, 2019 at 3:57
  • If you use ADD dont forget to unzip the tar file. Else you can also use copy. Commented Dec 30, 2019 at 4:20

2 Answers 2

4

You can do that with a RUN command:

FROM python:<version number here>

RUN ./configure && make-recursive && make install

CMD ['<some command here>']

what you use for <some command here> depends on what the image is meant to do. Remember that docker containers only run as long as that command is executing, so if you put the configure/make/install steps in a script and use that as your entry point, it's going to build your program, and then the container will halt.

Also you need to get the downloaded files into the container. That can be done using a COPY or an ADD directive (before the RUN of course). If you have the tar.gz file saved locally, then ADD will both copy the file into the container and expand it into a directory automatically. COPY will not expand it, so if you do that, you'll need to add a tar -zxvf or similar to the RUN.

If you want to download the file directly into the container, that could be done with ADD <source URL>, but in that case it won't expand it, so you'll have to do that in the RUN. COPY doesn't allow sourcing from a URL. This post explains COPY vs ADD in more detail.

Sign up to request clarification or add additional context in comments.

Comments

1

You can have the three commands in a shell script and then use the following docker commands

COPY ./<path to your script>/<script-name>.sh /
ENTRYPOINT ["/<script-name>.sh"]
CMD ["run"]

For reference, you can create your docker file as they have created for one of the projects I worked on Apache ActiveMQ Artemis: https://github.com/apache/activemq-artemis/blob/master/artemis-docker/Dockerfile-ubuntu

1 Comment

You'd almost always run commands like make install while the image is being built (in a RUN command) and not when the image is starting up (as the image's ENTRYPOINT).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.