Can't change repo in discourse docker

I want to make modification to the appearance of discourse by plugin.
Due to the plugin architecture I have to fork repos.

First I changed repo in discourse_docker at my forked discourse_docker

Then I forked discourse itself, add some change to test.
Went to my in instance, checked Dockerfile - it had link to my repo, installed all by instruction, build an app, enter that app and check
git remote show origin - it didn’t change:

Fetch URL: https://github.com/discourse/discourse.git

I’ve tried to remove images and rebuild them, same result

What am I missing here?

Maybe it doesn’t build image from image/discourse/Dockerfile and downloads from DockerHub instead?

Forced to build the docker image locally, retagged as discourse/discourse and launched.
Now git repo shows the right link, but didn’t fetch my last commit from repo, looks like it cached somewhere.
I can force to fetch all commits but it’s not a solution.
Any ideas what might be a problem?

You have to change the repo (as well as any other change you would like to make) using app.yml

If you have issues doing this, let me know and I will post the commands.

app.yml has only repo’s to plugins, isn’t it?
Now I’m sure it doesn’t build image from Dockerfile, this from terminal:

Unable to find image 'discourse/discourse:1.3.5' locally                                              │-bash: ./launcher: No such file or directory
1.3.5: Pulling from discourse/discourse
...

How to build the local image?

You need to add a command in app.yml to change the origin remote to point to your fork, otherwise the base image will still be using the official Discourse repo. You can build your own base image, too, but that’s a lot more effort to keep maintained, and will likely cause Confusion and Delay in the future. So, just add this to your app.yml:

run:
  - exec:
     cd: /var/www/discourse
     cmd:
         - sudo -u discourse git remote set-url origin https://git.example.com/discourse.git
         - sudo -u discourse git fetch origin
         - sudo -u discourse git checkout origin/master

You can also do various other forms of the above git commands, to get the code you want checked out, checked out.

6 Likes

Thanks Matt, that’s what I needed
But problem still remains. It has the right repo link, the repo itself cloned correctly but it has no affect, my view didn’t change. Maybe I should put this code like this:

hooks:
  before_code:
    - exec:
      cd: /var/www/discourse
      cmd:
        - sudo -u discourse git remote set-url origin https://github.com/sevenmaxis/discourse
        - sudo -u discourse git fetch origin
        - sudo -u discourse git checkout origin/master

So I added to before_code hook.
It fails on command git checkout origin/master with message:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && git pull failed with return #<Process::Status: pid 231 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"code", "cmd"=>["git reset --hard", "git clean -f", "git remote set-branches --add origin master", "git pull", "git fetch origin $version", "git checkout $version", "mkdir -p tmp/pids", "mkdir -p tmp/sockets", "touch tmp/.gitkeep", "mkdir -p                    /shared/log/rails", "bash -c \"touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log\"", "bash -c \"ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log $home/log\"", "bash -c \"mkdir -p           /shared/{uploads,backups}\"", "bash -c \"ln    -s           /shared/{uploads,backups} $home/public\"", "chown -R discourse:www-data /shared/log/rails /shared/uploads /shared/backups"]}
9b58f831c155421a2bcf09cbed22dd61598612e737b03968fd653a4452757650
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

I’m sure that it fails on git checkout origin/master, I’ve incrementally added remote set-url, fetch origin and checkout origin/master, it fails exactly on last command. But I can’t see any clue in the error message.

In the past, I’ve done it by editing app.yml like this:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/scossar/localized-categories
          - git clone https://github.com/scossar/dictionary-card-onebox
    - exec:
        cd: $home
        cmd:
         # changes start here
          - git remote remove origin
          - git config --remove-section branch.master
          - git config --remove-section branch.tests-passed
          - git remote add origin https://github.com/scossar/discourse-dev
          - git fetch
          - git remote set-branches --add origin anonymous-locale
          - git branch -u origin/anonymous-locale
          - git reset --hard origin/anonymous-locale

If you are only needing a plugin outlet added to Discourse you could try making a pull request to Discourse for the addition.

3 Likes

git reset --hard works, but git checkout origin/master didn’t work, that’s strange. I was wrong about before_code, it should be in after_code section

hi could u plz let me know why I’m getting following error.

Pups::ExecError: cd /var/www/discourse && git fetch failed with return #<Process::Status: pid 278 exit 128>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn’
exec failed with the params {“cd”=>"$home", “cmd”=>[“git remote remove origin”, “git config --remove-section branch.master”, “git config --remove-section branch.tests-passed”, “git remote add origin https://xxxxxxxxcom/Discourse/xxxxx-Discourse”, “git fetch”, “git remote set-branches --add origin anonymous-locale”, “git branch -u origin/anonymous-locale”, “git reset --hard origin/anonymous-locale”]}

1 Like