Level 29
Try to add this to your docker file
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello
I try to configure the gitlab CICD but I always get the error :
Running with gitlab-runner 16.6.0~beta.105.gd2263193 (d2263193)
on blue-4.saas-linux-small-amd64.runners-manager.gitlab.com/default J2nyww-s, system ID: s_cf1798852952
feature flags: FF_USE_IMPROVED_URL_MASKING:true
Preparing the "docker+machine" executor
00:20
Using Docker executor with image ruby:3.1 ...
Pulling docker image ruby:3.1 ...
Using docker image sha256:fe5345016b77964fe21e462507d7c6db1982a4f91d1f85ebf0b2babcfe915a04 for ruby:3.1 with digest ruby@sha256:3c24464780a402a8b9ad6215848a025bb79eec4c822803434944ddc1dbe3f2bc ...
Preparing environment
00:05
Running on runner-j2nyww-s-project-52133591-concurrent-0 via runner-j2nyww-s-s-l-s-amd64-1708217890-57e722b7...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/MostafaTEST/tracker/.git/
Created fresh repository.
Checking out b95f4448 as detached HEAD (ref is main)...
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
Executing "step_script" stage of the job script
00:01
Using docker image sha256:fe5345016b77964fe21e462507d7c6db1982a4f91d1f85ebf0b2babcfe915a04 for ruby:3.1 with digest ruby@sha256:3c24464780a402a8b9ad6215848a025bb79eec4c822803434944ddc1dbe3f2bc ...
$ composer install
/usr/bin/bash: line 140: composer: command not found
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
here the .gitlab-cd.yml
stages:
- build
- test
- deploy
variables:
IMAGE_NAME: registry.example.com/group/project
cache:
paths:
- vendor/
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build:
stage: build
script:
- docker build -t $IMAGE_NAME .
- docker push $IMAGE_NAME
test:
stage: test
script:
- docker pull $IMAGE_NAME
- docker run --rm -v $(pwd):/app -w /app composer install
- docker run $IMAGE_NAME php artisan test
deploy:
stage: deploy
script:
- ls -l /builds/MostafaTEST/tracker
- cat /builds/MostafaTEST/tracker/deploy-script.sh
- ./deploy-script.sh
only:
- master
Dockfile:
# Use the official PHP image as the base image
FROM php:8.0-fpm
# Set environment variables for Laravel
ENV APP_NAME="laravel_app"
ENV APP_ENV="production"
ENV APP_KEY="base64:abcdefghijklmnopqrstuvwxyz1234567890"
ENV APP_DEBUG="false"
ENV APP_URL="http://localhost"
# Set environment variables for PostgreSQL
ENV DB_CONNECTION="pgsql"
ENV DB_HOST="db"
ENV DB_PORT="5432"
ENV DB_DATABASE="laravel_db"
ENV DB_USERNAME="laravel_user"
ENV DB_PASSWORD="password"
# Set environment variables for Nginx
ENV NGINX_VERSION="latest"
ENV NGINX_PORT="80"
# Install necessary packages
RUN apt-get update && apt-get install -y \
nginx \
postgresql \
supervisor \
unzip
# Copy Laravel files into the container
COPY . /var/www/html
# Configure Nginx
COPY laravel.conf /etc/nginx/sites-available/default
RUN ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
# Expose ports
EXPOSE 80
# Start services
CMD ["nginx", "-g", "daemon off;"]
deploy-script.sh
#!/bin/bash
# Navigate to your Laravel project directory
cd /builds/MostafaTEST/tracker
# Update your project from the Git repository
git pull origin master
# Install or update Composer dependencies
composer install --no-interaction --prefer-dist --optimize-autoloader
# Run database migrations
php artisan migrate --force
# Optionally, you may need to clear caches, generate key, and perform other tasks
php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:clear
php artisan optimize
# Reload your web server (assuming you are using something like Nginx or Apache)
# For Nginx
sudo service nginx reload
# You might also need to restart your queue worker or any other background processes
# php artisan queue:restart
# Add any additional deployment steps as needed
Any Idea ?
Please or to participate in this conversation.