dockerperlmakefiledebian-jessiejmap

`make install` Fails Inside Docker


I'm trying to build a docker image for a JMAP Proxy named jmap-perl.

The documentation states that it targets Debian Jessie by default, so I have created the following Dockerfile:

FROM debian:jessie

# Port to expose.
EXPOSE 80

# Add all files in current directory
# to a new folder named `jmap-perl`
# in Debian Jessie's `/` folder.
ADD . / ./jmap-perl/

# Install `build-essential` (needed for `make install`) and `perl`.
# `apt-get update` is required to install `build-essential`.
RUN apt-get update && apt-get install -y \
    build-essential \
    perl

# Navigate to our new folder and run `make install`.
RUN cd /jmap-perl
RUN make install

# Run the scripts needed by the server.
CMD ["perl bin/apiendpoint.pl && perl bin/server.pl"]

I have added this Dockerfile to the project's root folder and copied everything to our Docker server.

On our Docker server, I am running the below commands:

cd jmap-perl
docker build -t jmap-perl:latest .

Everything goes well until it hits the make install command which produces the following error:

Step 6/7 : RUN make install
---> Running in 6209e8b71062
make: *** No rule to make target 'install'.  Stop.
The command '/bin/sh -c make install' returned a non-zero code: 2

What puzzles me is that the Makefile inside the project's root directory already contains a section for install: all.

Is there anything I need to change in the Makefile or the steps I'm running in my Dockerfile?


Solution

  • There are 2 things to take note here:

    1. For this ADD . / ./jmap-perl/, you should use COPY instead of ADD: COPY . /jmap-perl/
    2. Instead of using RUN cd /jmap-perl, you should use WORKDIR /jmap-perl so that subsequent commands will be executed within the jmap-perl folder. cd within the run will only have an effect within that single RUN command.

    Hope it will help :)