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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. App Packaging & Development
  3. How to build (custom) apps using the docker-registry

How to build (custom) apps using the docker-registry

Scheduled Pinned Locked Moved App Packaging & Development
build servicecustom appsdockerregistrytutorial
24 Posts 8 Posters 3.9k Views 10 Watching
  • 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.
  • M msbt

    Since I was documenting what I was doing to debug errors, here's a short how-to for people who want to use the docker-registry app with authentication to build their own apps. Before submitting I realized that @girish already made a post here, but that was without the registry so I'm posting it either way 😬

    Prerequisites:

    A machine that has both, docker and the cloudron cli installed and of course one or two Cloudrons for the apps to build and/or install

    Docker: https://docs.docker.com/engine/install/ubuntu/
    Cloudron CLI: https://docs.cloudron.io/custom-apps/cli/

    How to build apps and push to your Docker-Registry

    install the docker-registry app on a cloudron (if possible don't use a production server), e.g. docker.example.com (you might want to create a dedicated user to work with it). Add the URL and docker credentials to your target cloudron in Settings / Private Docker Registry

    Optional: use the Cloudron Build Service

    install the Build Service app, e.g. https://build.example.com, open the terminal or file manager of the app and enter your docker credentials in /app/data/docker.json. After those changes reboot the build service app to make sure the correct registry is in there. You can directly login to your build service (no trailing slash in the url! see https://docs.cloudron.io/apps/build-service/ for more information) via
    $ cloudron build --set-build-service (enter https://build.example.com)

    clone any repo you want to build
    $ git clone https://git.cloudron.io/cloudron/lamp-app

    cwd into the cloned git directory
    $ cd lamp-app/

    With local build

    login to the docker-registry with your credentials (as non root user you might need to use sudo when issuing docker commands)
    $ docker login docker.example.com

    build the thing (use custom lamp-app:tags if you want specific tag names)
    $ docker build -t docker.example.com/lamp-app .

    push to the registry - this does not work without logging in first
    $ docker push docker.example.com/lamp-app

    install on your target cloudron after logging in via cloudron login
    $ cloudron install --image docker.example.com/lamp-app

    With the Build Service

    If you're using the build service, you can just run
    $ cloudron build and enter your docker-repo (e.g. docker.example.com/lamp-app)
    and after logging in to your cloudron
    $ cloudron install --image docker.example.com/lamp-app

    If you updated an app, you can use cloudron update to push a new version for an existing app.

    Cheers, M

    P Offline
    P Offline
    plusone-nick
    wrote on last edited by
    #21

    @msbt 🙏🦾🙌+1

    ✌💙+1

    1 Reply Last reply
    0
    • M msbt

      Since I was documenting what I was doing to debug errors, here's a short how-to for people who want to use the docker-registry app with authentication to build their own apps. Before submitting I realized that @girish already made a post here, but that was without the registry so I'm posting it either way 😬

      Prerequisites:

      A machine that has both, docker and the cloudron cli installed and of course one or two Cloudrons for the apps to build and/or install

      Docker: https://docs.docker.com/engine/install/ubuntu/
      Cloudron CLI: https://docs.cloudron.io/custom-apps/cli/

      How to build apps and push to your Docker-Registry

      install the docker-registry app on a cloudron (if possible don't use a production server), e.g. docker.example.com (you might want to create a dedicated user to work with it). Add the URL and docker credentials to your target cloudron in Settings / Private Docker Registry

      Optional: use the Cloudron Build Service

      install the Build Service app, e.g. https://build.example.com, open the terminal or file manager of the app and enter your docker credentials in /app/data/docker.json. After those changes reboot the build service app to make sure the correct registry is in there. You can directly login to your build service (no trailing slash in the url! see https://docs.cloudron.io/apps/build-service/ for more information) via
      $ cloudron build --set-build-service (enter https://build.example.com)

      clone any repo you want to build
      $ git clone https://git.cloudron.io/cloudron/lamp-app

      cwd into the cloned git directory
      $ cd lamp-app/

      With local build

      login to the docker-registry with your credentials (as non root user you might need to use sudo when issuing docker commands)
      $ docker login docker.example.com

      build the thing (use custom lamp-app:tags if you want specific tag names)
      $ docker build -t docker.example.com/lamp-app .

      push to the registry - this does not work without logging in first
      $ docker push docker.example.com/lamp-app

      install on your target cloudron after logging in via cloudron login
      $ cloudron install --image docker.example.com/lamp-app

      With the Build Service

      If you're using the build service, you can just run
      $ cloudron build and enter your docker-repo (e.g. docker.example.com/lamp-app)
      and after logging in to your cloudron
      $ cloudron install --image docker.example.com/lamp-app

      If you updated an app, you can use cloudron update to push a new version for an existing app.

      Cheers, M

      BrutalBirdieB Offline
      BrutalBirdieB Offline
      BrutalBirdie
      Partner
      wrote on last edited by BrutalBirdie
      #22

      @msbt Nice guide!

      There is something that I miss tho.
      I like to run my cloudron apps local first so I can see if everything is working as intended.
      This only works to a certain level for example this can't work if a database addon is used.
      But everything before that step can be tested locally.

      A full local test suite would be awesome, so I the developer don't have to push every test and deploy it.

      For example this is how I do some local testing before I push my image.

      Needed software is jq for json parsing, docker, bash, sed

      Script explained with words:

      • Get the ID and version Tag from the CloudronManifest.json and use them for docker build.
      • Create local folders for /tmp /app/data and /run so I can emulate cloudrons readonly behavior.
      • Cleanup local folders so every test is fresh and clean
      • Build the docker image with Data from CloudronManifest.json
      • Run the freshly build Image in readonly mode with local test folders and an interactive bash session so I can debug / test some stuff.
      #!/bin/bash
      
      set -x
      
      ID=$(jq -r ".id" CloudronManifest.json)
      VERSION=$(jq -r ".version" CloudronManifest.json')
      
      echo "=> Create Test Data dir"
      mkdir -p ./cloudron_test/data ./cloudron_test/tmp ./cloudron_test/run
      
      echo "=> Cleanup Test Data"
      rm -rf ./cloudron_test/data/* ./cloudron_test/tmp/* ./cloudron_test/run/*
      
      echo "=> Build test image"
      docker build -t dr.cloudron.dev/$ID:$VERSION .
      
      echo "=> Run $VERSION tag of build image of $ID"
      docker run -ti --read-only \
          --volume $(pwd)/cloudron_test/data:/app/data:rw \
          --volume $(pwd)/cloudron_test/tmp:/tmp:rw \
          --volume $(pwd)/cloudron_test/run:/run:rw \
          dr.cloudron.dev/$ID:$VERSION \
          bash
      
      

      Like my work? Consider donating a drink. Cheers!

      infogulchI 1 Reply Last reply
      3
      • BrutalBirdieB BrutalBirdie

        @msbt Nice guide!

        There is something that I miss tho.
        I like to run my cloudron apps local first so I can see if everything is working as intended.
        This only works to a certain level for example this can't work if a database addon is used.
        But everything before that step can be tested locally.

        A full local test suite would be awesome, so I the developer don't have to push every test and deploy it.

        For example this is how I do some local testing before I push my image.

        Needed software is jq for json parsing, docker, bash, sed

        Script explained with words:

        • Get the ID and version Tag from the CloudronManifest.json and use them for docker build.
        • Create local folders for /tmp /app/data and /run so I can emulate cloudrons readonly behavior.
        • Cleanup local folders so every test is fresh and clean
        • Build the docker image with Data from CloudronManifest.json
        • Run the freshly build Image in readonly mode with local test folders and an interactive bash session so I can debug / test some stuff.
        #!/bin/bash
        
        set -x
        
        ID=$(jq -r ".id" CloudronManifest.json)
        VERSION=$(jq -r ".version" CloudronManifest.json')
        
        echo "=> Create Test Data dir"
        mkdir -p ./cloudron_test/data ./cloudron_test/tmp ./cloudron_test/run
        
        echo "=> Cleanup Test Data"
        rm -rf ./cloudron_test/data/* ./cloudron_test/tmp/* ./cloudron_test/run/*
        
        echo "=> Build test image"
        docker build -t dr.cloudron.dev/$ID:$VERSION .
        
        echo "=> Run $VERSION tag of build image of $ID"
        docker run -ti --read-only \
            --volume $(pwd)/cloudron_test/data:/app/data:rw \
            --volume $(pwd)/cloudron_test/tmp:/tmp:rw \
            --volume $(pwd)/cloudron_test/run:/run:rw \
            dr.cloudron.dev/$ID:$VERSION \
            bash
        
        
        infogulchI Offline
        infogulchI Offline
        infogulch
        wrote on last edited by
        #23

        @brutalbirdie btw, you can get raw strings from jq directly without having to strip quotes with the -r option:

        ID=$(jq -r ".id" CloudronManifest.json)
        VERSION=$(jq -r ".version" CloudronManifest.json)
        

        This does one better than just stripping quotes since it will also decode other escaped characters (not that that applies in this case).

        BrutalBirdieB 1 Reply Last reply
        2
        • infogulchI infogulch

          @brutalbirdie btw, you can get raw strings from jq directly without having to strip quotes with the -r option:

          ID=$(jq -r ".id" CloudronManifest.json)
          VERSION=$(jq -r ".version" CloudronManifest.json)
          

          This does one better than just stripping quotes since it will also decode other escaped characters (not that that applies in this case).

          BrutalBirdieB Offline
          BrutalBirdieB Offline
          BrutalBirdie
          Partner
          wrote on last edited by
          #24

          @infogulch RTFM myself 😄 nice catch, thanks for that.

          Like my work? Consider donating a drink. Cheers!

          1 Reply Last reply
          1
          • rxlictR rxlict referenced this topic on
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Bookmarks
          • Search