Lsb_release

version: 2
jobs:
  build: 
    docker:
      - image: circleci/php:7.3.9
      - image: circleci/postgres:11.6-postgis -e POSTGRES_PASSWORD=testpwd
    steps:
      - checkout
      - run:
          name: Update RELEASE Environment Variable
          command: |
            echo 'export RELEASE=$(lsb-release -cs)' >> $BASH_ENV
            source $BASH_ENV
            echo $RELEASE
      - run: sudo apt install -y wget
      - run: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
      - run: 
           name: Update Repository
           command: |
             sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
             cat /etc/apt/sources.list.d/pgdg.list
      - run: sudo apt update && sudo apt -y upgrade
      - run: sudo apt install -y postgresql-client-11 php-pgsql
      - run: sudo docker-php-ext-install zip
      - run: sudo docker-php-ext-install php-pgsql
      - run: sudo composer self-update
      - restore_cache: # special step to restore the dependency cache if `composer.lock` does not change
          keys:
            - composer-v1-{{ checksum "composer.lock" }}
            # fallback to using the latest cache if no exact match is found (See https://circleci.com/docs/2.0/caching/)
            - composer-v1-
      - run: composer install -n --prefer-dist
      - save_cache: # special step to save the dependency cache with the `composer.lock` cache key template
          key: composer-v1-{{ checksum "composer.lock" }}
          paths:
            - vendor
      - restore_cache: # special step to restore the dependency cache if `package-lock.json` does not change
          keys:
            - node-v1-{{ checksum "package-lock.json" }}
            # fallback to using the latest cache if no exact match is found (See https://circleci.com/docs/2.0/caching/)
            - node-v1-
      - run: npm install
      - save_cache: # special step to save the dependency cache with the `package-lock.json` cache key template
          key: node-v1-{{ checksum "package-lock.json" }}
          paths:
            - node_modules
      - run: ./composer test

For the life of me, I am unable to figure out how to get lsb_release (or lsb-release … seems two different formats?) installed. How should I approach this?

Thank you!

Hey, welcome to the forum!

The official php:7.3.9 image (which is what our convenience images are based on) is based on the Debian (buster) docker image. It looks like the lsb-release package is not available for the Debian docker image, so this is why it is not working here and is not available to apt.

There are a few alternatives, depending on the information you are trying to obtain. Consider the following files which provide information about the release - you could extract

circleci@9e8d383a5503:~$ cat /etc/issue
Debian GNU/Linux 10 \n \l

circleci@9e8d383a5503:~$ cat /etc/debian_version 
10.1

circleci@9e8d383a5503:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

So for example, if you wanted to grab the version codename, you would use the following:

grep -oP "VERSION_CODENAME=\K.*" /etc/os-release

The -P flag here tells grep to use Perl style regex and the reason we need this is to enable \K. This will allow us to print out everything to the right of the regex match, so the output here would be buster instead of VERSION_CODENAME=buster.