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
  • Brite
  • 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

Offical apps | Community apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Package development
  3. Localstorage & /app/data

Localstorage & /app/data

Scheduled Pinned Locked Moved Package development
20 Posts 5 Posters 8.0k Views 5 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.
  • girishG girish

    @timconsidine I assume you mean symlinks from code to some writable data path? If so, yes, Dockerfile is the correct place.

    timconsidineT
    timconsidineT
    timconsidine
    App Dev
    wrote on last edited by
    #6

    @girish Thank you.
    I seem to be stuck in a loop (although I am not 100% sure what's going on).
    I create a symlink in the Dockerfile from a code directory to a writable data location.
    In the start.sh I copy contents of code directory to the /app/data path.
    But I'm using localstorage addon and I think it destroys the symlink when it creates /app/data.
    But I can't create or recreate the symlink in start.sh (as /app/code is readonly).

    in dockerfile :

    RUN mv /app/code/data /app/code/datasrc \
        && mkdir -p /app/code/datasrc/uploads \
        && ln -s /app/data/data /app/code/data \
        && ln -s /app/data/public /app/code/public
    

    in start.sh :

    mkdir -p /app/data/public /app/data/data
    cp -r /app/code/client/* /app/data/public/
    cp -r /app/code/datasrc/* /app/data/data
    

    App fails to launch because it tries to read (or write) to :
    Error: EROFS: read-only file system, open '/app/code/public/flame.css'

    But flame.css should be symlinked to /app/data/public/flame.css.

    I'm too close to this to see the problem.
    Any thoughts ?

    Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

    1 Reply Last reply
    0
    • robiR
      robiR
      robi
      wrote on last edited by
      #7

      As was mentioned, you cannot do any /app/data operations in the Dockerfile.

      Frequency tech

      timconsidineT 1 Reply Last reply
      0
      • robiR robi

        As was mentioned, you cannot do any /app/data operations in the Dockerfile.

        timconsidineT
        timconsidineT
        timconsidine
        App Dev
        wrote on last edited by
        #8

        @robi I don't think I am (now).

        Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

        robiR 1 Reply Last reply
        0
        • timconsidineT
          timconsidineT
          timconsidine
          App Dev
          wrote on last edited by
          #9

          is /tmp writeable ?
          e.g. can I prepare the app for runtime in /tmp, copy contents in start.sh and empty /tmp (for tidiness) ?

          Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

          1 Reply Last reply
          0
          • nebulonN
            nebulonN
            nebulon
            Staff
            wrote on last edited by
            #10

            /tmp is writeable and also created in runtime, however as the name suggests, the app should not rely on content to persist there. Traditionally it may be used as temporary storage for file uploads, of other caching files.

            1 Reply Last reply
            1
            • timconsidineT timconsidine

              @robi I don't think I am (now).

              robiR
              robiR
              robi
              wrote on last edited by robi
              #11

              @timconsidine said in Localstorage & /app/data:

              @robi I don't think I am (now).

              so what is this in Dockerfile?

              && ln -s /app/data/data /app/code/data \

              && ln -s /app/data/public /app/code/public

              Frequency tech

              timconsidineT 1 Reply Last reply
              0
              • robiR robi

                @timconsidine said in Localstorage & /app/data:

                @robi I don't think I am (now).

                so what is this in Dockerfile?

                && ln -s /app/data/data /app/code/data \

                && ln -s /app/data/public /app/code/public

                timconsidineT
                timconsidineT
                timconsidine
                App Dev
                wrote on last edited by
                #12

                @robi that's from the start.sh file which runs after Dockerfile has been built to an image.

                Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

                robiR 1 Reply Last reply
                0
                • timconsidineT timconsidine

                  @robi that's from the start.sh file which runs after Dockerfile has been built to an image.

                  robiR
                  robiR
                  robi
                  wrote on last edited by
                  #13

                  @timconsidine I updated my post, since it's about the ln commands not the cp commands

                  Frequency tech

                  1 Reply Last reply
                  0
                  • girishG
                    girishG
                    girish
                    Staff
                    wrote on last edited by
                    #14

                    I would double check if the app was built and updated properly to use your latest Dockerfile. You can do cloudron debug and then you can cloudron exec to inspect if all the symlinks are proper. You can then launch your start.sh manually in that shell also.

                    1 Reply Last reply
                    1
                    • timconsidineT
                      timconsidineT
                      timconsidine
                      App Dev
                      wrote on last edited by
                      #15

                      Thank you
                      So app builds and launches, symlinks created in Dockerfile work
                      But there is weirdness in running start.sh
                      Some commands executed, some not.
                      Eg the first mkdir works but not #2 or #3
                      The first cp from tmp works but not #2 or #3
                      The chown doesn't work but the script is running to the end and working because the app launches.
                      Any ideas ?
                      Here's the start.sh :

                      #!/bin/bash
                      # set -eu
                      mkdir -p /app/data/config || true
                      mkdir -p /app/data/public || true
                      mkdir -p /app/data/images || true
                      cp -r /tmp/skeleton/* /app/data/config
                      cp -r /tmp/public/* /app/data/public 
                      cp -r /tmp/images/* /app/data/images 
                      chown -R cloudron:cloudron /app/data
                      export npm_config_cache=/app/data/.npm-cache
                      exec /usr/local/bin/gosu cloudron:cloudron npm start
                      

                      Cloudronmanifest.json has localstorage addon and proxyAuth addon.

                      Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

                      nebulonN 1 Reply Last reply
                      0
                      • timconsidineT timconsidine

                        Thank you
                        So app builds and launches, symlinks created in Dockerfile work
                        But there is weirdness in running start.sh
                        Some commands executed, some not.
                        Eg the first mkdir works but not #2 or #3
                        The first cp from tmp works but not #2 or #3
                        The chown doesn't work but the script is running to the end and working because the app launches.
                        Any ideas ?
                        Here's the start.sh :

                        #!/bin/bash
                        # set -eu
                        mkdir -p /app/data/config || true
                        mkdir -p /app/data/public || true
                        mkdir -p /app/data/images || true
                        cp -r /tmp/skeleton/* /app/data/config
                        cp -r /tmp/public/* /app/data/public 
                        cp -r /tmp/images/* /app/data/images 
                        chown -R cloudron:cloudron /app/data
                        export npm_config_cache=/app/data/.npm-cache
                        exec /usr/local/bin/gosu cloudron:cloudron npm start
                        

                        Cloudronmanifest.json has localstorage addon and proxyAuth addon.

                        nebulonN
                        nebulonN
                        nebulon
                        Staff
                        wrote on last edited by
                        #16

                        @timconsidine not sure if this the main problem, but mkdir -p ... does "no error if existing, make parent directories as needed" so should run it without the || true also if essential commands don't work in start.sh the app should not just continue anways in some unknown state.

                        timconsidineT 1 Reply Last reply
                        0
                        • nebulonN nebulon

                          @timconsidine not sure if this the main problem, but mkdir -p ... does "no error if existing, make parent directories as needed" so should run it without the || true also if essential commands don't work in start.sh the app should not just continue anways in some unknown state.

                          timconsidineT
                          timconsidineT
                          timconsidine
                          App Dev
                          wrote on last edited by
                          #17

                          @nebulon thank you
                          I stuck in the || true because chatGPT told me to do so when I asked it why the script wasn't working ! 😄

                          Yep, it's weird behaviour, some lines working but some not.
                          I can execute the failed lines manually in Terminal, but not the right way to do it !

                          Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

                          BrutalBirdieB 1 Reply Last reply
                          0
                          • timconsidineT timconsidine

                            @nebulon thank you
                            I stuck in the || true because chatGPT told me to do so when I asked it why the script wasn't working ! 😄

                            Yep, it's weird behaviour, some lines working but some not.
                            I can execute the failed lines manually in Terminal, but not the right way to do it !

                            BrutalBirdieB
                            BrutalBirdieB
                            BrutalBirdie
                            Partner
                            wrote on last edited by
                            #18

                            @timconsidine said in Localstorage & /app/data:

                            I stuck in the || true because chatGPT told me to do so when I asked it why the script wasn't working ! 😄

                            lol - That will just always make an exec return true / successful even when it fails.

                            AI will replace developers 😏 right.

                            Like my work? Consider donating a drink. Cheers!

                            timconsidineT 1 Reply Last reply
                            0
                            • BrutalBirdieB BrutalBirdie

                              @timconsidine said in Localstorage & /app/data:

                              I stuck in the || true because chatGPT told me to do so when I asked it why the script wasn't working ! 😄

                              lol - That will just always make an exec return true / successful even when it fails.

                              AI will replace developers 😏 right.

                              timconsidineT
                              timconsidineT
                              timconsidine
                              App Dev
                              wrote on last edited by timconsidine
                              #19

                              @BrutalBirdie said in Localstorage & /app/data:

                              AI will replace developers right.

                              Absolutely ... not !
                              I have seen some absolute shockers (hallucinations, wrong responses) but nevertheless I do find it useful.
                              Comes back to that old age truth : you can have the best sword/drill/hammer in the world, but it's only useful if you know how to use it.
                              AI is helpful ... except when it's not and you recognise it is not !

                              Indie app dev, scratching my itches : communityapps.appx.uk, portfolio at myca.appx.uk

                              1 Reply Last reply
                              0
                              • robiR
                                robiR
                                robi
                                wrote on last edited by
                                #20

                                If you stop calling it AI, it will begin to make sense as a tool.

                                Frequency tech

                                1 Reply Last reply
                                1

                                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                With your input, this post could be even better 💗

                                Register Login
                                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