GithubHelp home page GithubHelp logo

Comments (9)

josegonzalez avatar josegonzalez commented on May 28, 2024 1

From the docs:

https://dokku.com/docs/development/plugin-triggers/?h=git+image#git-from-image

You can probably do something like:

#!/usr/bin/env bash

main() {
  declare APP="$1" DOCKER_IMAGE="$2"

  # do something with the `$DOCKER_IMAGE` specified for the `$APP`
  # maybe update your diun.yaml file and reload diun?
}

main "$@"

You could name the plugin something like dokku-git-diun and then ensure the git-from-image file in there is executable. You're not limited to shell, btw, and this can be in whatever language you want, as long as the interpreter is on disk (python is an easy one since that is a Dokku dependency, but it could just as well be a golang binary or anything else).

from dokku.

alzedd avatar alzedd commented on May 28, 2024 1

thank you again for the support.
yesterday I looked at the plugin docs and came out with this https://github.com/alzedd/dokku-diun/

it is still a WIP, but it's working fine so far.
(feel free to open a issue if is something is not done in "the dokku way" :) )

from dokku.

josegonzalez avatar josegonzalez commented on May 28, 2024

So looking at our codebase, we don't ever write a /var/lib/dokku/data/git/$APP/Dockerfile path. We use that path to hold the .git dir when calling from-image or other things, but the actual build happens in a temporary directory that we remove after the build.

Do you have an image I can use that will replicate what you are seeing? I can't seem to get that Dockerfile where you are seeing it, and the image you provided in your example seems to require some setup (something about a database scheme not being up to date).

from dokku.

alzedd avatar alzedd commented on May 28, 2024

I saw that a temp dir is created in /tmp.
If you want to try with some real image you could use silverbullet (a Markdown note taking app):

# did a docker cleanup before doing anything
docker system prune -a
dokku apps:destroy silverbullet
rm -rf /var/lib/dokku/data/git/silverbullet

## then I ran this simple commands as usual
dokku apps:create silverbullet
dokku git:from-image silverbullet zefhemel/silverbullet:0.7.3
### check what's in $DOKKU_LIB_ROOT/data/git/silverbullet folder
### then update to a new tag
dokku git:from-image silverbullet zefhemel/silverbullet:0.7.5

Strange thing is, when I tried to reproduce this problem on my pi4, after installing 0.7.3, $DOKKU_LIB_ROOT/data/git/silverbullet was empty and git status showed me that a Dockerfile was removed (staged but not committed)

dokku@raspberry:/var/lib/dokku/data/git/silverbullet $ git log
commit eb3ab8d80ded8c4c1284d780659ecd6be214e95b (HEAD -> master, origin/master, origin/HEAD)
Author: Dokku <[email protected]>
Date:   Wed Mar 13 09:13:13 2024 +0100

    Initial commit
dokku@raspberry:/var/lib/dokku/data/git/silverbullet $ git show HEAD
commit eb3ab8d80ded8c4c1284d780659ecd6be214e95b (HEAD -> master, origin/master, origin/HEAD)
Author: Dokku <[email protected]>
Date:   Wed Mar 13 09:13:13 2024 +0100

    Initial commit

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..b6c6887
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,2 @@
+FROM zefhemel/silverbullet:0.7.3
+LABEL com.dokku.docker-image-labeler/alternate-tags=[\"zefhemel/silverbullet:0.7.3\"]
dokku@raspberry:/var/lib/dokku/data/git/silverbullet $ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    Dockerfile

from dokku.

josegonzalez avatar josegonzalez commented on May 28, 2024

Okay looking further into this, that git directory should actually be treated as a temporary directory and it just so happens to be in a constant directory. The reason it shows up on the first git:from-image call is that when initializing an app from scratch, we call fn-git-clone, which happens to use a constant directory.

I don't think "fixing" the temp source you see is correct as it was never meant to be permanent. If you want to do something with a deployed image, you could create a plugin named git-diun that implements a git-from-image trigger to update a mapping of images to follow/apps to redeploy (with the corresponding post-delete hook to remove the app entry).

The only thing I think we need to add is a missing removal of the dead git data dir as we don't clean it up after deleting an app (and maybe move the dir completely to a temp dir to ensure it doesn't stick around).

from dokku.

josegonzalez avatar josegonzalez commented on May 28, 2024

Closing as there is a pull request open.

from dokku.

alzedd avatar alzedd commented on May 28, 2024

ok! so in my case the easy fix is to push a repo with the dockerfile containing only FROM company/image:version for every app I would deploy with git:from-image.

the plugin is a very good idea btw, I'm gonna test something when I'm free:)

from dokku.

josegonzalez avatar josegonzalez commented on May 28, 2024

Note: that folder path (data/git) will no longer be used as a temporary storage path for the deploying git repository, so depending on it will not work.

from dokku.

alzedd avatar alzedd commented on May 28, 2024

@josegonzalez yes!
I'm trying to write a plugin with an hook on git-from-image that writes a file per app with its relative image and version so diun can parse those...
something like that

#!/usr/bin/env bash


CONFIG_DIR="/var/lib/dokku/config/diun"



set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x

  ARGS=()
  skip=false
  for arg in "$@"; do
    if [[ "$arg" == "--build-dir" ]]; then
      skip=true
      continue
    fi

    if [[ "$skip" == "true" ]]; then
      BUILD_DIR="$arg"
      skip=false
      continue
    fi

    ARGS+=("$arg")
  done


APP="${ARGS[0]}"
DOCKER_IMAGE="${ARGS[1]}"
USER_NAME="${ARGS[2]}"
USER_EMAIL="${ARGS[3]}"

echo $DOCKER_IMAGE > "$CONFIG_DIR/$APP"

from dokku.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.