when I run composer-self-update in Openshift I get the error below. I searched for a while but couldn't understand the solutions properly like this one - How can I composer update on OpenShift?
[Composer\Downloader\FilesystemException]
Filesystem exception:
Composer update failed: the "/var/lib/openshift/.cartridge_repository/redhat-php/0.0.28/usr/bin/composer.phar" file could not be written
The answer in the question you linked does a pretty good job of explaining it if you follow the links, but I'm happy to try and explain it further for you.
Openshift supports action hooks which are scripts that are triggered to run at the appropriate git phase that you link them to.
To use the solution they suggest, you need to:
First; create a directory called .openshift/action_hooks inside the root directory of your project (e.g mkdir .openshift/action_hooks) - by placing it in the root directory it would map like this myproject/.openshift/action_hooks
Second; you now need to create a bash script called post_deploy inside the action_hooks directory that contains the following:
#!/bin/bash
export MY_PHPCOMPOSER=$OPENSHIFT_DATA_DIR/composer.phar
# if composer not exists, download
if [ ! -f $MY_PHPCOMPOSER ]; then
cd $OPENSHIFT_DATA_DIR
echo "Downloading composer..."
php -r "readfile('https://getcomposer.org/installer');" | php
fi
$MY_PHPCOMPOSER -n -q self-update
cd $OPENSHIFT_REPO_DIR
# install
php -dmemory_limit=1G $MY_PHPCOMPOSER install
You should now have a script that maps like this in your project; myproject/.openshift/action_hooks/post_deploy
Now every time you push to your repo in openshift it will execute that script and effectively run composer install.
If you have any trouble then be sure to check out the comments on that answer for a local permissions change you may need to make.
If you get stuck along the way then please comment or ask a new question and we can help you work through it.
Related
After I am using
composer global require laravel/installer
it seems the installation is success. For the second time, the result is:
Changed current directory to /home/ryanadhi/.config/composer
Using version ^3.1 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
13 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
then if I do
echo $PATH
the result is
~/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/ryanadhi/go/bin:/home/ryanadhi/.composer/vendor/bin
However if I try
laravel
the result is always:
laravel: command not found
Editing the ~/.bashrc in Ubuntu 20.04 to reflect the path shown in the "Changed current directory to /home/ryanadhi/.config/composer" , message. fixed this for me.
first
gedit ~/.bashrc
then edit the line
export PATH="/home/ryanadhi/.config/composer/vendor/bin:$PATH"
You need to add /home/ryanadhi/.config/composer/vendor/bin to your path.
The output that said "Changed current directory to /home/ryanadhi/.config/composer" means that /home/ryanadhi/.config/composer is your Composer global directory.
If your still having issues running the laravel command you can symlnk laravel to /usr/local/bin/
Use this command:
ln -s ~/.composer/vendor/laravel/installer/bin/laravel laravel
Worked for me
I had to do two things, first I needed the "~" in front of the path in the bashrc file. My path line was:
export PATH="~/home/stephen/.config/composer/vendor/bin:$PATH"
and I had been putting "sudo" in front of "laravel new..." command which didn't work.
With those changes it installed as expected.
I have a WordPress app that has multiple plugins which are all built with OOP principles using Composer to manage autoloading in each plugin.
Now I'm wondering is it possible to just run
composer install --no-dev
in the project root, and somehow trigger running all the composer installs in the plugins so that the classmap is updated.
This is important when I want to deploy by pulling from a repository and performing the build using some kind of continuous integration.
Or do I need to manually specify in my deploy/build script to perform installation separately for each plugin?
I think that Wordpress still has no real Composer integration, which looks like a shame for everyone (including me) not involved in Wordpress development, but the project might have valid reasons, or it is no simple task (probably both).
That being said: You cannot run Composer in a directory level "one up" and mass-update the subdirectories. But it should only be a task of a simple shell script to iterate over all found directories, and if a composer.json is found inside, to update (or install) the dependencies.
My suggestion (including a random number of bugs) would be:
#!/bin/bash
for dir in {*,subdirA/*,subdirB/*}
do
if [ -d $dir ]
then
pushd $dir
if [ -f composer.json ]
then
composer install
fi
popd
fi
done
I manged to get my spring boot website online on Heroku. But I also use wkhtmltopdf to create a pdf. This works locally but now I have some problems.
Offline it works as follow :
ProcessBuilder pb = new ProcessBuilder
("cmd.exe",
"/c",
" cd C:\\Program Files\\wkhtmltopdf\\bin && wkhtmltopdf.exe "
+ "http://google.com C:\\MainWebApps\\TestApp\\src\\main\\resources\\userstorage\\Google2.pdf");
But how do I install this on Heroku?
Where do I store the temporarily html page so I can create a pdf from it ?
And where is wkhtmltopdf installed on Heroku ?
Can I call the wkhtmltopdf with a processbuilder on heroku?
EDIT
So after the comment of ceejayoz I googled a bit more and did find some interesting stuff.
So for Compile the binaries on Heroku I used this:
heroku run /bin/bash
Then I did a curl of wkhtmltopdf like this:
curl -O http://download.gna.org/wkhtmltopdf/0.12/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
Then I tried to extract it on the server but without success:
$ tar -xjvf wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
tar (child): wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
EDIT2
I also found this https://github.com/dscout/wkhtmltopdf-buildpack on github.
So I did following :
heroku buildpacks:set 'https://github.com/heroku/heroku-buildpack-multi.git'
echo 'https://github.com/dscout/wkhtmltopdf-buildpack.git' >> .buildpacks
This created a file named .buildpacks but how do I proceed from there on ?
I also found this post but vulcan is deprecated and uses ruby
Using Wkhtmltopdf with Nodejs on Heroku
Can somebody provide me with good information because I am completely stuck with this?
You actually have two problems that you need to solve -
How to install/invoke the executable
How to handle the generated .pdf
Assuming you have the basics of Heroku deployment (push to the Heroku git remote), for #1, #ceejayoz is right - check the binary into your git repository. For example, under a ./bin directory. The root of your project (where the Procfile is) will be your working directory, and you should be able to invoke the program with ProcessBuilder using relative paths.
Caveat - since it looks like you are developing on Windows, you will need to pay attention to ensuring both platform-specific binaries are available, and add some logic to know which one to invoke (for example, by setting/checking a specific environment variable).
I recommend against trying to build with a custom build pack - you will spend a lot of energy for little to no benefit. Aside from the platform issue, you don't need to rebuild a third party tool when your code changes...
The second problem is that you can't leave the generated PDF in place. It will go away when the dyno is restarted (see https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). Thus, the first thing you should do when the process completes is move the generated file to an external storage service (Amazon S3 is a good starting point).
Hope this helps.
You might want to use wkhtmltopdf-binary. With that solution, you do not need to put wkhtmltopdf executable into your VCS. You can use it for example with Maven or Gradle.
Yes, I have thoroughly searched for another answer to this question but have yet to find one.
I tried installing first by following the instructions on this page: http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
I am not sure what to do after this step. It seems that is has installed correctly, but I don't know how to run it. (I am using PuTTY.) Can I import it into my module now and being using it, or is there something else I should do?
Here are some attempts I've made:
deloacha#azdev-deloacha:~$ bin/elasticsearch.bat
-bash: bin/elasticsearch.bat: No such file or directory
deloacha#azdev-deloacha:~$ cd elasticsearch-1.5.1/bin
-bash: cd: elasticsearch-1.5.1/bin: No such file or directory
deloacha#azdev-deloacha:~$ cd elasticsearch-1.5.1
-bash: cd: elasticsearch-1.5.1: No such file or directory
deloacha#azdev-deloacha:~$ cd ..
deloacha#azdev-deloacha:/home$ cd elasticsearch-1.5.1
-bash: cd: elasticsearch-1.5.1: No such file or directory
Installing the way as provided in the document can sometimes leads to confusion. You need to find the directory containing the elasticsearch files. most probably it'll be at "/etc/elast...."
Another easy way of installation follow the steps:
make a directory where you want to install
go to that directory and download elasticsearch there using
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.5.1.tar.gz or curl
extract files: tar -zxvf elasticsearch-1.5.1.tar.gz
cd elasticsearch-1.5.1
You need to have java 7 on your system. you can start elasticsearch using "bin/elasticsearch -d" . "-d" is to run in detached mode.
Logs are by default in the location elasticsearch-1.5.1/logs. Check logs for any error during start up.
check status at: http://localhost:9200 or http://{system ip}:9200
We're looking to deploy a few Laravel4 based PHP apps on amazon with OpsWorks, this requires a few things:
Grab code from git
Download composer.phar from getcomposer.com
Run php composer.phar install
Change permissions on a few specific folders
I'm completely fresh with it comes to chef, so initially looking for a place to get to grips with the basics of chef, and then how to achieve the tasks above, would appreciate any pointers.
I'm no Chef guru (I usually use Puppet) but try the following:
Grab code from git
You may want to execute a wget command (see examples below).
If you want something more sophisticated see http://docs.opscode.com/resource_deploy.html
deploy_revision "/path/to/application" do
repo 'ssh://name-of-git-repo/repos/repo.git'
migrate false
purge_before_symlink %w{one two folder/three}
create_dirs_before_symlink []
symlinks(
"one" => "one",
"two" => "two",
"three" => "folder/three"
)
before_restart do
# some Ruby code
end
notifies :restart, "service[foo]"
notifies :restart, "service[bar]"
end
Download composer.phar from getcomposer.com
I would execute a wget.
I lifted some code from here: http://cookingclouds.com/2012/06/23/chef-simple-cookbook-example/
It's basically just doing a wget in a specific folder, extracting the contents of the tar & updating some permissions on the new files. It only does this if the folder doesn't already exist.
# Run a bash shell - download and extract composer
bash "install_composer" do
user "root"
cwd "/folder/to/extact/to"
code <<-EOH
wget http://getcomposer.com/composer.tar.gz
tar -xzf composer.tar.gz
chown -R user:group /folder/to/extact/to
EOH
not_if "test -d /folder/to/extact/to"
end
Run php composer.phar install
http://docs.opscode.com/resource_execute.html
execute "composer install" do
command "php composer.phar install && touch /var/log/.php_composer_installed"
creates "/var/log/.php_composer_installed"
action :run
end
This will only run it once, otherwise you can remove the "creates" and it will run it each time.
Change permissions on a few specific folders
http://docs.opscode.com/resource.html
directory "/tmp/folder" do
owner "root"
group "root"
mode 0755
action :create
end
If the directory already exists, nothing will happen. If the directory was changed in any way, the resource is marked as updated.
Finally
I find the search handy, browsing stuff on the Chef site seems to be hopeless (too much stuff to dig through). http://docs.opscode.com/search.html
I would go pretty much with Drew Khoury's answer, with one change. To download compose.phar, you can use the remote_file resource instead of doing a wget in a bash script.
As composer.phar is already an executable, you could simply put it to a dir in your $PATH:
remote_file '/usr/bin/composer' do
source 'http://getcomposer.org/composer.phar'
mode '0755'
action :create_if_missing
end
You can configure your git hook post-receive to something like that:
GIT_WORK_TREE=/path/to/your/site
cd /path/to/your/site
curl -sS https://getcomposer.org/installer | php
php composer.phar install
# do your stuff here
And make sure to give executable permissions to the post-receive file.
Or you can just commit your vendor directory. We have a couple projects running on Laravel 4 and OpsWorks.
I'm in the same position with Laravel and OpsWorks. I was looking for a solution but then...
What happens if someone injects a security flaw into one of the sub modules? Does that mean we trust X number of external code-bases to be 100% secure all the time?
Either there is some fundamental flaw in my understanding or running composer at all on a production server is about the most serious WTF there is.
I've now made sure that the code in my project repo will be deployed 100% as is. No downloading external modules on the production server ever.