Add example on how to make an onbuild image for Perl
Instead of providing an `onbuild` variant, show to the user how it is created instead, by example. See https://github.com/Perl/docker-perl/issues/13 and https://github.com/docker-library/official-images/issues/2076
This commit is contained in:
parent
9c74ecf15a
commit
c42b9573d2
|
|
@ -31,3 +31,23 @@ For many simple, single file projects, you may find it inconvenient to write a c
|
||||||
```console
|
```console
|
||||||
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp perl:5.20 perl your-daemon-or-script.pl
|
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp perl:5.20 perl your-daemon-or-script.pl
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Creating a reusable `perl:onbuild` image for Perl projects
|
||||||
|
|
||||||
|
Suppose you have a project that uses [Carton](https://metacpan.org/pod/Carton) to manage Perl dependencies. You can write a `Dockerfile` that makes use of the [ONBUILD](https://docs.docker.com/engine/reference/builder/#onbuild) instruction like this:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
FROM perl:5.26
|
||||||
|
|
||||||
|
RUN cpanm Carton \
|
||||||
|
&& mkdir -p /usr/src/app
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
ONBUILD COPY cpanfile* /usr/src/myapp
|
||||||
|
ONBUILD RUN carton install
|
||||||
|
|
||||||
|
ONBUILD COPY . /usr/src/app
|
||||||
|
```
|
||||||
|
|
||||||
|
Building this as a `perl:onbuild` image can let you reduce your project's `Dockerfile` into a single line of `FROM perl:onbuild`, which may be enough to build a stand-alone image for your project.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue