Reputation: 32294
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?
Upvotes: 2
Views: 6962
Reputation: 409
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
Upvotes: 1
Reputation: 7988
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.
Upvotes: 4