From 86b1fe7263216ab7acbf3b2f60f7290efcfdaea5 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sat, 7 Mar 2026 00:27:16 +0100 Subject: [PATCH] 40 - Add base image for faster CI build --- Dockerfile | 25 ++----------------------- docker/build/Dockerfile.base | 24 ++++++++++++++++++++++++ shell.nix | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 docker/build/Dockerfile.base diff --git a/Dockerfile b/Dockerfile index 929892d..c86a0e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,5 @@ -# Production Dockerfile with FrankenPHP -FROM dunglas/frankenphp:latest-php8.3-alpine - -# Install system dependencies -RUN apk add --no-cache \ - nodejs \ - npm \ - git \ - mysql-client - -# Install PHP extensions -RUN install-php-extensions \ - pdo_mysql \ - opcache \ - zip \ - gd \ - intl \ - bcmath \ - redis \ - pcntl - -# Install Composer -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer +# Production Dockerfile - uses pre-built base image +FROM forge.lvl0.xyz/lvl0/fedi-feed-router-base:latest # Set working directory WORKDIR /app diff --git a/docker/build/Dockerfile.base b/docker/build/Dockerfile.base new file mode 100644 index 0000000..e7280db --- /dev/null +++ b/docker/build/Dockerfile.base @@ -0,0 +1,24 @@ +# Base image with FrankenPHP, PHP extensions, Node, and Composer +FROM dunglas/frankenphp:latest-php8.3-alpine + +# Install system dependencies +RUN apk add --no-cache \ + nodejs \ + npm \ + git \ + mysql-client \ + curl + +# Install PHP extensions +RUN install-php-extensions \ + pdo_mysql \ + opcache \ + zip \ + gd \ + intl \ + bcmath \ + redis \ + pcntl + +# Install Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer \ No newline at end of file diff --git a/shell.nix b/shell.nix index dc33800..d674e21 100644 --- a/shell.nix +++ b/shell.nix @@ -81,6 +81,35 @@ pkgs.mkShell { podman-compose -f $COMPOSE_FILE exec app php artisan "$@" } + # =================== + # BUILD COMMANDS + # =================== + base-build() { + local image="forge.lvl0.xyz/lvl0/fedi-feed-router-base:latest" + + # Check if logged in, prompt if not + if ! podman login --get-login forge.lvl0.xyz &>/dev/null; then + echo "Not logged in to forge.lvl0.xyz" + podman login forge.lvl0.xyz || return 1 + fi + + echo "Building base image: $image" + if ! podman build -t "$image" -f docker/build/Dockerfile.base .; then + echo "Build failed!" + return 1 + fi + + echo "" + echo "Pushing to registry..." + if ! podman push "$image"; then + echo "Push failed!" + return 1 + fi + + echo "" + echo "Done! Base image pushed: $image" + } + # =================== # WELCOME MESSAGE # =================== @@ -99,6 +128,7 @@ pkgs.mkShell { echo " dev-logs-db Tail database logs" echo " dev-shell Shell into app container" echo " dev-artisan Run artisan command" + echo " base-build Build and push base image" echo "" echo "Services:" echo " app Laravel + Vite http://localhost:8000"