Laravel Fly Docker Image

Hi,
When creating a new laravel application with fly, the Dockerfile created uses an image from fideloper/fly-laravel:${PHP_VERSION} as base.

This works alright but I need my image to contain the postgres-client or pg_dump package for me to use spatie laravel backups to backup my database.

Apparently, I am not able to sudo apt install new packages once using the fideloper/fly-laravel:8.2 package. I checked out the image on docker hub https://hub.docker.com/r/fideloper/fly-laravel/tags but it looks like it’s not linked to any github account for me to see and perhaps customize the Dockerfile.

In this case, I want to customize the Dockerfile, are there any suggestions or ways I can do that to enable pg_dump?

That’s weird because I can install custom package with the same image.

Here I have my Mongodb install in my Dockerfile

RUN apt-get update && apt-get install -y \
  php${PHP_VERSION}-mongodb  \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*
1 Like

Thanks for this suggestion. @AsymetricalData I realized I was using sudo and that was one of the factors causing the commands to fail.

In the end, I was also missing the postgres linux source. I was also getting errors, Unable to find package information.

So I ended up using this to add the client:

RUN curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null

RUN echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list

RUN apt-get update

RUN apt-get install -y postgresql-client-13

PS: I got the above command from laravel sail 8.2 Dockerfile. The change I had to make was to use focal-pgdg instead of jammy-pgdg for the postgres deb repo source as the laravel base image uses ubuntu 22.04.

2 Likes

Hey there!

Sorry for the trouble on this - If you want to take a peak, the repository generating those Docker images is found here: GitHub - fly-apps/laravel-docker: Base Docker images for use with Laravel on Fly.io

I’ll add that to the readme.

1 Like

Oh good, thanks very much. I wanted to take a peak at it earlier but could not find the Dockerfile

1 Like

Just a quick note: I’ve setup the git repository to rebuild the images every 3 days so the latest minor (point releases) of PHP get updated in the base images:

1 Like