capifony deployment task order : site unavailable during grunt - symfony

I am using capifony to deploy my symfony 2 application.
I run two late tasks. During the time grunt is run, my website is unavailable. I've tried to play around with tasks order without success.
How should I configure the following task or what else should I do to make sure my website does not become unavailable durint the grunt process (ideally, the simlink to current would be changed after the grunt command has finished) ?
after 'deploy:restart', 'deploy:dump_dev_assets'
after 'deploy:dump_dev_assets', 'deploy:grant_permissions'
namespace :deploy do
desc "Dump dev assets"
task :dump_dev_assets do
run("cd #{deploy_to}/current && npm install")
run("cd #{deploy_to}/current && bower install --allow-root")
run("cd #{deploy_to}/current && grunt")
end
end
namespace :deploy do
desc "Grantpermissions"
task :grant_permissions do
run "sudo chmod -R 777 #{latest_release}/app/cache"
run "sudo chmod -R 777 #{latest_release}/app/logs"
run "sudo chmod -R 777 #{latest_release}/web/uploads"
run "sudo chmod -R 777 #{latest_release}/web/media"
end
end

Related

CSS not working in Laravel project deployed to Google Cloud Run

I deployed a dockerized Laravel project to Google Cloud Run. The CSS works great locally. When I go to the page that is hosted, there are no styles applied. When I inspect the page, I see that the CSS has been found and is correct, but the styles are not applied.
Here is my dockerfile
FROM php:7.4-fpm-alpine
RUN apk add --no-cache nginx wget
RUN mkdir -p /run/nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
RUN mkdir -p /app
COPY . /app
RUN sh -c "wget http://getcomposer.org/composer.phar && chmod a+x composer.phar && mv composer.phar /usr/local/bin/composer"
RUN cd /app && \
/usr/local/bin/composer install --no-dev
RUN chown -R www-data: /app
CMD sh /app/docker/startup.sh

Installing wp plugins after image builds

I'm trying to install wp plugins by executing script right after the wordpress image is built.
Here is my Dockerfile:
FROM wordpress
# Update aptitude with new repo
RUN apt-get update
# Install software
RUN apt-get install -y sudo vim curl less git python-dev python3.5
# Add WP-CLI
RUN curl -o /bin/wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
COPY wp-su.sh /bin/wp
RUN chmod +x /bin/wp-cli.phar /bin/wp && chown www-data:www-data /bin/wp-cli.phar /bin/wp
# Copy scripts into the image
COPY install.py /usr/src/wordpress
COPY plugins.json /usr/src/wordpress
COPY wait-for-it.sh /usr/src/wordpress
RUN chmod +x /usr/src/wordpress/install.py
RUN chmod +x /usr/src/wordpress/plugins.json
RUN chmod +x /usr/src/wordpress/wait-for-it.sh
COPY --chown=www-data:www-data uploads/ /usr/src/wordpress/wp-content/uploads
# Cleanup
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["/usr/src/wordpress/wait-for-it.sh", "db:3306", "--", "python" , "/usr/src/wordpress/install.py" ]
CMD ["apache2-foreground"]
Once the scripts runs I get the following error:
Error: This does not seem to be a WordPress installation.
Pass --path=`path/to/wordpress` or run `wp core download`.
I tried doing what the error suggested but it did not work. The wordpress installation from my understanding should be located at /usr/src/wordpress along with all the scripts I copied into it. Is what I'm doing correct ? Should it even be possible to do what I'm attempting ? Any help would be appreciated.
Note: This image is run from docker-compose.yml
UPDATE:
Looks to me like the reason for the above error is because the wordpress installation isn't there yet and by specifying the entrypoint I think I'm overwriting the entry point that is provided by the official wp image in which wordpress installation is copied into /var/www/html directory at runtime. Not sure how to get around this.

How do you point deployed Meteor app to a new version?

I am specifically talking about an app bundle running on my own server.
I have a Meteor app running using forever in ~/bundle and my git repo is at ~/project. I keep different release bundle tarballs in ~/release.
~/release
|-0.1.0.tar.gz
|-0.1.1.tar.gz
|-0.2.0.tar.gz
After pulling in changes from git and switching to the latest release, I want to bundle my new version and take advantage of hot-code reloading and (hopefully?) keeping client connections alive. What is the best way to do this?
Note: I am also using nginx; so will this affect the process in any way? i.e. will it kill open client connections? do I have to reload nginx after updating to newer app version?
Thanks.
You could use a script like this.
Make sure define your server in your ssh config file, e.g
Host yourserver
User youruser
Port 22
Hostname yourapp.com
IdentityFile ~/.ssh/yourkeyfile.pem
TCPKeepAlive yes
IdentitiesOnly yes
Then you could have a bash script like this:
#!/bin/bash
cd ~/Desktop/yourappdirectory
rm -f ~/Desktop/yourapp.tar.gz
meteor bundle ~/Desktop/yourapp.tar.gz
scp ~/Desktop/yourapp.tar.gz yourserver:~/yourapp.tar.gz
ssh yourserver <<'ENDSSH'
cd ~/
tar -xzf yourapp.tar.gz
sudo rm -rf yourapp
mv bundle yourapp
cd yourapp/programs/server/node_modules
rm -rf fibers
rm -rf bcrypt
sudo npm install fibers#1.0.1
sudo npm install bcrypt
cd ~/yourapp/programs/server/npm/mongo-livedata/main
rm -r mongodb
sudo npm install mongodb#1.4.1
cd ~/
sudo forever stop ~/yourapp/main.js
sudo MONGO_URL=mongodb://user:pass#ip:27017/meteor PORT=3000 ROOT_URL=https://yoursite.com forever start ~/yourapp/main.js
ENDSSH
Then just run the bash and it would upload and deploy your app for you. Just a note I couldn't put a release version in so stuff just uploads to ~/yourapp.tar.gz then unbundles into ~/yourapp
The meteor app would then be hot code reloaded on any clients if they're on the site.

Unable to install Sylius with Composer

With composer, i tried to install Sylius via sylius/sylius and sylius/sylius-standard.
Installations have both ended like this :
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
It happens just after the parameters.ini initialization.
And after, the command line doesn't work (example : "app/console list" return nothing) although I'm in the project root directory.
Any idea, please ? Thanks.
I've gotten this error ( I'm not sure if it's the same place where your getting it ) and developed a solution that seems to work. Instead of running app/console cache:clear ( which I think gets run at the end of the composer install ), I run a bash script that opens the permissions before and after.
sudo sh clearCache
Contents of clearCache:
#!/bin/bash
chmod -R 777 app/cache/ app/logs/
su www-data -c "app/console cache:clear -e dev"
chmod -R 777 app/cache/ app/logs/
su www-data -c "app/console cache:clear -e prod"
chmod -R 777 app/cache/ app/logs/
I think I got this message during a composer install and was still able to continue via cd Sylius and app/console sylius:install. Just run this before and after installing and updates.

error about dependencies again and again

I took my project to another local computer and Im getting this error after requesting app_dev.php:
You must set up the project dependencies by running the following
commands: curl -s http://getcomposer.org/installer | php php
composer.phar install.
So I run those commands but the error is the same again...
You sure you use 2.0 version? Because composer is used in symfony 2.1
Can you show logs which occur when executing php composer.phar install?
Else try to:
Remove extra php word in curl -s http://getcomposer.org/installer | php php composer.phar install
Delete cache and make cache dir writable: sudo rm -rf app/cache/* && chmod a+rwx -R app/cache/*

Resources