Nginx在Bitbucket管道

afdcj2ne  于 2023-05-28  发布在  Nginx
关注(0)|答案(1)|浏览(228)

我正在尝试使用Bitbucket Pipelines运行Web服务器。
这是我目前为止的bitbucket-pipelines.yml:

image: php:latest

pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - apt-get update && apt-get install -y unzip
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
          - vendor/bin/behat --colors --format=pretty --out=std
        services:
          - selenium
          - nginx

definitions:
  services:
    selenium:
      hostname: selenium
      image: selenium/standalone-chrome:latest
    nginx:
      image: nginx

现在,如果我转到http://localhost,我可以看到默认的Nginx页面。
我怎样才能在仓库中提供一些文件而不是这样?可以将文件复制到Nginx容器吗?

bd1hkmkf

bd1hkmkf1#

如果不获取所有 meta并使用自定义的Docker-in-Docker镜像,在bitbucket服务中安装文件似乎是不可能的,所以我最终放弃了nginx服务。但是我成功地运行了PHP内置的Web服务器!

php -S 127.0.0.1:80 public/index.php &

-S选项启动内置的开发服务器,public/index.php是我的应用程序的入口点。&将进程推到后台。它似乎只适用于127.0.0.1 IP,如果您尝试自定义主机,它将无法工作。
以下是我的完整管道配置:

image:
  name: php:8.1-fpm
  username: $DH_USER
  password: $DH_PASS

definitions:
  services:
    db:
      image: mariadb:10.2
      variables:
        MARIADB_DATABASE: MY_TEST_DB
        MARIADB_USER: root
        MARIADB_ROOT_PASSWORD: 'root'
    chrome:
      image: selenium/standalone-chrome
      ports:
        - 4444
        - 5900

pipelines:
  pull-requests:
    '**':
      - step:
          services:
            - db
            - chrome
          name: Installing Composer and running Unit Tests...
          script:
            - if [[ "${BITBUCKET_PR_DESTINATION_BRANCH}" != "develop" ]] && [[ "${BITBUCKET_PR_DESTINATION_BRANCH}" != "release/"* ]]; then printf "Skipping Tests for this target (${BITBUCKET_PR_DESTINATION_BRANCH})"; exit; fi
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer install --no-scripts
            - vendor/bin/grumphp git:pre-commit
            - cp config/autoload/data.test.php.dist config/autoload/data.test.php
            - php bin/console orm:schema-tool:create
            - php bin/console fixtures:load
            - php -S 127.0.0.1:80 public/index.php &
            - vendor/bin/codecept run

  branches:
    develop:
      - step:
          services:
            - db
          name: Installing Composer and running Unit Tests...
          script:
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer install --no-scripts
            - vendor/bin/grumphp git:pre-commit
            - cp config/autoload/data.test.php.dist config/autoload/data.test.php
            - php bin/console orm:schema-tool:update --force --complete
            - php bin/console fixtures:load
            - php -S 127.0.0.1:80 public/index.php &
            - vendor/bin/codecept run unit

相关问题