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

    Dockerfile with 2 x FROM sources

    App Packaging & Development
    4
    7
    262
    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.
    • timconsidine
      timconsidine App Dev last edited by

      I've seen a few interesting FOSS apps which in their Dockerfiles have 2 FROM ... statements.
      e.g.

      FROM elixir:1.12-alpine as build
      ...
      ...
      FROM elixir:1.12-alpine
      ...
      ...
      

      Ignoring that these examples are not the Cloudron base images, just wondering how this might be handled in building a Cloudron package. Is it possible ?
      Probably going will turn out to be a dumb question : humour the newbie

      mehdi 1 Reply Last reply Reply Quote 0
      • mehdi
        mehdi App Dev @timconsidine last edited by

        @timconsidine This is just a Docker syntax that allow you to have a temporary container that does some stuff (usually building things), then you can access files built during previous steps in subsequent ones and add them to your image.

        Basically, it's just a way to simplify cleanup : instead of installing a bunch of tools that you only need during build time, then having to remove them (or worse, leave them in the final image), you can do the build in the temporary container, then import the build results in the final container.

        timconsidine 1 Reply Last reply Reply Quote 3
        • timconsidine
          timconsidine App Dev @mehdi last edited by timconsidine

          @mehdi thanks for the explanation šŸ‘
          Maybe I will get brave and try it out on a project

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

            This style is called multistage builds, if you want to search/read more. FWIW, they will work fine on Cloudron, we use standard docker images. That all our apps use cloudron/base:3.2.0 as the base image is only a convention that helps us maintain things more easily. (as in, if each each app package had it's own coding style and convention, it becomes hard for us to navigate the code and update them).

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

              @girish thanks, will research and play around a bit

              fbartels 1 Reply Last reply Reply Quote 0
              • fbartels
                fbartels App Dev @timconsidine last edited by

                @timconsidine Multi stage builds are super easy to use. As long as binaries are compatible, you could even pull binaries from pre existing containers.

                I’m doing the same in https://github.com/fbartels/cloudron-drone-app/blob/master/Dockerfile

                timconsidine 1 Reply Last reply Reply Quote 2
                • timconsidine
                  timconsidine App Dev @fbartels last edited by

                  @fbartels thanks, nice example šŸ‘

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