Running commands over ssh?
HOW DOES FORGE REALLY WORK ?
How does forge really work? How does it run apt-get commands on digital ocean servers ? It's written in PHP, or Laravel i suppose. I know it communicates through DO API, but the api only gives permission to create droplets and stuff like that. But how does it install nginx , mysql and all that on the droplet ? ANY IDEAS ARE MOST HIGHLY WELCOME !
@ohffs true. . . Please do you care to elaborate more ? For example, where does forge live ? On a server, right ? So this server SSH-es into the newly created DO droplet and runs commands? What programming language tells it to do this ? PHP ? how ? thanks for your reply . ;)
I'd guess it's mostly PHP with envoy. Not sure if it maybe uses something like ansible/puppet too.
@ohffs Makes a lot of sense . Looking into all that right now. Any more ideas would be appreciated. Thank you.
I would be curious to know to, as I have a couple projects that attempt similar tasks but I have encountered many setbacks and caveats that forge seems to have figured out in some way or another.
@katifrantz i will try to answer this and provide what i think occurs
how does it install nginx , mysql and all that on the droplet
based on having a custom vps on forge that's hosted with AWS, i notice it runs a bash script that does the configuration. check out this script https://gist.github.com/slider23/35b9e6ce9ceda7b35b8d. i believe this is how it configures the web server. this is not the exact script but very similar to it.
What programming language tells it to do this ?
it's written in bash shell
now in terms of deployment, you can customize what runs if you "deploy" an application. i have my applications connect to bitbucket repository. i have it pull source code from a specific branch. my deploy script consist of the usual
- install/update composer components
- install/update node components
- gulp --production
- migrate database changes
for the most part, i prefer to run these myself manually over ssh rather than run a customized deployment script from the forge interface.
@w1n78 thank you very much for this response. can you go deeper please ? from what i understand now, i can say forge has an api, when its called, a php method runs a bash script on the server, then broadcasts the results. Can you go deeper on how the process works ? thank you again for this insight
@katifrantz not really sure what else you're looking for. if you check out the bash script, check out the notes (the lines that start with #). it briefly describes what the code is doing.
- Upgrade The Base Packages
- Disable Password Authentication Over SSH (you need to have a key rather than use password over ssh)
- Setup Forge User (it's a good practice to create an use a different user other than root)
- Create The Server SSH Key
- Copy Github And Bitbucket Public Keys Into Known Hosts File
- generate .env file
- configures firewall with ufw
- installs required packages like mcrypt, nginx, and composer
the script i shared above may not be the exact script being ran on forge. it changes whenever there's a new feature or update.
have you ever tried homestead locally? it's fairly similar in the process. forge just gives you a GUI to use. hope that helps.
@w1n78 Thanks again. I understand what the bash script does, i have experience in setting up and managing linux servers. I was actually interested in some code that would run this script on another server . I think i have a pretty rough idea about how it works, using laravel envoy. But I just wanted to get others' opinions. So thanks for your input ;)
Please or to participate in this conversation.