Запустите Laravel на gitlab-ci.yaml - PullRequest
0 голосов
/ 20 марта 2020

Я пытаюсь развернуть Laravel, используя gitlab-ci.yaml и Gitlab runner, но развертывание никогда не удается. Я копирую код Dockerfile в манифест gitlab. Dockerfile:

#start with our base image (the foundation) - version 7.1.5
FROM php:7.1.5-apache

#set our application folder as an environment variable
ENV APP_HOME /app

WORKDIR $APP_HOME

#copy source files and run composer
COPY . $APP_HOME

#install all the system dependencies and enable PHP modules 
RUN apt-get update && apt-get install -y \
      libicu-dev \
      libpq-dev \
      libmcrypt-dev \
      git \
      zip \
      unzip \
      libfreetype6-dev \
      libjpeg62-turbo-dev \
      libpng-dev \
    && rm -r /var/lib/apt/lists/* \
    && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
    && docker-php-ext-install \
      gd \
      intl \
      mbstring \
      mcrypt \
      pcntl \
      pdo_mysql \
      pdo_pgsql \
      pgsql \
      zip \
      opcache

#install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
# install all PHP dependencies
RUN composer install --no-interaction

#change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data

COPY vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data $APP_HOME \
    && a2enmod rewrite \
    && a2enmod headers

И я пытаюсь это сделать на gitlab-ci.yaml:

# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/php
image: php:7.1.5-apache

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
    - vendor/

variables:
  APP_HOME: /app

# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
  # Update packages
  - mkdir /app && cd /app
  - apt-get update && apt-get install -y \
      libicu-dev \
      libpq-dev \
      libmcrypt-dev \
      git \
      zip \
      unzip \
      libfreetype6-dev \
      libjpeg62-turbo-dev \
      libpng-dev \
    && rm -r /var/lib/apt/lists/* \
    && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
    && docker-php-ext-install \
      gd \
      intl \
      mbstring \
      mcrypt \
      pcntl \
      pdo_mysql \
      pdo_pgsql \
      pgsql \
      zip \
      opcache

deploy:
  script:
    # run laravel tests
    - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
    - composer install --no-interaction
    - usermod -u 1000 www-data && groupmod -g 1000 www-data
    - cp vhost.conf /etc/apache2/sites-available/000-default.con
    - chown -R www-data:www-data $APP_HOME \
        && a2enmod rewrite \
        && a2enmod headers

Но когда я пу sh на gitlab, конвейер завершается с этим сообщением :

Running with gitlab-runner 12.9.0-rc1 (a350f628)
   on docker-auto-scale 72989761
Preparing the "docker+machine" executor
00:26
 Using Docker executor with image php:7.1.5-apache ...
 Pulling docker image php:7.1.5-apache ...
 Using docker image sha256:be6dcd27eea7e35c58981df2f04bb24bd51666d9dac2f1002f89f1dc5a7da2c0 for php:7.1.5-apache ...
Preparing environment
00:05
 Running on runner-72989761-project-17269617-concurrent-0 via runner-72989761-srm-1584717146-e3ecfc95...
Getting source from Git repository
00:06
 $ eval "$CI_PRE_CLONE_SCRIPT"
 Fetching changes with git depth set to 50...
 Initialized empty Git repository in /builds/polichat/polichat-web-app/.git/
 Created fresh repository.
 From https://gitlab.com/polichat/polichat-web-app
  * [new ref]         refs/pipelines/128202740 -> refs/pipelines/128202740
  * [new branch]      release/gitlab-ci        -> origin/release/gitlab-ci
  * [new tag]         pegarNomeExt             -> pegarNomeExt
  * [new tag]         v1.19.37                 -> v1.19.37
  * [new tag]         v1.19.39                 -> v1.19.39
  * [new tag]         v1.20.0                  -> v1.20.0
  * [new tag]         v1.20.1                  -> v1.20.1
 Checking out 26ec0587 as release/gitlab-ci...
 Skipping Git submodules setup
Restoring cache
00:01
 Checking cache for default...
 FATAL: file does not exist                         
 Failed to extract cache
Downloading artifacts
00:02
Running script from Job
00:23
 $ mkdir /app && cd /app
 $ apt-get update && apt-get install -y \ libicu-dev \ libpq-dev \ libmcrypt-dev \ git \ zip \ unzip \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ && rm -r /var/lib/apt/lists/* \ && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \ && docker-php-ext-install \ gd \ intl \ mbstring \ mcrypt \ pcntl \ pdo_mysql \ pdo_pgsql \ pgsql \ zip \ opcache
 Ign http://deb.debian.org jessie InRelease
 Get:1 http://deb.debian.org jessie-updates InRelease [16.3 kB]
 Get:2 http://security.debian.org jessie/updates InRelease [44.9 kB]
 Get:3 http://deb.debian.org jessie Release.gpg [1652 B]
 Get:4 http://deb.debian.org jessie Release [77.3 kB]
 Get:5 http://deb.debian.org jessie-updates/main amd64 Packages [20 B]
 Get:6 http://security.debian.org jessie/updates/main amd64 Packages [950 kB]
 Get:7 http://deb.debian.org jessie/main amd64 Packages [9098 kB]
 Fetched 10.2 MB in 8s (1175 kB/s)
 Reading package lists...
 W: There is no public key available for the following key IDs:
 AA8E81B4331F7F50
 Reading package lists...
 Building dependency tree...
 Reading state information...
 E: Unable to locate package  libicu-dev
 E: Unable to locate package  libpq-dev
 E: Unable to locate package  libmcrypt-dev
 E: Unable to locate package  git
 E: Unable to locate package  zip
 E: Unable to locate package  unzip
 E: Unable to locate package  libfreetype6-dev
 E: Unable to locate package  libjpeg62-turbo-dev
 E: Unable to locate package  libpng-dev
 E: Unable to locate package  
 $ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
 All settings correct for using Composer
 Downloading...
 Composer (version 1.10.1) successfully installed to: /usr/bin/composer
 Use it: php /usr/bin/composer
 $ composer install --no-interaction
 Composer could not find a composer.json file in /app
 To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running after script
00:02
Uploading artifacts for failed job
00:01
 ERROR: Job failed: exit code 1

Кто-нибудь может мне помочь, пожалуйста? Я видел, что libs не был установлен, и попробуйте сначала, но не решено.

...