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

    Ability to pull a private repository via Git

    LAMP
    2
    3
    132
    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.
    • FoksVHox
      FoksVHox last edited by

      Hello!

      I'd like to pull a private repository once a day, however, I currently need to retype the credentials every time. When I try to use git to store the credentials, I get the following error:

      # git config --global credential.helper cache
      error: could not lock config file /root/.gitconfig: Read-only file system
      

      Would it be possible to add a way to do this?

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

        @FoksVHox On Cloudron , only the /app/data (persistent, part of app backup), /run (runtime) and /tmp (temporary, auto-cleaned up) directories are writable.

        So, you have to set the credential path to somewhere in /app/data using git config credential.helper 'store --file=/app/data/git_credentials'. Important: You have to run this command in your git checkout! This is because it saves this info inside .git/config.

        For example, my repo is helloworld. Then, I cd into it and:

        root@89cc2457-9d0a-4752-affb-c918fa4a90db:/app/data/helloworld# git config credential.helper 'store --file=/app/data/git_credentials'
        
        root@89cc2457-9d0a-4752-affb-c918fa4a90db:/app/data/helloworld# git fetch
        Username for 'https://git.cloudron.space': root
        Password for 'https://root@git.cloudron.space': 
        
        root@89cc2457-9d0a-4752-affb-c918fa4a90db:/app/data/helloworld# git fetch
        

        (the second command above ends up storing it in the file /app/data/git_credentials and the third command does not ask for password anymore).

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

          Also, to automate the pull, put this in the app's cron:

          * * * * * echo "==> Pulling" && cd /app/data/helloworld && git pull
          

          Then, in the logs, you will see:

          Mar 20 15:48:02 ==> Pulling
          Mar 20 15:48:02 From https://git.cloudron.space/root/helloworld
          Mar 20 15:48:02 8e9fa9a..6a79ead master -> origin/master
          Mar 20 15:48:02 Updating 8e9fa9a..6a79ead
          Mar 20 15:48:02 Fast-forward
          Mar 20 15:48:02 index.php | 3 ++-
          Mar 20 15:48:02 1 file changed, 2 insertions(+), 1 deletion(-)
          

          It pulls every minute for testing, so you might want to adjust the cron pattern.

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