这可能是一个微不足道的问题,但阅读ARG和ENV的文档并不能让我明白.
我正在构建一个PHP-FPM容器,我希望能够启用/禁用一些用户需求扩展.
如果可以在Dockerfile中通过添加条件并在构建命令上传递标志来完成,那将是很好的,但是不支持AFAIK.
在我的情况下,我个人的方法是在容器启动时运行一个小脚本,如下所示:
#!/bin/sh
set -e
RESTART="false"
# This script will be placed in /config/init/ and run when container starts.
if [ "$INSTALL_XDEBUG" == "true" ]; then
printf "\nInstalling Xdebug ...\n"
yum install -y php71-php-pecl-xdebug
RESTART="true"
fi
...
if [ "$RESTART" == "true" ]; then
printf "\nRestarting php-fpm ...\n"
supervisorctl restart php-fpm
fi
exec "$@"
Run Code Online (Sandbox Code Playgroud)
这是我的Dockerfile
样子:
FROM reynierpm/centos7-supervisor
ENV TERM=xterm \
PATH="/root/.composer/vendor/bin:${PATH}" \
INSTALL_COMPOSER="false" \
COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_ALLOW_XDEBUG=1 \
COMPOSER_DISABLE_XDEBUG_WARN=1 \
COMPOSER_HOME="/root/.composer" \ …
Run Code Online (Sandbox Code Playgroud) 我有一个本地开发服务器,我测试了很多东西,现在我正在玩bower来管理我的Symfony2项目中的库的依赖项.在安装了NodeJS(v0.10.31)和bower(1.3.9)后,我尝试sp:bower:install
从控制台运行属于Symfony2 SpBowerBundle 的命令root
:
Symfony > sp:bower:install
Installing bower dependencies for "TemplateBundle" into "/var/www/html/tanane/src/Tanane/TemplateBundle/Resources/config/bower/../../public/components"
bower ESUDO Cannot be run with sudo
Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814
You can however run a command with …
Run Code Online (Sandbox Code Playgroud) 我正在使用Docker,我有一个PHP,MySQL,Apache和Redis的堆栈.我现在需要添加MongoDB所以我正在检查Dockerfile以获取最新版本以及来自MongoDB Dockerhub 的docker-entrypoint.sh文件,但我找不到设置默认数据库,管理员用户/密码以及可能的身份验证的方法来自文件的容器的方法.docker-compose.yml
在MySQL中,您可以设置一些ENV变量,例如:
db:
image: mysql:5.7
env_file: .env
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
Run Code Online (Sandbox Code Playgroud)
这将设置数据库和用户/密码作为root
密码.
有什么办法可以实现与MongoDB相同的功能吗?任何人都有一些经验或解决方法?
我想尝试 Xdebug 3.0.0RC1 来探索发生了什么变化以及随之而来的新功能。我也在使用最新的 PhpStorm 2020.3 EAP,它支持 Xdebug 3,不需要主要配置。下面是我的调试器的 PhpStorm 配置:
这是我为 Xdebug3 尝试的配置:
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal # here I tried several combinations like: "localhost", "127.0.0.1", "172.17.0.1"
xdebug.client_port=9001 # here I tried several ports 9003 included with no success
Run Code Online (Sandbox Code Playgroud)
我也试过根本不添加client_host/client_port
设置,但仍然失败。
我收到此错误:
Script php bin/console doctrine:cache:clear-metadata returned with error code 255
!! [17-Nov-2020 15:24:40 UTC] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9001 (through xdebug.client_host/xdebug.client_port) :-(
!! [17-Nov-2020 15:24:41 UTC] PHP Fatal error: Method class@anonymous::__toString() …
Run Code Online (Sandbox Code Playgroud) 我有四个实体:OfficialDocument
,Media
,NMediaStatus
和NMediaType
.我正在尝试翻译这个SQL:
SELECT od.media, od.type, od.status, md.url, nms.name
FROM official_document od
LEFT JOIN media md ON od.media = md.id
LEFT JOIN n_media_status nms ON od.status = nms.id
WHERE od.company = 9
Run Code Online (Sandbox Code Playgroud)
到Doctrine Query Builder,这是结果:
public function findOfficialDocument($company_id) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('od.media', 'od.type', 'od.status', 'md.url', 'nms.name', 'nmt.name');
$qb->from('Company\RegisterCompanyBundle\Entity\OfficialDocument', 'od');
$qb->leftJoin('Common\MediaBundle\Entity\Media', 'md', \Doctrine\ORM\Query\Expr\Join::WITH, 'od.media = md.id');
$qb->leftJoin('Common\MediaBundle\Entity\NMediaStatus', 'nms', \Doctrine\ORM\Query\Expr\Join::WITH, 'od.status = nms.id');
$qb->leftJoin('Common\MediaBundle\Entity\NMediaType', 'nmt', \Doctrine\ORM\Query\Expr\Join::WITH, 'od.type = nmt.id');
$qb->where('od.company = ?1');
$qb->setParameter(1, $company_id);
return …
Run Code Online (Sandbox Code Playgroud) 我正在使用Docker Compose和卷
version: '2'
services:
php-apache:
env_file:
- dev_variables.env
image: reypm/php55-dev
build:
context: .
args:
- PUID=1000
- PGID=1000
expose:
- "80"
- "9001"
extra_hosts:
# IMPORTANT: Replace with your Docker Host IP (will be appended to /etc/hosts)
- "dockerhost:xxx.xxx.xxx.xxx"
volumes_from:
- volumes_source
volumes_source:
image: tianon/true
volumes:
- ../:/var/www
volumes_data:
image: tianon/true
volumes:
- ./data/sessions:/sessions
Run Code Online (Sandbox Code Playgroud)
我们来看看以下事实:
~/var/www
/var/www
我想与容器共享主机上的数据,但我甚至不知道docker-compose.yml
上面的文件是正确的还是需要更改的内容才能实现我的需要.我知道如何docker run
单独使用它,但没有Docker Compose的线索?
能帮助我做到这一点吗?
更新:玩这个
我已将此行添加到docker-compose.yml
文件中:
volumes_from:
- …
Run Code Online (Sandbox Code Playgroud) 开始之前我应该说我已经看了这个帖子和这个很好,但由于某些原因,解决方案,只要不是为我工作.我的存储库位于,~/sources
因此每个命令都从该路径运行.这就是我所做的:
将filemode更改为false:
$ git config --global core.filemode false
Run Code Online (Sandbox Code Playgroud)
检查全局配置:
$ git config --list
...
core.filemode=false
core.repositoryformatversion=0
core.bare=false
core.logallrefupdates=true
...
Run Code Online (Sandbox Code Playgroud)
重新初始化存储库:
$ git init
Reinitialized existing Git repository in /home/rperez/sources/.git/
Run Code Online (Sandbox Code Playgroud)
检查需要添加的内容:
$ git status
Run Code Online (Sandbox Code Playgroud)
我得到一个包含存储库中所有文件的列表.
我在用:
$ git --version
git version 2.9.3
Run Code Online (Sandbox Code Playgroud)
更新:为两个不同的文件添加了git diff
$ git status
...
modified: testing/test-valid-swasset-update.php
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
library/mpdf60/ttfontdata/dejavusanscondensedI.GDEFdata.php
...
Run Code Online (Sandbox Code Playgroud)
git diff
上述文件的输出:
$ git diff testing/test-valid-swasset-update.php
diff --git …
Run Code Online (Sandbox Code Playgroud) 我试图Discriminator
在一个从另一个扩展的实体中使用a .这是我制作的代码:
/**
* @ORM\Entity
* @ORM\Table(name="usuarios_externos.usuarios", schema="usuarios_externos")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({
* "natural" = "Natural",
* "empresa" = "Empresa"
* })
* @UniqueEntity(fields={"correo_alternativo"}, message="El correo electrónico ya está siendo usado.")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class Usuario extends BaseUser {
....
}
Run Code Online (Sandbox Code Playgroud)
但是在运行命令时我收到此错误doctrine:schema:validate
:
[Doctrine\ORM\Mapping\MappingException]实体'UsuarioBundle\Entity\Usuario'必须是'UsuarioBundle\Entity\Usuario'的鉴别器映射的一部分才能在继承层次结构中正确映射.或者,您可以将"UsuarioBundle\Entity\Usuario"设为抽象类,以避免发生此异常.
有任何解决这个问题的方法吗?可以在扩展类中使用Discriminator吗?
我已经阅读了有关如何部署Symfony2应用程序的 Symfony2 文档,但我遇到了一些问题警告.至于说这里的第一个命令我运行是这个:
composer install --no-dev --optimize-autoloader
Run Code Online (Sandbox Code Playgroud)
那个命令卸载| Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle
我在控制台遇到了这个错误:
Generating optimized autoload files
PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /var/www/sis-php-source/app/AppKernel.php on line 40
PHP Stack trace:
PHP 1. {main}() /var/www/sis-php-source/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /var/www/sis-php-source/app/console:28
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/sis-php-source/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
PHP 4. Symfony\Component\HttpKernel\Kernel->boot() /var/www/sis-php-source/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
PHP 5. Symfony\Component\HttpKernel\Kernel->initializeBundles() /var/www/sis-php-source/app/bootstrap.php.cache:2343
PHP 6. AppKernel->registerBundles() /var/www/sis-php-source/app/bootstrap.php.cache:2513
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
Run Code Online (Sandbox Code Playgroud)
这些是涉及此文件的内容(composer.json
和 …
我正在尝试driverid
使用set
,作为for driver in assigned.driver
循环中的var 来供以后使用.看下面我在做什么:
{% for key, assigned in pgn %}
<tr id="device-{{ assigned.id }}">
<td>{{ assigned.imei }}</td>
<td>{{ assigned.description }}</td>
<td>
{% for driver in assigned.driver %}
{{ driver.driver.id }} {# check if driver.driver.id has values testing purposes - delete me #}
{% set driverid = driver.driver.id %}
{% if driver.driver.name != "" %}
{% if driver.driver.name %}
{{ driver.driver.name }}
{% else %}
-
{% endif %}
{% endif %}
{% …
Run Code Online (Sandbox Code Playgroud) symfony ×5
php ×4
docker ×3
doctrine-orm ×2
arguments ×1
bower ×1
composer-php ×1
deployment ×1
dockerfile ×1
doctrine ×1
git ×1
ignore ×1
mapping ×1
mongodb ×1
node.js ×1
orm ×1
phpstorm ×1
symfony-2.4 ×1
twig ×1
xdebug ×1