Search code examples
phpdockerubuntupipeline

Dockers | Pipelines failing ubuntu sources list


I had running pipelines yesterday and suddenly it stopped working and showing this error:

bash: ssh: command not found

pipelines the second step is: apt-get update && apt-get install -y Openssh-client

and it fails on hitting the source lists throwing 404's and because of it Openssh-client is not installing:

Pipeline logs

So far I have tried upgrading to a newer PHP image which is throwing the exact same error of 404,

The current PHP image php:7.3.18-apache is being used and was working till yesterday and all of a sudden it stopped working, I don't have much room to go for higher PHP versions.

Dockerfile:

FROM php:7.3.18-apache

ARG PHP_OPENSSL=yes

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        libpcre3-dev \
        curl \
        cron \
        supervisor \
        zip \
        libzip-dev \
        libicu-dev \
        libmagickwand-dev \
        inkscape \
        && docker-php-ext-install bcmath sockets \
        && docker-php-ext-configure intl \
          && docker-php-ext-install intl \
    && docker-php-ext-configure gd \
    && docker-php-ext-configure zip --with-libzip \
    && docker-php-ext-install -j$(nproc) gd gettext json mbstring pdo_mysql pcntl zip

RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick

RUN a2enmod rewrite

ARG PSR_VERSION=0.7.0
ARG PHALCON_VERSION=4.0.2
ARG PHALCON_EXT_PATH=php7/64bits

RUN set -xe && \
        # Download PSR, see https://github.com/jbboehr/php-psr
        curl -LO https://github.com/jbboehr/php-psr/archive/v${PSR_VERSION}.tar.gz && \
        tar xzf ${PWD}/v${PSR_VERSION}.tar.gz && \
        # Download Phalcon
        curl -LO https://github.com/phalcon/cphalcon/archive/v${PHALCON_VERSION}.tar.gz && \
        tar xzf ${PWD}/v${PHALCON_VERSION}.tar.gz && \
        docker-php-ext-install -j $(getconf _NPROCESSORS_ONLN) \
            ${PWD}/php-psr-${PSR_VERSION} \
            ${PWD}/cphalcon-${PHALCON_VERSION}/build/${PHALCON_EXT_PATH} \
        && \
        # Remove all temp files
        rm -r \
            ${PWD}/v${PSR_VERSION}.tar.gz \
            ${PWD}/php-psr-${PSR_VERSION} \
            ${PWD}/v${PHALCON_VERSION}.tar.gz \
            ${PWD}/cphalcon-${PHALCON_VERSION} \
        && \
        php -m

# install phalcon dev tools
ARG DEV_TOOL_VERSION=4.0.0

RUN echo ">>> Downloading phalcon.phar ..." && \
                curl -LOs https://github.com/phalcon/phalcon-devtools/releases/download/v${DEV_TOOL_VERSION}/phalcon.phar && \
                chmod +x phalcon.phar && \
                mv phalcon.phar /usr/local/bin/phalcon && \
                echo ">>> Testing 'phalcon --version' command ..." && \
                phalcon --version

#install composer
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php && \
    # install
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
    #verify
    composer -V

