Hello! I creating application with gitlab package registry(dockerhub but local in gitlab).
I created my docker image for laravel only for testins env and next step deploy my app to servers.
But. when I testing deployment jobs I get error:
Composer could not find a composer.json file in /builds/
Docker image for testing:
FROM php:8-fpm-alpine
WORKDIR /var/www
RUN apk update \
&& apk add \
$PHPIZE_DEPS \
git \
zlib-dev \
libzip-dev \
zip && \
rm -rf /var/lib/apt/lists
RUN pecl install igbinary \
&& docker-php-ext-enable igbinary \
&& pecl install msgpack \
&& docker-php-ext-enable msgpack \
&& docker-php-ext-install bcmath pcntl sockets pdo_mysql zip
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
Gitlab-ci.yml
image: $CI_REPOSITORY/gitlab-ci
stages:
- composer
- build
- syntax
- phpunit
cache:
paths:
- vendor/
- .env
composer:
stage: composer
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
only:
changes:
- composer.json
# Prepare project
build:
stage: build
script:
- cp .env.testing .env
- php artisan key:generate
only:
changes:
- .env.testing
syntax:
stage: syntax
script:
- composer dump-autoload
- vendor/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php
only:
changes:
- "**/*.php"
phpunit:
stage: phpunit
script:
- vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml --testsuite Unit
only:
changes:
- composer.json
- app/**/*
- config/**/*
- tests/**/*
So, I wanted to ask, does the application code really need to be stored in the image, or can it be copied there during after pushing to gitlab?
Do I need make something like this:
COPY . /var/www
Or mb this?
docker run --name gitlab-test-ci -v .:/var/www -dp 80:80 gitlab-test-ci
I mean how can I fix error in my application and how can make correctly settings for gitlab package registry?
Thanks