Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Lamp App with Git

    LAMP
    lamp
    3
    5
    380
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jdelon02 last edited by girish

      Hello,

      I was wondering if git is available to the lamp app for deploying web projects? I use drupal and WP for various projects, and being able to deploy the code directly from a git hosting service and then run composer install to get any dependencies would be much more inline with the method I currently.

      Thanks,

      Jeremy

      1 Reply Last reply Reply Quote 0
      • girish
        girish Staff last edited by

        @jdelon02 Currently, you can only upload via SFTP. We are working on git support for the next release. Please see my comment at https://forum.cloudron.io/topic/1948/using-mongodb-instead-of-mysql-in-a-lamp-app

        murgero 1 Reply Last reply Reply Quote 0
        • murgero
          murgero App Dev @girish last edited by murgero

          @girish I coulda sworn I was able to git clone blahblah in LAMP, is that not possible anymore...?

          Edit: Yeah, it works for me?

          4c6623ff-73e4-49c9-8aff-52791bb9c093-image.png

          What I did in my lamp was:

          cd /app/data/public
          rm -rf ./.
          cd ..
          git clone <URL> public
          

          Will put a git repo right in the apache web root folder.

          --
          https://urgero.org
          ~ Professional Nerd. Freelance Programmer. ~
          Matrix: @murgero:urgero.org

          1 Reply Last reply Reply Quote 0
          • girish
            girish Staff last edited by

            @murgero You are right. I think what some users are looking for is a "git push" based workflow (like in heroku). So, your code is hosted on gitlab/gogs and they just want to do "git push lamp" and expect it to deploy to the lamp server. I guess the main advantage is that they don't need to open Cloudron terminal + also can integrate with CI/CD.

            murgero 1 Reply Last reply Reply Quote 0
            • murgero
              murgero App Dev @girish last edited by

              @girish & @jdelon02

              I believe LAMP app supports cron, in that case use the following script to auto-pull from a git repo whenever an update is pushed to that repo:

              Put in /app/data/updateGit

              #!/bin/sh
              
              ## CD to the path where the app is installed.
              cd /app/data/public
              UPSTREAM=${1:-'@{u}'}
              LOCAL=$(git rev-parse @)
              REMOTE=$(git rev-parse "$UPSTREAM")
              BASE=$(git merge-base @ "$UPSTREAM")
              
              if [ $LOCAL = $REMOTE ]; then
                  echo "Up-to-date"
              elif [ $LOCAL = $BASE ]; then
                  echo "Need to pull"
                  git pull
              elif [ $REMOTE = $BASE ]; then
                  echo "Need to push? Some files changed / commited here, this should not have happened."
              else
                  echo "Diverged?? Help!"
              fi
              

              Then in /app/data/crontab:

              */5 * * * * bash /app/data/updateGit 2>&1
              
              ## Or if you wanna avoid filling logs:
              */5 * * * * bash /app/data/updateGit  2>&1 > /dev/null
              

              This will check if a pull is needed from a repo every 5 minutes. (Re: https://crontab.guru/every-5-minutes)

              You can also modify the bash script to rebuild, npm install, composer install, etc when needed too.

              --
              https://urgero.org
              ~ Professional Nerd. Freelance Programmer. ~
              Matrix: @murgero:urgero.org

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              Powered by NodeBB