COPY ./supervisor/* /etc/supervisor/conf.d

#Install xdebug
RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.idekey=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

COPY ./ssl/ /etc/ssl/certs/
COPY ./sites-available/* /etc/apache2/sites-available/

RUN a2ensite default-ssl
RUN a2enmod ssl

RUN apt-get install -y --no-install-recommends apt-utils
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs

#install yarn
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
# RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# RUN apt update && apt install -y yarn
RUN npm install -g yarn

ENV REDIS_VERSION 5.2.2

RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$REDIS_VERSION.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mkdir -p /usr/src/php/ext \
    && mv phpredis-* /usr/src/php/ext/redis

RUN docker-php-ext-install redis

COPY ./php.ini /usr/local/etc/php/
COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh

And bitbucket-pipelines.yml:

image: php:7.3.3
pipelines:
  branches:
    master:
      - step:
          name: Main deploy process
          deployment: production
          caches:
            - composer
            - node
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
            - echo "Main deploy process" && ssh -tt $TABACK_SSH_USER@$PROD_SERVER "rm -rf $RELEASE_DIR_REMOVE && mkdir $RELEASE_DIR_REMOVE && cd $RELEASE_DIR_REMOVE && git clone --branch $BITBUCKET_BRANCH https://$Cred/trustanalytica/trustanalytica.git $RELEASE_DIR_REMOVE"
            - echo "Copy env files" && ssh -tt $TABACK_SSH_USER@$PROD_SERVER "cp $APP_ROOT/env.$BITBUCKET_BRANCH $RELEASE_DIR_REMOVE/app/config/.env" #&& cp $APP_ROOT/env.$BITBUCKET_BRANCH.client $RELEASE_DIR_REMOVE/react/client/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.server $RELEASE_DIR_REMOVE/react/server/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.messenger $RELEASE_DIR_REMOVE/react/messenger/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.badge $RELEASE_DIR_REMOVE/react/widgets/badge/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.review $RELEASE_DIR_REMOVE/react/widgets/review/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.sadmin.catalog $RELEASE_DIR_REMOVE/react/superadmin/catalog-module/.env
            - echo "Install via composer" && ssh -tt $TABACK_SSH_USER@$PROD_SERVER "cd $RELEASE_DIR_REMOVE && composer install"
      - parallel:
          - step:
              name: Checking everything is ok
              caches:
                - composer
                - node
              script:
                - apt-get update && apt-get install -y openssh-client
                - apt-get update && apt-get install -y unzip rsync wget
                - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
                - ssh -tt $TABACK_SSH_USER@$PROD_SERVER "cd $APP_ROOT && ./check_build.sh"
          - step:
              name: Creating cache files...
              caches:
                - composer
                - node
              script:
                - apt-get update && apt-get install -y openssh-client
                - apt-get update && apt-get install -y unzip rsync wget
                - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
                - ssh -tt $TABACK_SSH_USER@$PROD_SERVER "cd $APP_ROOT && ./cache_folders.sh"
          - step:
              name: Migrations magick
              caches:
                - composer
                - node
              script:
                - apt-get update && apt-get install -y openssh-client
                - apt-get update && apt-get install -y unzip rsync wget
                - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
                - ssh -tt $TABACK_SSH_USER@$PROD_SERVER "cd $RELEASE_DIR_REMOVE && vendor/bin/phinx migrate"
      - step:
          name: Re-link build
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            #[ ! -d /home/taback/old`date +%m%d%H%M%S` ] && mkdir -p /home/taback/old`date +%m%d%H%M%S` && cp -a /home/taback/current/ /home/taback/old`date +%m%d%H%M%S`/ && rm -rf /home/taback/current/ &&
            - ssh -tt $TABACK_SSH_USER@$PROD_SERVER "rm -rf $RELEASE_DIR && mv -f $RELEASE_DIR_REMOVE $RELEASE_DIR"
            - echo "Deploying Modules" && ssh -tt $TABACK_SSH_USER@$PROD_SERVER "cd $RELEASE_DIR && ./deploy_modules.sh"
      - step:
          name: Restart everything
          caches:
            - composer
            - node
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
            - ssh -tt $TABACK_SSH_USER@$PROD_SERVER "sudo supervisorctl restart all && sudo systemctl restart php7.4-fpm && sudo systemctl restart nginx"

    development:
      - step:
          name: Main deploy process
          deployment: development
          caches:
            - composer
            - node
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
            - echo "Deploy to dev server" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "rm -rf $RELEASE_DIR_REMOVE && mkdir $RELEASE_DIR_REMOVE && cd $RELEASE_DIR_REMOVE && git clone --branch $BITBUCKET_BRANCH https://$Cred/trustanalytica/trustanalytica.git $RELEASE_DIR_REMOVE"
            - echo "Copy env files" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cp $APP_ROOT/env.$BITBUCKET_BRANCH $RELEASE_DIR_REMOVE/app/config/.env" #&& cp $APP_ROOT/env.$BITBUCKET_BRANCH.client $RELEASE_DIR_REMOVE/react/client/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.server $RELEASE_DIR_REMOVE/react/server/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.messenger $RELEASE_DIR_REMOVE/react/messenger/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.badge $RELEASE_DIR_REMOVE/react/widgets/badge/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.review $RELEASE_DIR_REMOVE/react/widgets/review/.env && cp $APP_ROOT/env.$BITBUCKET_BRANCH.sadmin.catalog $RELEASE_DIR_REMOVE/react/superadmin/catalog-module/.env
            - echo "Install via composer" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $RELEASE_DIR_REMOVE && composer install"
      - parallel:
          - step:
              name: Checking everything is ok
              caches:
                - composer
                - node
              script:
                - apt-get update && apt-get install -y openssh-client
                - apt-get update && apt-get install -y unzip rsync wget
                - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
                - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $APP_ROOT && ./check_build.sh"
          - step:
              name: Creating cache files...
              caches:
                - composer
                - node
              script:
                - apt-get update && apt-get install -y openssh-client
                - apt-get update && apt-get install -y unzip rsync wget
                - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
                - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $APP_ROOT && ./cache_folders.sh"
          - step:
              name: Migrations magick
              caches:
                - composer
                - node
              script:
                - apt-get update && apt-get install -y openssh-client
                - apt-get update && apt-get install -y unzip rsync wget
                - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
                - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $RELEASE_DIR_REMOVE && vendor/bin/phinx migrate"
      - step:
          name: Re-link build
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "rm -rf $RELEASE_DIR && mv -f $RELEASE_DIR_REMOVE $RELEASE_DIR"
            - echo "Deploying Modules" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $RELEASE_DIR && ./deploy_modules.sh"
      - step:
          name: Restart everything
          caches:
            - composer
            - node
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "sudo supervisorctl restart all && sudo systemctl restart php7.4-fpm && sudo systemctl restart nginx"

    "version-*":
      - step:
          name: Deploying Sprint Updates
          deployment: sprint-version
          caches:
            - composer
            - node
          script:
            - apt-get update && apt-get install -y openssh-client
            - apt-get update && apt-get install -y unzip rsync wget
            - BRANCH_FOLDER=${BITBUCKET_BRANCH//./}
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer self-update --2
            - echo "Git prepare version branch" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $VERSIONS_DIR/$BRANCH_FOLDER/trustanalytica && git fetch origin $BITBUCKET_BRANCH && git checkout $BITBUCKET_BRANCH && git pull origin $BITBUCKET_BRANCH"
            - echo "Install via composer" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $VERSIONS_DIR/$BRANCH_FOLDER/trustanalytica && composer install"
            - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $VERSIONS_DIR/$BRANCH_FOLDER/trustanalytica && vendor/bin/phinx migrate"   
            - echo "Deploying Modules" && ssh -tt $TABACK_SSH_USER@$DEV_SERVER "cd $VERSIONS_DIR/$BRANCH_FOLDER && ./deploy_modules.sh"
            - ssh -tt $TABACK_SSH_USER@$DEV_SERVER "sudo supervisorctl restart all && sudo systemctl restart php7.4-fpm && sudo systemctl restart nginx"

OS version : Debian GNU/Linux 10


Solution

  • For reference:

    The issue is the actual 404 (not the typo in the package name). Luis Herrera in 1 pointed to the message 2 from Ansgar:

    the stretch, stretch-debug and stretch-proposed-updates suites have now also been imported on archive.debian.org. People still interested in these should update their sources.list.

    I plan to remove the suites from the main archive in about a month (2023-04-23 or later). [highlights by me]

    update the sources.list in the container.

    Please see the earlier and more canonical Q&A resource on site.

    Further notes

    With a recent fresh base container pull today for docker.io/php:7.3.18-apache I did not have the issue. Mind any caches within Bitbucket Pipelines tought and perhaps consider streamlining building the pipeline build containers with your prodcution containers so that you don't need to run apt-get all the time (both in the container build and the pipeline scripts).

    And seeing you running a PHP project with Atlassian Bitbucket Pipelines Plugin, if you're looking for a bit more comfort getting things on the run and test, checkout this local Bitbucket Pipelines Runner which you can run directly from your PHP project given Docker is available.

    It also has goodies like self-running docker build scripts, e.g. pipelines/lib/container/ .