gpt4 book ai didi

docker - 使用 docker 在 gitlab 中进行 Laravel 黄昏测试 - 无法连接到本地主机端口 9515 : Connection refused

转载 作者:行者123 更新时间:2023-12-02 18:53:37 25 4
gpt4 key购买 nike

在 gitlab 上的 docker 容器中运行 laravel-dusk on 时,我收到一条错误消息,指出它无法连接到本地主机上的端口 9515。

无法连接到本地主机端口 9515:连接被拒绝

我的 docker 文件如下所示:

# Set the base image for subsequent instructions
FROM php:7.1

# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Install packages
RUN apt-get update -yqq && apt-get install -y git wget curl libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq bzip2 libfontconfig xvfb chromium libmagickwand-dev

# Add chrome repo and install google-chrome-stable
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update
RUN apt-get install -y google-chrome-stable

# Install php environment
RUN docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache bcmath

# Install imagick
RUN pecl install imagick && docker-php-ext-enable imagick

# check installed modules
RUN php -m

# Install NVM
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.1.4
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

# install node and npm
RUN source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default

# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

# Install Composer Package manager
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php \
php -r "unlink('composer-setup.php');" && mv composer.phar /usr/local/bin/composer

# Update packages
RUN apt-get update

# Xdebug
RUN pecl install -o -f xdebug \
&& rm -rf /tmp/* \ && docker-php-ext-enable xdebug

# Clear out the local repository of retrieved package files
RUN apt-get clean


# Install Laravel Envoy
RUN composer global require "laravel/envoy=~1.0"

# confirm installed versions
RUN node -v
RUN npm -v
RUN php -v
RUN google-chrome-stable --version
RUN composer --version
RUN php -m

EXPOSE 9515

然后我的 gitlab-ci 文件如下所示:

image: registry.gitlab.com/path-to-repo/repo-name:latest

# Select what we should cache
cache:
paths:
- vendor/

services:
- mysql:5.7

variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: database-name
MYSQL_ROOT_PASSWORD: database-password
DB_HOST: mysql
DB_USERNAME: root

stages:
- test

unit_test:
stage: test
script:
- cp .env.runnable .env
- composer install
- php artisan config:clear
- php artisan key:generate
- php artisan migrate --seed
- php artisan db:seed --class=TestSeeder
- vendor/bin/phpunit --coverage-text --colors=never
- php artisan env
- php artisan dusk

起初我以为是因为我没有暴露9515端口,但是我已经在Dockerfile中暴露了这个。但是,现在我不知道问题出在哪里。此端口用于另一个进程是否存在问题?会不会是 Chromedriver 在不同的端口上运行?

最佳答案

在你的 gitlab-ci 文件中,尝试将 php artisan dusk 替换为:

php artisan serve & php artisan dusk

关于docker - 使用 docker 在 gitlab 中进行 Laravel 黄昏测试 - 无法连接到本地主机端口 9515 : Connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50291230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com