Skip to content

Instantly share code, notes, and snippets.

@neekey
Created May 2, 2018 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neekey/8882045f187d3190bfd14fd53d038bd2 to your computer and use it in GitHub Desktop.
Save neekey/8882045f187d3190bfd14fd53d038bd2 to your computer and use it in GitHub Desktop.
create node and npm and puppeteer in Docker
FROM python:3.6
ADD . /app
WORKDIR /app
#
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# install node and npm for query thumbnail process
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# nvm environment variables
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 8.11.1
RUN . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default \
&& npm i
ENV APP_NODE_MODULES /app_node_modules
RUN cp -r ./node_modules $APP_NODE_MODULES
# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules:$APP_NODE_MODULES
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# install lib deps for chrome
# see https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
RUN apt-get update && apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
COPY ./ops/app/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ['npm', 'i']
CMD ["gunicorn", "manage:app", "--workers=4", "--bind", "0.0.0.0:8000", "--timeout=120"]
@neekey
Copy link
Author

neekey commented May 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment