I have a problem using docker compose link alias. I host a PHP application on docker and use curl in the application
this is my docker-compose.yml
php:
external_links:
- apache:my-apache
That links is working. I have my-apache item on /etc/hosts
172.17.0.5 my-apache
But the problem comes when i use php curl to access my-apache service, since php curl requires the strict format : http://domain.com, and i am unable to use http://domain.com as an alias for docker link.
This will produce error
apache:http://domain.com
The error :
ERROR: for php too many values to unpack
Any suggestions?
Big Thanks
Related
I'm trying to run a Symfony application with Bref and serverless-offline. I know that Bref doesn't officially support serverless-offline, but I want to give it a shot; this thread - https://github.com/brefphp/bref/issues/875 - implies that it should be possible but I'm not getting the error described there yet.
When I run sls invoke local -f MyLambda I get this error:
{"errorType":"exitError","errorMessage":"RequestId: 09256631-dcc7-1775-350e-b0c10a2c9c00 Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"}
So I assume that serverless-offline fails to get the layer correctly. The directory .serverless/layers contains a sub-structure php-81-fpm/18 for the PHP layer but it is empty.
What's important is that I'm running this setup in a development Docker container. I mounted the docker socket so the Docker daemon on the host is used.
The serverless.yml looks like this (simplified):
plugins:
- ./vendor/bref/bref
- serverless-offline
functions:
MyLambda:
handler: public/index.php
layers:
- ${bref:layer.php-81-fpm} # also tried with 'arn:aws:lambda:eu-central-1:209497400698:layer:php-81-fpm:18'
custom:
serverless-offline:
host: 0.0.0.0
useDocker: true
dockerHost: host.docker.internal
I'm happy to provide further information, please let me know. Don't hesitate to suggest "low-level" things as I'm quite new to this ecosystem. Thanks for your help!
I'm working on a Gitlab CI configuration in the .gitlab-ci.yml file for a Laravel project which uses redis as Cache Driver. Within this configuration file I use an image which has all the linux packages, php extension which are used on our production environment. This includes the redis extension installed by pecl so phpredis can be used within Laravel.
After spending a fair amount of time into learning the process of continuous integration and the configuration of the gitlab ci file I encountered the following error on deploy of the image:
In PhpRedisConnector.php line 126:
Redis::connect() expects parameter 2 to be int, string given
parameter should be only the port as an int but somehow turned into tcp://111.111.11.11:6379
As documented https://docs.gitlab.com/ee/ci/services/redis.html the host in your .env should be redis so I had. Dumping the config during the deploy resulted in port being some tcp://111.111.11.11:6379 connection string and host being empty. There is no way this is changed within our application or any extension we use.
I use the https://hub.docker.com/_/redis/ as a service in the .gitlab-ci.yml.
...
services:
- name: redis:4
...
Solution found here:
https://laracasts.com/discuss/channels/testing/gitlab-ci-weird-redis-host
This variable isn't documented anywhere but somehow it solves the problem.
Add the following to your .gitlab-ci.yml file:
variables:
REDIS_PORT: 6379
If anyone finds documentation about this variable and maybe more options, let me know!
This is expected behaviour from Docker.
In Gitlab CI, all services you define will be linked with your container which is running your job using Docker linking system.
As describe here, when we link containers, Docker automatically creates ENVs in format:
<_alias>_NAME
<_alias>_PORT
and some other ENVS
And those ENVs from Docker will override yours.
alias here will be the hostname of your container you defined in services. For example you define these services in your .gitlab-ci.yml:
services:
- redis:5-alpine
- name: mongo
alias: db
So Docker will create the following ENVs respectively:
REDIS_PORT="some thing looks like: tcp://172.17.0.3:6379"
REDIS_NAME="looks like: /runner-72989761-project-19846207-concurrent-0-62507216079cf651-build-3/redis"
DB_PORT=same like redis
DB_NAME=same like redis
And note that, as described here, by default the following ENVs are also auto created based on service image's name:
MONGO_PORT=...
MONGO_NAME=...
So in your code if you have any variable that has same name with the ones Docker creates, you may need to change your variable's name otherwise it'll be override by Docker. Or you can use the solution from #MmynameStackflow above, pass variables in your Gitlab CI config file to override what Docker does.
I am developing a web application using the Laravel framework. I need to generate the web page into pdf/ image in my application. I am using PHP browser shot spatie package for it, https://github.com/spatie/browsershot. I created a test function to generate the image using it with the following code.
\Spatie\Browsershot\Browsershot::url("https://www.google.com/")->save(public_path() . '/example.png');
When I run the function, I got the following error.
The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"https:\/\/www.google.com\/","action":"screenshot","options":{"type":"png","path":"\/var\/www\/public\/example.png","args":[],"viewport":{"width":800,"height":600}}}'" failed. Exit Code: 127(Command not found) Working directory: /var/www/public Output: ================ Error Output: ================ sh: 1: npm: not found sh: 1: node: not found
I am using Docker and Docker Compose for my project. What is wrong with my code?
You need to tell BrowserShot to point to the installation binary of node and npm.
Modify your code this way
\Spatie\Browsershot\Browsershot::url("https://www.google.com/")
->setNodeBinary('/usr/bin/node')
->setNpmBinary('/usr/bin/npm')
->save(public_path() . '/example.png');
Make sure to modify '/usr/bin/node' and '/usr/bin/npm' accordingly.
I'm trying to build RESTful API with Laravel using PhpStorm and artisan server, but when I try to test with Rest Client I receive this error:
For now I write only the GET method and I receive correct output in my browser with the address http://localhost:8000/users
This is my code:
routes.php
Route::resource('users','UserController');
UserController.php
public function index()
{
return \Response::json(User::all());
}
I tried also to add json in request window
php artisan serve --host 127.0.0.1 should do the trick.
Looks like PHPStorm does a lookup on localhost which results in 127.0.0.1. But php artisan serve binds to your local IPv6 address ::1.
I am trying to deploy PHP app with Windows Azure Command Line tool for PHP, but unable to make .cspkg and i'm getting this error:
Runtime Exception: 0: Default document “ServiceDefinition.rd” does not exist in Service directory “ServiceDefinition.csx”!
Error: Unexpected Exit
I have following link for guidelines
http://azurephp.interoperabilitybridges.com/articles/deploying-your-first-php-application-with-the-windows-azure-command-line-tools-for-php
The documentation you are using is OLD and had several issues in past so I would suggest using the latest supported way to create PHP application in Windows Azure:
Download new PHP SDK for Windows Azure which is tested with Windows Azure SDK 1.6. You can download the new PHP SDK from the link below:
http://phpazure.codeplex.com/
Follow the documentation as described here:
http://phpazure.codeplex.com/documentation
Try to use –phpRuntime=”C:\Program Files\PHP\v5.3″ instead of –phpRuntime=”C:\Program Files\PHP”.
i had the some error look here may be you find a solution for your problem :
http://marvelley.com/2011/03/03/24-hours-of-windows/