lando / drupal

The Official Drupal Lando plugin
https://docs.lando.dev/drupal
GNU General Public License v3.0
16 stars 17 forks source link

D7 recipe with mysql tries to install postgres #42

Closed garrettw closed 1 year ago

garrettw commented 2 years ago

PostgreSQL should not be trying to install as I have nothing in my lando file asking for it.

Lando version: 3.1.4

.lando.yml:

name: myapp
recipe: drupal7
config:
  php: '7.3'
  composer_version: '2.4.4'
  via: apache:2.4
  webroot: .
  xdebug: true
  database: mysql:5.7
  config:
    php: .lando/php/php.ini

services:
  appserver:
    ssl: true
    build_as_root:
      - apt-get update
      - apt-get install -y libcurl4-openssl-dev libxml2-dev
      - printf "\n" | pecl install solr-2.5.1
      - docker-php-ext-enable solr
  pma:
    type: phpmyadmin
    hosts:
      - database

proxy:
  pma:
    - pma.myapp.lndo.site

The problematic part of the build output:

Get:1 http://security.debian.org/debian-security stretch/updates InRelease [59.1 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [34.8 kB]
Get:3 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [782 kB]
Ign:4 http://deb.debian.org/debian stretch InRelease       
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [397 kB]
Get:6 http://deb.debian.org/debian stretch-updates InRelease [93.6 kB]    
Get:7 http://deb.debian.org/debian buster InRelease [122 kB]              
Get:8 http://deb.debian.org/debian buster-updates InRelease [56.6 kB]          
Get:9 http://deb.debian.org/debian stretch Release [118 kB]
Get:10 http://deb.debian.org/debian stretch Release.gpg [3177 B]               
Get:11 http://deb.debian.org/debian buster/main amd64 Packages [7909 kB]
Get:12 http://deb.debian.org/debian buster-updates/main amd64 Packages [8788 B]
Get:13 http://deb.debian.org/debian stretch/main amd64 Packages [7080 kB]
Ign:14 http://apt.postgresql.org/pub/repos/apt stretch-pgdg InRelease          
Ign:15 http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release
Ign:16 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
Ign:17 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main all Packages
Ign:16 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
Ign:17 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main all Packages
Ign:16 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
Ign:17 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main all Packages
Ign:16 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
Ign:17 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main all Packages
Ign:16 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
Ign:17 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main all Packages
Err:16 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
  404  Not Found [IP: 147.75.85.69 80]
Ign:17 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main all Packages
Fetched 16.7 MB in 3s (5271 kB/s)
Reading package lists... Done
W: The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/stretch-pgdg/main/binary-amd64/Packages  404  Not Found [IP: 147.75.85.69 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR ==> E: Some index files failed to download. They have been ignored, or old ones used instead.
reynoldsalec commented 1 year ago

I'm guessing this was part of the apt-get update in the appserver's build_as_root; Lando's appserver containers are built on Debian images, and I believe Debian comes with Postgres by default.

If someone is in a similar position, I'm guessing you could run an apt remove postgresql or similar as an initial step.

Now I see why Alpine and other lean images are a thing ;)

lmlima commented 1 month ago

The postgresql repository moved to apt-archive, as stated in https://apt-archive.postgresql.org/:

Distribution releases are moved here from apt.postgresql.org after they have been EOLed by Debian or Ubuntu.

Note that it also affects lando users that use drupal7 with postgresql, so apt remove postgresql can not be a solution to those users.

If someone still has that issue, you need to fix postgresql /etc/apt/sources.list.d/pgdg.list file by adding before the apt update command in build_as_root section the command echo "deb http://apt-archive.postgresql.org/pub/repos/apt/ $(grep -oP 'VERSION_CODENAME=\K\w+' /etc/os-release)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list.

The .lando.yml file should be something like the following one:

.lando.yml:

name: myapp
recipe: drupal7
config:
  php: '7.3'
  composer_version: '2.4.4'
  via: apache:2.4
  webroot: .
  xdebug: true
  database: mysql:5.7
  config:
    php: .lando/php/php.ini

services:
  appserver:
    ssl: true
    build_as_root:
      - echo "deb http://apt-archive.postgresql.org/pub/repos/apt/ $(grep -oP 'VERSION_CODENAME=\K\w+' /etc/os-release)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
      - apt-get update
      - apt-get install -y libcurl4-openssl-dev libxml2-dev
      - printf "\n" | pecl install solr-2.5.1
      - docker-php-ext-enable solr
  pma:
    type: phpmyadmin
    hosts:
      - database

proxy:
  pma:
    - pma.myapp.lndo.site
reynoldsalec commented 1 month ago

...I recently rebuilt a D7 app running on PHP 7.2 that has an apt-get update in its build_as_root instructions and got this error. My solution was to simply update to running PHP 7.4, since that image is on a more recent version of Debian that still has the postgres package listing, but @lmlima your solution is the most universal.

reynoldsalec commented 1 month ago

...hopefully going to address this in the underlying PHP base images, see https://github.com/lando/php/issues/130 for more details.