首页 > 解决方案 > Docker容器上的Heroku Exec未安装

问题描述

我试图在 Docker 容器上安装 Heroku Exec,以便我可以通过 shell 运行脚本。我无法访问容器上的外壳。我已按照以下链接说明heroku ps:exec与 Docker 一起使用,但在运行时出现此错误heroku:ps exec。你可以看到我已经在我的 dockerfile 中安装了这些包,我/.profile.d在我的基本 /app 目录中创建了一个文件夹,并添加了该heroku-exec.sh文件并粘贴了他们想要的代码行。似乎 Heroku Exec 没有安装或工作。

establishing credentials... error
Heroku Exec is not running!
 ▸    Could not connect to dyno!
 ▸    Check if the dyno is running with heroku ps

Heroku Exec 与 Docker: https ://devcenter.heroku.com/articles/exec#using-with-docker

Dockerfile

FROM node:latest

# update and add all the steps for running with xvfb
RUN apt-get update &&\
apt-get install -yq 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 \
xvfb x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
  --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get install bash
RUN apt-get install python
RUN apt-get install curl
RUN apt-get install openssh-client

#remove zombie images
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_x86_64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
ENTRYPOINT ["dumb-init", "--"]


# WORKDIR /app
# using /tmp in order to read/write to container fs as non-root user
WORKDIR /tmp 
# add the required dependencies - this breaks the build process for some reason, manually npm install below works
# COPY node_modules /app/node_modules

RUN npm install puppeteer \
# Add user so we don't need --no-sandbox.
  # same layer as npm install to keep re-chowned files from using up several hundred MBs more space
  && groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
  && mkdir -p /home/pptruser/Downloads \
  && chown -R pptruser:pptruser /home/pptruser \
  && npm install express \
  && npm install basic-ftp 
  # && chown -R pptruser:pptruser /node_modules
    
# For Heroku exec  
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

ADD ./.profile.d /app/.profile.d

EXPOSE 3000
# Run everything after as non-privileged user.
USER pptruser
# USER root
# Finally copy the build application
COPY . .

# make sure we can run without a UI
ENV DISPLAY :99

CMD Xvfb :99 -screen 0 1024x768x16 -nolisten unix & node server.js

标签: node.jsdockerheroku

解决方案


推荐阅读