作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的 gitlab ci 服务器上运行moodle phpunit。使用 gitlab-ci.yml 文件,我正在创建一个带有 php 5.6 和 mysql 服务的容器。
# Services
services:
- mysql:latest
before_script:
- mysql -e 'CREATE DATABASE gitlab_ci_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;' ;
我收到ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
并且不知道如何继续。
最佳答案
Tomasz 这是我的 gitlab-ci.yml 文件,您将需要这样的文件:
# Select image from https://hub.docker.com/r/_/php/
image: php:7.0.0
services:
- mysql:5.7
variables:
# Configure mysql environment variables (https://hub.docker.com/r/_/mysql/)
MYSQL_DATABASE: symfony
MYSQL_ROOT_PASSWORD: qwerty
# Composer stores all downloaded packages in the vendor/ directory.
# Do not use the following if the vendor/ directory is commited to
# your git repository.
cache:
paths:
- vendor/
before_script:
# Install dependencies
- bash ci/docker_install.sh > /dev/null
- cp ci/parameters.yml app/config/parameters.yml
- composer install
test:app:
script:
- phpunit
这是我的 ci 文件夹中的 docker_install.sh
#!/bin/bash
# We need to install dependencies only for Docker
[[ ! -e /.dockerenv ]] && [[ ! -e /.dockerinit ]] && exit 0
set -xe
# Install git (the php image doesn't have it) which is required by composer
apt-get update -yqq
apt-get install git -yqq
apt-get install wget -yqq
apt-get install zip unzip -yqq
# Install composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
# Install phpunit, the tool that we will use for testing
curl -o /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar
chmod +x /usr/local/bin/phpunit
# Install mysql driver
# Here you can install any other extension that you need
docker-php-ext-install pdo pdo_mysql mbstring
关于mysql - 我如何在 mysql docker 服务上创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34003404/
我是一名优秀的程序员,十分优秀!