This time ** Docker </ font> **, ** CircleCI </ font> **, ** AWS < I learned from scratch the growing popularity of infrastructure technologies such as / font> ** and tried to create a web application. The back end is ** Laravel </ font> **, and the front end is ** Vue.js </ font> **.
In this article, the points that I had a hard time developing the application, I would like to introduce the articles and teaching materials that I referred to when implementing each function.
It is an SNS application with the theme of morning activities.
Based on this concept, we have developed a service called ** "Asa Kotsu" ** with the letters "morning activity". The URL is here ↓. If you like, feel free to move it ^^
App URL: https://pf.asakotsu.com/ (* Since smartphone support has not been completed yet, it is recommended to browse on a PC ^^;)
URL of GitHub: https://github.com/ngsw877/asakotsu
Top page (post list and ranking, etc.)
Post list by tag
Post details and comment list
Zoom meeting list
User details screen
When getting up early
Basically, it is an SNS with posts, comments, likes, and follow functions like twitter, In addition, it is an application with the following features.
HTML / CSS / Sass / MDBootstrap
__ Backend __
ZoomAPI (guzzlehttp/guzzle 7.0.1)
Docker 19.03.12 / docker-compose 1.26.2
mysql 5.7.31 / PHPMyAdmin
AWS ( EC2, ALB, ACM, S3, RDS, CodeDeploy, SNS, Chatbot, CloudFormation, Route53, VPC, EIP, IAM )
Server-side logic is programmed in PHP / Laravel, The detailed design of the front end was arranged with Sass, and when I wanted to add movement, I implemented it with Vue.js and jQuery. Use Docker / docker-compose for your development environment For the CI / CD pipeline, we did an automated test build with CircleCI and I am trying to realize automatic deployment with CodeDeploy of AWS.
I am using
Docker / docker-compose for the development environment, and I am using containers for the following four purposes.
-[How to build Laravel + Vue execution environment (LEMP environment) with Docker that never fails ~ Part 1 ~](https://qiita.com/shimotaroo/items/29f7878b01ee4b99b951#8docker-composeyml%E3%82%B3 % E3% 83% B3% E3% 83% 86% E3% 83% 8A% E3% 81% AE% E8% A8% AD% E5% AE% 9A% E3% 83% 95% E3% 82% A1% E3 % 82% A4% E3% 83% AB% E3% 82% 92% E4% BD% 9C% E6% 88% 90% E3% 81% 99% E3% 82% 8B)
-How to build Laravel 6.8 + Vue execution environment (LEMP environment) with Docker that never fails ~ Part 2 ~
-phpMyAdmin on docker is too useful
I wanted to deploy with ECS on AWS in the production environment, Abandoned due to high difficulty ... For the time being, I got used to the experience of deploying on EC2, so this time I proceeded by building an environment on EC2.
I am using
ACM (AWS Certificate Manager) because I wanted to issue an SSL certificate and make it HTTPS.
In order to use ACM, in addition to EC2,
ALB (ELB) and
CloudFront are also required, so I decided to introduce ALB this time.
Although I am using ALB, ~~ To save money ~~ Currently, I do not expect access to load distribution or scale out, so I have prepared only one EC2 instance.
In addition, even if there is a key mark in the address bar **, if you do not set the proxy on the Laravel side, the css and js files will not be read and the routing will not be https **, so be careful. ..
Reference link: -AWS: How to get an SSL certificate for free --Trusted Proxy Settings
S3 is prepared for the following two purposes.
Store the source built with CircleCI
Store the image data uploaded by the application on EC2
Regarding 2, there was something unexpected to do, such as setting the bucket policy of S3 and installing the package for S3 on the Laravel side.
-AWS (IAM: User, S3: Bucket) settings for Rails, Laravel (image upload) -Upload images to AWS S3 with Laravel
Chatbot, notifications will be sent to your Slack account at the start and end of automatic deployment. Very convenient.
__ User registration related __
New registration, profile editing function
Login and logout functions
Easy login function (guest user login)
__ Zoom API integration __
Morning activity Zoom meeting function (CRUD)
New meeting, list, edit, delete function
__ Judgment function for achieving early rising __
Target wake-up time can be set for each user (from 4:00 to 10:00)
If you can post before the target wake-up time, the early rising achievement record will increase by one day.
__ Ranking function for the number of days that users get up early (every month) __
__ Infinite scroll function __ (jQuery / inview.js / ajax)
__ User Post Related (CRUD) __
__ Comment function __
__ Tag function __ (Vue.js / Vue Tags Input)
__ Like function __ (Vue.js / ajax)
__ Follow function __ --Following / Follower list (pagination)
__ Flash message display function __ (jQuery / Toastr)
Show flash message when posting, editing, deleting, logging in, logging out
__ Image upload function __ (AWS S3 bucket)
__PHPUnit test __
|users||Registered user information|
|follows||following/Follower user information|
|achievement_days||Manage the date when the user got up early and achieved it as a history|
|meetings||User-created Zoom meeting information|
|articles||User posted information|
|tags||User post tag information|
|article_tags||Intermediate table between article and tags|
|likes||Like information for posts|
|comments||Comment information for user posts|
wake_up_time in the ** users table ** means the user's ** target wake-up time **.
If users can post earlier than this time, the early riser of the day will be achieved.
In addition, it should be noted
"The target wake-up time is 07:00, and I posted at 1:00 at midnight."
And so on, users posted too early
Even in some cases, it is set so that it will not be achieved early.
As a mechanism, the value of
range_of_success in the ** users table ** is used.
"An integer value that indicates the range of how many hours before the target wake-up time should be posted to achieve early rising."
The default is
3, for example, if the target wake-up time is set to ** 07: 00 **, 3 hours before that.
If you can post between ** 04:00 and 07: 00 **, you will get up early.
If you can achieve early rising in this way, the date of the achievement date will be recorded as a history in
date of the ** achievement_days table **.
The following functions are realized by using this date data.
** ① Calculate the number of days to get up early every month ** ** ② Ranking function using the number of days in ① **
At first, I was thinking about getting up early ** continuing ** in the ranking of the number of days, but From the viewpoint of maintaining user motivation, we decided to adopt ** monthly ** early rising ** achievement ** days.
I struggled with errors in every process from development to deployment, but w, Here are some of the most memorable points.
I was suffering from a lot of errors when setting up config.yml. .. Especially when specifying commands and paths, it is important to understand where the root of the path starts. As a countermeasure when the test failed, I tried to solve the cause by SSH logging in to the built container and checking the error log.
Reference link: Debugging with SSH
As mentioned above, [Issuing SSL Certificate](#### Issuing SSL Certificate) [Upload to S3 bucket](#### Upload to S3 bucket) I tended to get addicted to errors around me. Also, this time I decided to deploy with EC2 instead of ECS, but after SSH login to EC2 There were many files to install and configure, and the work around them was difficult. Considering this process, I wanted to be able to handle ECS more and more ^^;
At first, I had a hard time around the relations. Which table is associated with which table, and how to get the associated information? Also,
For example, I felt that the difference between the two was also an important point.
As for the PHPUnit test code, I had a hard time collecting information because I couldn't find any information that could be systematically learned.
I decided to add a function to create and edit Zoom meetings from the app, Since I had never used an external API before, I found it difficult to understand the grammatical things and the mechanism of API communication.
In implementation, it is a PHP HTTP client to communicate with Zoom API in Laravel. I have installed ** Guzzle **.
Next, register the app on the Zoom App Marketplace and read the official document, but in English, what page should I look at at the beginning? I had a hard time without knowing. .. ^^;
Laravel introduces sample code of the process to communicate with Zoom API While referring to overseas articles, I gradually became able to find the necessary information from the official documents.
However, since I was developing an application with Laravel 6 series this time, I also had a hard time because I could not use the Guzzle wrapper that can normally be used with Laravel 7 series, and I had to rewrite the code a little.
Basically, I've learned with ** Udemy ** and ** Techpit **. These two are very easy to understand. Personally, I felt that it would be better to learn the basics at Udemy and then move your hands with Techpit as an advanced version.
Docker / docker-compose
PHPUnit / CircleCI / AWS
Laravel / Vue.js
There are still many issues, but I would like to improve them one by one and brush them up.
It's been a long article, but thank you for reading this far! ^^