-I will write the process of deploying laravel / docker on AWS for those who are stuck at the same point as the point where they are stuck.
Clone any laravel project in Git's remote repository into an EC2 instance.
root@ip:/home/ubuntu# git clone [Any repository URL]
Move to your cloned folder (where docker-compose.yml is) and launch the container.
root@ip:/home/ubuntu/awstest# docker-compose up -d
root@ip:/home/ubuntu/awstest# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------
awstest_app_1 docker-php-entrypoint php-fpm Up 9000/tcp
awstest_db_1 docker-entrypoint.sh mysqld Up 3306/tcp, 33060/tcp
awstest_web_1 /docker-entrypoint.sh ngin ... Up 0.0.0.0:10080->80/tcp
It's OK if you stand up like this.
** Where I struggled ** I got a version error of docker-compose.yml and according to the error content
root@ip-172-31-35-36:/home/ubuntu/awstest# vi docker-compose.yml
version: "3.3" ←3.8 to 3.Change to 3
And version changed. Furthermore, because the push to git was wrong, there was no docker related file and it did not start. I don't think there is anyone other than myself who makes such mistakes, but if there is the same person, please check the file.
We will set the environment so that Laravel can be used. Enter the app container.
root@ip:/home/ubuntu/awstest# docker-compose exec app bash
The .env file that sets the environment in the Laravel project is specified in .gitignore, so it will not be pushed to the Git repository. So I will create it again.
root@:/work# cp .env.example .env
After creating the .env, issue composer install, and also issue APP_KEY.
root@:/work# composer install
root@:/work# php artisan key:generate
Change permissions on files in your project.
Normally, it seems OK if you change the permissions of storage / logs and vendor.
Again, an error occurred and I struggled a little.
View won't open with file_put_contents error
root@:/work# chmod 777 storage/logs vendor
root@:/work# chmod 777 storage/framework/views
root@:/work# chmod 777 storage/framework/sessions
The TOP page has finally opened.
Access http: // [Set Elastic IP Address]: 10080 from a browser.
If it is displayed like this, it is OK.
root@:/work# php artisan migrate
root@:/work# php aritsan db:seed
If you do so far, I think that the locally created application will work.
This is the end of "Deploying laravel using docker on EC2 on AWS". Thank you very much.
** Previous article ** Deploy laravel using docker on EC2 on AWS ③
** Please point out any mistakes **
Recommended Posts