- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个容器化的 PHP 应用程序。我正在尝试在 Azure 中设置管道,但我很难在构建的容器内运行命令(这对于完全安装和搭建应用程序至关重要,以便我可以运行代码分析和测试)。
我已经设置了 make 命令,所以安装应用程序的方法很简单
make up
make install
这些正在有效运行:
docker-compose up --build -d
docker-compose exec -T {containerName} composer install
docker-compose exec -T {containerName} php artisan migrate:fresh
docker-compose exec -T {containerName} php artisan passport:install
docker-compose exec -T {containerName} php artisan db:seed
...
要构建镜像,安装依赖项(laravel),搭建应用程序后端。
我的测试azure-pipelines.yml
设置如下:
# Docker
# Build a Docker image
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- develop
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/infrastructure/php/Dockerfile'
tags: |
$(tag)
- job: Install
displayName: Install app
dependsOn: Build
steps:
- script: |
docker-compose exec -T api composer install
- job: Database
displayName: Scaffold Database
dependsOn: Install
steps:
- script: |
make db_reset
- job: Analyse
displayName: Analyse backend
dependsOn: Database
steps:
- script: |
make analyse
- job: Test
displayName: Run tests
dependsOn: Analyse
steps:
- script: |
php artisan test
但是在Install
作业上失败,错误日志如下:
Starting: CmdLine
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.201.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
docker-compose exec -T api composer install
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/a440fb6a-e03b-4da2-b958-1fa3aefa2084.sh
##[error]Bash exited with code '1'.
Finishing: CmdLine
Verifying lock file contents can be installed on current platform.
Package operations: 163 installs, 0 updates, 0 removals
In Filesystem.php line 268:
/var/www/app/vendor does not exist and could not be created.
在构建镜像后尝试安装 Composer 依赖项时。设置非常标准。
Dockerfile
FROM php:8.1-apache
RUN apt update
RUN apt-get install -y --no-install-recommends \
g++ \
libicu-dev \
libpq-dev \
libzip-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
git \
lsb-release \
gnupg \
zip
RUN docker-php-ext-install \
intl \
opcache \
pdo \
pdo_mysql \
zip \
exif \
gd
RUN pecl install \
pcov \
xdebug
WORKDIR /var/www/app
RUN usermod -a -G www-data www-data
RUN chown root:root /var/www
RUN chown -R www-data:www-data /var/www/app
RUN chmod -R 755 /var/www/app
RUN mkdir /var/www/app/vendor
RUN chmod -R 775 /var/www/app/vendor
RUN chown -R www-data:www-data /var/www/app/vendor
RUN a2enmod rewrite
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
USER www-data
docker-compose
version: '3.8'
services:
database:
image: mysql:8.0
container_name: database
environment:
- MYSQL_DATABASE=app
- MYSQL_ROOT_PASSWORD=root
volumes:
- ./infrastructure/mysql-data:/var/lib/mysql
ports:
- '3306:3306'
api:
container_name: api
build:
context: ./infrastructure/php
ports:
- '8080:80'
volumes:
- ./server:/var/www/app
- ./infrastructure/apache/default.conf:/etc/apache2/sites-enabled/000-default.conf
depends_on:
- database
mailhog:
image: mailhog/mailhog:latest
container_name: mailhog
ports:
- '1025:1025'
- '8025:8025'
生成文件
DOCKER_COMPOSE = docker-compose
COMPOSER ?= composer
PHP_CMD = php
PHP_SERVICE = api
up:
@echo "\n==> Docker container building and starting ..."
$(DOCKER_COMPOSE) up --build -d
db_reset:
$(DOCKER_COMPOSE) exec -T api php artisan migrate:fresh
$(DOCKER_COMPOSE) exec -T api php artisan passport:install
$(DOCKER_COMPOSE) exec -T api php artisan db:seed
analyse:
$(DOCKER_COMPOSE) exec -T -u root api php artisan ide-helper:models -W
$(DOCKER_COMPOSE) exec -T -u root api ./vendor/bin/php-cs-fixer fix app
$(DOCKER_COMPOSE) exec -T -u root api ./vendor/bin/phpstan analyse --memory-limit=2G -c phpstan.neon
我假设问题出在尝试通过容器运行 Composer install 时的权限,但是,我实际上如何使用该容器呢?本地没有权限问题。构建显然成功了,这是构建作业的最后一个片段:
---> Running in b83b9f8e8010
All settings correct for using Composer
Downloading...
Composer (version 2.3.5) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Removing intermediate container b83b9f8e8010
---> bc104ff13e89
Step 11/22 : USER www-data
---> Running in 200f01ed5b5f
Removing intermediate container 200f01ed5b5f
---> 2431fb9a77ae
Step 12/22 : LABEL com.azure.dev.image.build.buildnumber=20220509.10
---> Running in 8183d45902d5
Removing intermediate container 8183d45902d5
---> d1a9ed6d2dc6
Step 13/22 : LABEL com.azure.dev.image.build.builduri=vstfs:///Build/Build/14
---> Running in 316a03a492e7
Removing intermediate container 316a03a492e7
---> 8bd620fc9792
Step 14/22 : LABEL com.azure.dev.image.build.definitionname=REDACTED
---> Running in 75f66a32856a
Removing intermediate container 75f66a32856a
---> 4daf41f08c6c
Step 15/22 : LABEL com.azure.dev.image.build.repository.name=REDACTED
---> Running in 707ba3523e83
Removing intermediate container 707ba3523e83
---> 7084ad9947a7
Step 16/22 : LABEL com.azure.dev.image.build.repository.uri=REDACTED
---> Running in b08c87ff8818
Removing intermediate container b08c87ff8818
---> 83a6531aef80
Step 17/22 : LABEL com.azure.dev.image.build.sourcebranchname=develop
---> Running in 0d69670ee481
Removing intermediate container 0d69670ee481
---> 6389f09560dc
Step 18/22 : LABEL com.azure.dev.image.build.sourceversion=dab0a85595268c16a05c5292adc1e0340c13818f
---> Running in 3b58e7fe5640
Removing intermediate container 3b58e7fe5640
---> e495c2eeab89
Step 19/22 : LABEL com.azure.dev.image.system.teamfoundationcollectionuri=REDACTED
---> Running in 2e04a85c91b9
Removing intermediate container 2e04a85c91b9
---> 4570213d4e47
Step 20/22 : LABEL com.azure.dev.image.system.teamproject=REDACTED
---> Running in f4c914d2522c
Removing intermediate container f4c914d2522c
---> 0ee813e09dbf
Step 21/22 : LABEL image.base.digest=sha256:2891049f5a33bd4ac61ea28b4d4f9144468e50369b7bc29ff61e2dd3089f5bb6
---> Running in 564f498fb0c4
Removing intermediate container 564f498fb0c4
---> 039be559c0d4
Step 22/22 : LABEL image.base.ref.name=php:8.1-apache
---> Running in 60c373b879be
Removing intermediate container 60c373b879be
---> c10cb44c17d6
Successfully built c10cb44c17d6
Finishing: Build an image
...或者,我这样做完全错误吗?任何帮助将不胜感激。
最佳答案
权限问题发生在您的 ./server 目录上,您应该检查该目录的所有者和权限。
关于php - 如何在 Azure 管道内的 Docker 容器中运行命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72332702/
似乎有很多方法可以在 Azure 中自动使用 PowerShell。由于 ARM 模板是最新的,Azure 中的其他 PowerShell 选项是否已过时?这些工具/脚本之间有什么区别: Azure
我正在开发一个将托管在 Azure 中的 Web API。我想使用 Azure 诊断将错误记录到 Azure 表存储中。在经典门户中,我可以将日志配置为转到 Azure 表存储。 Classic Po
Azure 文件存储事件可以触发 Azure WebJob 或 Azure Function 吗? 例如,在文件夹“/todo/”中创建文件时。 最佳答案 我们目前没有任何 Azure 文件绑定(bi
我需要创建一个逻辑应用程序,我的要求是,我需要从 azure data Lake Gen2 文件夹迁移 json 文件,并根据某些值需要将该 json 转换为 xml,然后将其发送到 SQL。 因此,
我使用 VS Code 创建了 1 个 node.js 和 1 个 java Azure Function 当我使用 VS Code 将这两个函数部署到 Azure 时,我最终获得了这么多 Azure
收集 Azure 诊断数据时,暂存槽是否也会将诊断数据发送到 WadPerformanceCounters 表? 如果是这样,我该如何关闭它?或者在阅读诊断信息时如何区分暂存/生产。 我不想显示有关我
您好,我是 Azure 的新手。我有 VS 2012 和 Azure SDK 2.1,当我使用模拟器运行我的 Web 应用程序时一切正常。但是当我在 azure 上部署时出现错误消息: Could n
我很难区分 Azure 订阅和 Azure 租户有何不同?我尝试使用示例来弄清楚,但每次我得出的结论是它们在某种程度上是相同的?如果租户是组织在注册 Microsoft 云服务时接收并拥有的 Azur
如果我想在 Azure Insights 中设置自定义指标集合,并以(近)实时的方式可视化其中一些指标,并查看聚合的历史数据,我应该使用 Azure Metrics Explorer 还是 Azure
我想了解具有以下配置的 Azure 数据工厂 (ADF) 的现实示例/用例: Azure 集成运行时 (AIR) 默认值 自托管集成运行时(SHIR) 其他问题: 这两种配置(AIR 和 SHIR)是
请参阅下面来自 Azure 服务总线的指标。想要识别请求数量中的背景噪音|流量较低时的响应。假设振荡请求| session 中 amqp 握手的响应是潜在的。只是不明白这是什么类型的握手?从总线接收的
此问题与 Azure 事件中心和 Azure 服务总线之间的区别无关。 问题如下: 如果您将Azure Events Hub添加到您的应用程序中,那么您会注意到它依赖于Azure Service Bu
这两个事情是完全不同的,还是它们能完成的事情大致相同/相似? 最佳答案 Azure 辅助角色是“应用程序场”中您自己的一组虚拟机。您可以以分布式方式在它们上运行任何代码。通常,您编写业务代码以在这些服
我目前正在使用 Windows Azure 虚拟机来运行 RStudio, 我的虚拟机是 Windows Server R2 2012,它是 Azure 上的一项附加服务。 我还有一个 Azure 存
我们正在寻找托管一个网站(一些 css、js、一个 html 文件,但不是 aspx、一个通用处理程序)。 我们部署为: 1) Azure 网站 2) Azure 云服务 两种解决方案都有效。但有一个
我想从 Azure 表创建 blob。 AzCopy 支持此功能,但我找不到任何说明数据移动 API 也支持它的文档。此选项可用吗? https://azure.microsoft.com/en-us
This article表示 Azure 订阅所有者有权访问订阅中的所有资源。但是,要访问 Azure 数据库,必须是数据库中的用户,或者是 Azure Admin AD 组的成员。 无论 SQL 安
我尝试使用以下代码将 XML 文件上传到 Azure FTP 服务器: https://www.c-sharpcorner.com/article/upload-and-download-files-
除了 Azure 服务总线使用主题而 Azure 事件中心基于事件 - Azure 事件中心和 Azure 服务总线之间是否有任何根本区别? 对我来说,事件和消息之间没有真正的区别,因为两者只是不同类
我有一个通过虚拟网络网关连接到 Azure 虚拟网络的 Windows VPN 客户端。目标#1 是使用其内部 IP 地址连接到我的虚拟机。这有效。 第二个目标是使用其内部计算机名称进行连接(因为 I
我是一名优秀的程序员,十分优秀!