0

I am trying to deploy a Dockerfile from dockerhub on heroku using github workflow but I am getting error Failed to bind to $PORT within 60 seconds of launch – HEROKU ERROR.

Below is my Dockerfile.

FROM ghcr.io/linuxserver/baseimage-alpine:3.15

WORKDIR /app

# set version label
ARG UNRAR_VERSION=6.1.4
ARG BUILD_DATE
ARG VERSION
ARG SABNZBD_VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thespad"

# environment settings
ENV HOME="/config" \
PORT=8080 \
PYTHONIOENCODING=utf-8


RUN \
  echo "**** install packages ****" && \
  apk add -U --update --no-cache --virtual=build-dependencies \
    build-base \
    g++ \
    gcc \
    libffi-dev \
    make \
    openssl-dev \
    python3-dev && \
  apk add  -U --update --no-cache \
    curl \
    p7zip \
    par2cmdline \
    python3 \
    py3-pip && \
  echo "**** install unrar from source ****" && \
  mkdir /tmp/unrar && \
  curl -o \
    /tmp/unrar.tar.gz -L \
    "https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \  
  tar xf \
    /tmp/unrar.tar.gz -C \
    /tmp/unrar --strip-components=1 && \
  cd /tmp/unrar && \
  make && \
  install -v -m755 unrar /usr/local/bin && \
  echo "**** install sabnzbd ****" && \  
  if [ -z ${SABNZBD_VERSION+x} ]; then \
    SABNZBD_VERSION=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest \
      | awk '/tag_name/{print $4;exit}' FS='[""]'); \
  fi && \
  mkdir -p /app/sabnzbd && \
  curl -o \
    /tmp/sabnzbd.tar.gz -L \
    "https://github.com/sabnzbd/sabnzbd/releases/download/${SABNZBD_VERSION}/SABnzbd-${SABNZBD_VERSION}-src.tar.gz" && \
  tar xf \
    /tmp/sabnzbd.tar.gz -C \
    /app/sabnzbd --strip-components=1 && \
  cd /app/sabnzbd && \
  python3 -m pip install --upgrade pip && \
  pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.15/ \
    wheel \
    apprise \
    pynzb \
    requests && \
  pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.15/ -r requirements.txt && \
  echo "**** install nzb-notify ****" && \   
  NZBNOTIFY_VERSION=$(curl -s https://api.github.com/repos/caronc/nzb-notify/releases/latest \
    | awk '/tag_name/{print $4;exit}' FS='[""]') && \
  mkdir -p /app/nzbnotify && \
  curl -o \
    /tmp/nzbnotify.tar.gz -L \
    "https://api.github.com/repos/caronc/nzb-notify/tarball/${NZBNOTIFY_VERSION}" && \
  tar xf \
    /tmp/nzbnotify.tar.gz -C \
    /app/nzbnotify --strip-components=1 && \
  cd /app/nzbnotify && \
  pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.15/ -r requirements.txt && \
  echo "**** cleanup ****" && \
  ln -s \
    /usr/bin/python3 \
    /usr/bin/python && \
  apk del --purge \
    build-dependencies && \
  rm -rf \
    /tmp/* \
    $HOME/.cache

# add local files
COPY ./config /config

# ports and volumes
EXPOSE $PORT
# ENV LISTEN_PORT 8080 
# PORT=8080
VOLUME /config
CMD exec /app/sabnzbd/Sabnzbd --NoRestart --NoUpdates -p $PORT

I don't know why heroku showing Port error even though I have exposed the port. Can Anyone please help me with the error. I want to deploy Sabnzbd on heroku using Docker.

Kenil
  • 19
  • 4
  • Don't try to set `PORT=8080` as env variable but use the one assigned by Heroku. Also your `CMD` is commented – Beppe C Mar 22 '22 at 12:05
  • I have tried CMD without commenting but was getting error of Port when i try to reache the site. And PORT=8080 Is commented. – Kenil Mar 22 '22 at 12:11
  • BTW How to use the port assigned by Heroku? – Kenil Mar 22 '22 at 12:12
  • The port is available in the `$PORT` env variable, so setting `-p $PORT` is enough as long as the application sets the port reading the `-p` parameter – Beppe C Mar 22 '22 at 12:16
  • Should I Remove PORT=8080 from #environment settings? – Kenil Mar 22 '22 at 12:18
  • Yes, you don't need it on Heroku – Beppe C Mar 22 '22 at 12:23
  • Got Error In Heroku Logs ``` 2022-03-22T12:22:15.606391+00:00 app[web.1]: /bin/sh: exec: line 1: /app/sabnzbd/Sabnzbd: not found 2022-03-22T12:22:15.608830+00:00 app[web.1]: [cmd] /bin/sh exited 127 2022-03-22T12:22:15.616920+00:00 app[web.1]: [cont-finish.d] executing container finish scripts... 2022-03-22T12:22:15.618068+00:00 app[web.1]: [cont-finish.d] done. 2022-03-22T12:22:15.618313+00:00 app[web.1]: [s6-finish] waiting for services. 2022-03-22T12:22:15.826300+00:00 app[web.1]: [s6-finish] sending all processes the TERM signal. Heroku[web.1]: Process exited with status 129 ``` – Kenil Mar 22 '22 at 12:24
  • BTW here is the Github [Repo](https://github.com/kenil261615/sabnzbdheroku) – Kenil Mar 22 '22 at 13:44

0 Answers0