{"id":1526,"date":"2018-11-15T12:16:28","date_gmt":"2018-11-15T04:16:28","guid":{"rendered":"http:\/\/leegorous.net\/blog\/?p=1526"},"modified":"2018-11-15T16:31:31","modified_gmt":"2018-11-15T08:31:31","slug":"deploy-phantomjs-to-docker-server","status":"publish","type":"post","link":"http:\/\/leegorous.net\/blog\/2018\/11\/15\/deploy-phantomjs-to-docker-server\/","title":{"rendered":"Phantomjs\u90e8\u7f72\u5230docker\u670d\u52a1\u5668"},"content":{"rendered":"\n<p>\u57fa\u7840\u73af\u5883\u662f alpine-node:6\uff0c\u8981\u628a Phantomjs \u90e8\u7f72\u5230\u8be5\u670d\u52a1\u5668\u4e0a\uff0c\u53d1\u73b0\u76f4\u63a5\u5728 package.json \u91cc\u52a0\u4e0a&nbsp;phantomjs-prebuilt \u7684\u4f9d\u8d56\u662f\u4e0d\u80fd\u8fd0\u884c\u7684\u3002<\/p>\n\n\n\n<p>\u7f51\u7edc\u641c\u4e86\u4e00\u8f6e\uff0c\u53d1\u73b0\u662f Phantomjs \u5728 alpine linux \u4e0a\u662f\u6709\u95ee\u9898\u7684\uff0c\u627e\u5230\u8fd9\u4e2a&nbsp;<a href=\"https:\/\/github.com\/amir20\/phantomjs-node\/issues\/619\" target=\"_blank\" rel=\"noopener\">issue<\/a>\uff0c\u5c1d\u8bd5\u628a\u4e0b\u9762\u8fd9\u6bb5\u52a0\u5230 Dockerfile \u91cc\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"docker\" class=\"language-docker\">RUN apk update &amp;&amp; apk add --no-cache fontconfig curl curl-dev &amp;&amp; \\\n    mkdir -p \/usr\/share &amp;&amp; \\\n    cd \/usr\/share \\\n    &amp;&amp; curl -L https:\/\/github.com\/Overbryd\/docker-phantomjs-alpine\/releases\/download\/2.11\/phantomjs-alpine-x86_64.tar.bz2 | tar xj \\\n    &amp;&amp; ln -s \/usr\/share\/phantomjs\/phantomjs \/usr\/bin\/phantomjs \\\n    &amp;&amp; phantomjs --version<\/code><\/pre>\n\n\n\n<p>\u7684\u786e\u5728\u52a0\u5165\u8fd9\u6bb5\u4e4b\u540e\uff0c\u5b83\u80fd\u627e\u5230 phantomjs \u4e86\uff0c\u4f46\u662f\u6267\u884c createPage \u7684\u64cd\u4f5c\u65f6\u5e76\u4e0d\u8fd4\u56de\uff0c\u4e0d\u6e05\u695a\u662f\u4e0d\u662f\u54ea\u4e2a package \u91cc\u7684 bug\uff0c\u6253\u5f00 debug \u4e4b\u540e\uff0c\u53d1\u73b0 send \u4e8b\u4ef6\u4e4b\u540e\u662f\u6ca1\u6709 receive \u4e8b\u4ef6\u7684\uff0cNOOP command \u4e5f\u4ec5\u4ec5\u53d1\u9001\u4e00\u6b21\uff0c\u4e5f\u5c31\u662f\u8bf4 phantomjs \u6ca1\u6709\u6536\u5230\u547d\u4ee4\uff0c\u6216\u8005\u6536\u5230\u4e86\u6ca1\u6709\u53cd\u5e94\u3002\u7531\u4e8e\u7f3a\u4e4f\u4e0a\u4e0b\u6587\uff0c\u4e0d\u6e05\u695a\u7f51\u4e0a\u5176\u5b83\u4eba\u662f\u600e\u4e48\u80fd\u8dd1\u8d77\u6765\u7684\uff0c\u6ca1\u529e\u6cd5\uff0c\u53ea\u597d\u53e6\u5bfb\u5b83\u8def\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u641c\u5230\u8fd9\u4e2a<a href=\"https:\/\/gist.github.com\/vovimayhem\/6437c2f03b654e392ccf3e9903eba6af\" target=\"_blank\">\u4ee3\u7801\u7247\u6bb5<\/a>\uff0c\u5b83\u91cc\u9762\u662f\u4f7f\u7528\u4e86 <a href=\"https:\/\/github.com\/dustinblackman\/phantomized\" target=\"_blank\">phantomized<\/a>\uff0c\u8bd5\u4e86\u4e00\u4e0b\u8fd9\u6bb5\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"docker\" class=\"language-docker\"># 2: Download+Install PhantomJS, as the npm package 'phantomjs-prebuilt' won't work on alpine!\n# See https:\/\/github.com\/dustinblackman\/phantomized\nRUN set -ex \\\n  &amp;&amp; apk add --no-cache --virtual .build-deps ca-certificates openssl \\\n  &amp;&amp; wget -qO- \"https:\/\/github.com\/dustinblackman\/phantomized\/releases\/download\/2.1.1\/dockerized-phantomjs.tar.gz\" | tar xz -C \/ \\\n  &amp;&amp; npm install -g phantomjs \\\n  &amp;&amp; apk del .build-deps<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6b21\u7ec8\u4e8e\u80fd\u8fd0\u884c\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u7840\u73af\u5883\u662f alpine-node:6\uff0c\u8981\u628a Phantomjs \u90e8\u7f72\u5230\u8be5\u670d\u52a1\u5668\u4e0a\uff0c\u53d1\u73b0\u76f4\u63a5\u5728 package &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/leegorous.net\/blog\/2018\/11\/15\/deploy-phantomjs-to-docker-server\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cPhantomjs\u90e8\u7f72\u5230docker\u670d\u52a1\u5668\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[109,107,108],"_links":{"self":[{"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/posts\/1526"}],"collection":[{"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/comments?post=1526"}],"version-history":[{"count":11,"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/posts\/1526\/revisions"}],"predecessor-version":[{"id":1551,"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/posts\/1526\/revisions\/1551"}],"wp:attachment":[{"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/media?parent=1526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/categories?post=1526"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leegorous.net\/blog\/wp-json\/wp\/v2\/tags?post=1526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}