How do I install phantomjs with node in docker

0 votes

I have been trying to install phantomjs executable in /usr/local/bin in a docker container, alongside node. I am new to docker and not well versed in installing binaries or working with Linux so struggling to work out where I'm going wrong.

This is my docker file:

FROM        node:6.4-onbuild

# Install phantomjs
WORKDIR     ~
RUN         apt-get install libfreetype6 libfreetype6-dev \
            && apt-get install libfontconfig1 libfontconfig1-dev
RUN         export PHANTOM_JS="phantomjs-2.1.1-linux-i686" \
            && wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 \
            && tar xvjf $PHANTOM_JS.tar.bz2 \
            && mv $PHANTOM_JS /usr/local/share \
            && ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

WORKDIR     /usr/src/app
RUN         npm run build
EXPOSE      8080
CMD         ["node", "./bin/start.js"]

I've run bash on the container and there is definitely something called phantomjs in /usr/local/bin but I'm assuming that I've linked the wrong thing or it's an invalid executable. I'm thrown an error from my application telling me that there is no phantomjs executable in /usr/local/bin.

Can anyone resolve this query?

thanks.

Aug 1, 2018 in Docker by Atul
• 10,220 points
373 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Here is what you can try.

Link for existing image for this already on Docker hub using the following Dockerfile:

FROM debian:jessie 
MAINTAINER Werner Beroux <werner@beroux.com> 
# 1. Install runtime dependencies 
# 2. Install official PhantomJS release 
# 3. Clean up 

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        ca-certificates \
        bzip2 \
        libfontconfig \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        curl \
    && mkdir /tmp/phantomjs \
    && curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
           | tar -xj --strip-components=1 -C /tmp/phantomjs \
    && cd /tmp/phantomjs \
    && mv bin/phantomjs /usr/local/bin \
    && cd \
    && apt-get purge --auto-remove -y \
        curl \
    && apt-get clean \
    && rm -rf /tmp/* /var/lib/apt/lists/*

# Run as non-root user 
RUN useradd --system --uid 72379 -m --shell /usr/sbin/nologin phantomjs

USER phantomjs 
EXPOSE 8910 
CMD ["/usr/local/bin/phantomjs"]
answered Aug 1, 2018 by Damon Salvatore
• 5,450 points

Related Questions In Docker

0 votes
1 answer

How do I scale in Docker Swarm Mode W/Terraform Digital Ocean Load Balancing

The solution you could build for Digital ...READ MORE

answered Jun 19, 2018 in Docker by shubham
• 6,590 points
145 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,140 points
81 views
0 votes
1 answer

How do I remove an image in Docker?

Here is what you can try. Use docker ...READ MORE

answered Sep 4, 2018 in Docker by Damon Salvatore
• 5,450 points
32 views
0 votes
1 answer

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 27, 2018 in Docker by Damon Salvatore
• 5,450 points
1,049 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.