I started to learn the Docker. I am a complete beginner to Docker. Now, what I am doing is trying to deploy a Docker image of Laravel application onto the Heroku. I have installed a Laravel project. My Laravel project has only one page, a welcome page showing a message. That's it. I am just trying to test Docker. I have created a Docker image for my Laravel project and successfully run it on my laptop as follow.
I created a Dockerfile in the project root folder with the following content.
FROM php:7
RUN apt-get update -y && apt-get install -y openssl zip unzip git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo mbstring
WORKDIR /app
COPY . /app
RUN composer install
CMD php artisan serve --host=0.0.0.0 --port=8181
EXPOSE 8181
Then I built the image like this
docker build -t waiyanhein/laravel c:/xampp/htdocs/docker_laravel
Then I run it locally by running the following command.
docker run –p 8181:8181 waiyanhein/laravel
Everything was working. Then I tried to deploy the image to Heroku. I followed this link, https://devcenter.heroku.com/articles/container-registry-and-runtime. As in the link, I logged into heroku.
heroku container:login
Login succeeded. Then I create the app running this command.
heroku create dockerlaravelwai
The command was successful and this is the result.
Then I pushed it as a next step as in the link mention by running the following command.
heroku container:push web
when I run the above command, I got the following error.
» Error: Missing required flag:
» -a, --app APP app to run command against
» See more help with --help
What went wrong? How can I easily deploy the Laravel Docker's image to Heroku?
Its asking for you to specify the app name
heroku container:push web --app dockerlaravelwai
Related
I have been using Laravel Vapor for several years now using native runtimes and have never had an issue until recently when needing to use the Imageick PHP extension. Native runtimes don't support PHP extensions so I decided to try using a docker runtime on a staging server and everything went smoothly until I tried to run the migrate command in the Vapor UI. Getting the following error in Vapor-UI:
sh: /opt/bin/php: not found
Have tried unsuccessfully searching for the location of php in the staging deployment as well as adding alias for php in my dockerfile. Here is my current staging.Dockerfile:
ARG VERSION=php81
FROM laravelphp/vapor:${VERSION}
RUN apk add imagemagick imagemagick-dev php81-pecl-imagick \
&& pecl install imagick \
&& docker-php-ext-enable imagick
COPY . /var/task
Has anyone run in to this issue before? Seems too simple but I have zero experience with Docker and after reading through some documentation I could understand why it wouldn't be available, but then during deployment on vapor I would have thought there would be issues... and if its not available is there any way to access php in the Vapor UI by adding something to the Dockerfile or elsewhere?
https://laravel.com/docs/9.x/sail
I did a clean Laravel install with Sail on computer 1. It is all setup and working with all containers running (mysql, laravel, redis, etc) and Docker Desktop is showing that it is connected to Windows WSL2 and running in that environment. I never had to install PHP as this install procedure took care of the entire environment.
However, I would now like to pull this repo down on Computer 2 and run it in containers as well. So I pulled down the repo, it didn't have a devcontainers folder, only docker-compose.
I tried running docker compose up and the error is the vendor folder is empty/non existent for obvious reasons.
Now, I could install PHP with the right version and then install composer install and then try again. But that doesn't seem right to me.
Shouldn't I be able to just run this repo as a remote container in Vscode and have it running everything on its own?
How do I get the vendor/bin/sail folders installed?
I went back to computer 1 and created a devcontainer folder using remote-containers, pulled that down onto computer 2 but computer is still does not have the right vendor folder and files to complete the operations.
What am I doing wrong?
Assuming you have Docker working correctly at the second computer, you could run a temporary sail container just to install the composer dependencies in said project, as explained in the Laravel Sail documentation
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs
https://laravel.com/docs/9.x/sail#installing-composer-dependencies-for-existing-projects
After this the temporary container will not exist anymore and you can now run ./vendor/bin/sail up -d normally.
Hi i tried to install fresh Laravel project using
Laravel Sail
docker environment. First it was showing me "Docker is not running" error. Then i found out, i needed to start docker as rootless. I solved it, reading this url: [https://docs.docker.com/engine/install/linux-postinstall/].
After that, I successfully installed Laravel using Laravel Sail. Then I ran
./vendor/bin/sail up -d
I was able to view Laravel project in my browser. But when i ran any other artisan commands such as ./vendor/bin/sail artisan route:list or sail commands as sail shell, all the docker containers were forced closed automatically. It shows me this error.
Sail is not running.
You may Sail using the following commands: './sail up' or './sail up
-d'
Any suggestions? I am getting this issue on Ubuntu 20.04 LTS version.
If you are on Windows and using WSL, make sure the WSL Integration is properly set:
Settings->Ressources->WSL Integration + Toggle Linux version
I was using Laradock before installing Laravel Sail. Maybe there were some conflicts. So I backed up all my databases, then I removed all containers using this code. sudo docker rmi -f $(docker images -a -q). Then installed fresh Laravel project and it worked.
Please read my below comment as it is was a better solution for me.
very easy, maybe you don't have permission to run docker.
in Linux first use sudo -s and after user ./vendor/bin/sail up -d
Sail first checks to see if any current docker-compose processes have a status of Exit. If any of them have, then it will forcefully bring down all other services. Which is what you were are seeing whenever you type any sail sub-command. You can see the code here: https://github.com/laravel/sail/blob/87c63c2956749f66e43467d4a730b917ef7428b7/bin/sail#L44-L49
Run sail up to start the processes and then use docker-compose ps to check all services are running and none have an Exit status.
I had the same issue and when reviewing the code and checking my services I noticed the database had exited soon after I brought them up.
So far I have set up a mySQL server on Amazon lightsail and have succesfully used it while running strapi locally. How do I deploy Strapi itself on lightsail and get a link to access it through a browser?
I have read through https://strapi.io/documentation/3.0.0-beta.x/deployment/amazon-aws.html, but the guide is for AWS EC2. Do the same steps apply to lightsail?
So I ended up figuring out. Please let me know if something is wrong or can be done better:
Start an Ubuntu instance in lightsail, I picked the 2GB RAM tier because that's the min requirements for Strapi to run (they have them listed in their documents) and give it a static IP address.
Install node onto your server:
cd ~
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
...
sudo apt-get install nodejs
...
node -v && npm -v
I cloned my project from github, so a lot of node modules weren't imported due to .gitignore. Simply cd into the project direcotry and run node install to install all the missing dependencies.
run npm build to build the panel, then npm start
it should tell you to go to localhost:1337, instead go to [your server's IP address]:1337
your Strapi app should be on the screen
Yes, The strapi can be deployed to Lightsail. But there will be no advantages.
Lightsail must be configured as a Node.js server.
Deploy from github
Install PM2 Runtime
I have used git to clone pwa-studio theme, but still unable to run commands like yarn install. Tried installing node.js/npm but couldn't because I am on a dedicated server. From where do I install the pwa-studio theme without any error and how?
I hope this will help you,
You will see the pwa-studio directory in /var/www/html/mage0.
Enter into this directoy:
cd pwa-studio/
Run
yarn install
Specify the Magento backend server in .env file.
cp packages/venia-concept/.env.dist packages/venia-concept/.env
Open this .env file and find MAGENTO_BACKEND_URL.
MAGENTO_BACKEND_URL="https://magento-2-local/" # your local path
Find the deployVeniaSampleData.sh file in
/var/www/html/mage0/pwa-studio/packages/venia-concept/ directory. and copy this
file in your Magento root directory. Now it must look like
/var/www/html/mage0/deployVeniaSampleData.sh Now run:
bash deployVeniaSampleData.sh
After successful installation run:
bin/magento setup:upgrade bin/magento
indexer:reindex bin/magento
cache:flush
Now go back to pwa-studio directory /var/www/html/mage0/pwa-studio and
start Server.
yarn run build or sudo yarn run build
Run server, Use any of the following commands from the project root directory to start
the server:
yarn run watch:venia
yarn run watch:all
yarn run build && npm run
stage:venia
Now browse the application, you will the application url on terminal like:
PWADevServer ready at https://magento-venia.local.pwadev:8001
Thanks,