Setup LUYA as Headless API on DigitalOcean #2129
nadar
started this conversation in
Show and tell & Tutorials
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The tutorial below is an example of how you can setup LUYA as a Headless CMS API on DigitalOcean. Since DigitalOcean provides its App Platform its very easy to run a LUYA application with just a few clicks.
Prepare LUYA for DigitalOcean
In our example we use the LUYA HEADLESS CMS KICKSTARTER package as project base.
1.) Add
env.php
Add the
env.php
to your GIT system, as this file needs to be deployed on the server. Example content could be:the
ENV
env variable will be used later to correctly assign the production env config.2.) Production Config
Add some ENV variables for your production environment, for example the database strings and adjust the request component so it will work behind the load balancer of DigitalOcean:
3.) Extensions
Since DigitalOcean will deploy your app using heroku, the PHP extensions can be defined in your composer.json like following:
This will ensure the gd php extension is installed. See the [https://devcenter.heroku.com/articles/php-support#extensions](https://full list of heroku php extensions).
Setup DigitalOcean App
The DigitalOcean Setup requires a Database (which is pgsql / postgres) and an app Container. In my example i have connected the App trough GitLab, this ensures the app gets deployed for every commit.
1.) Create App
2.) Select the Repository
Select the repository form GitLab or GitHub you like to connect. Whenever you commit, the app will be build automatically.
3.) Define a Name and Region
4.) Configure
The most important step is to configure your app. Add the ENV variables we have previously defined in our configs and change the build and run commands:
Add a database to your app:
The database ENV variables can be access trough the db name (
db
in our case) as prefix. So the postgre db password would be available trough${db.PASSWORD}
. This YouTube Tutorial provides more informations about ENV Variables5.) Choose Plan and Launch App
6.) Run the setup commands
The deployment might run for a while, as on the first time the database needs to be created first. Here you can see the output of a successful build and run:
When the deployment was successful you can enter the console of the container and run the LUYA setup commands.
That's it. Visit your apps URL and you are ready to go.
Beta Was this translation helpful? Give feedback.
All reactions