# Can't change repo in discourse docker

**URL:** https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376
**Category:** Development
**Created:** [Agosto 29, 2016, 12:16pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376 "2016-08-29T12:16:39Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sevenmaxis](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sevenmaxis](https://meta.discourse.org/u/sevenmaxis)
#### Post date: [Agosto 29, 2016, 12:16pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/1 "2016-08-29T12:16:40Z")

</div>

I want to make modification to the appearance of [discourse](https://github.com/discourse/discourse/) by plugin.  
Due to the plugin architecture I have to fork repos.

First I changed repo in [discourse\_docker](https://github.com/sevenmaxis/discourse_docker/commit/793b33b36fb627b42946c79f2ecb89a4f64e5900) at my forked [discourse\_docker](https://github.com/sevenmaxis/discourse_docker)

Then I forked [discourse](https://github.com/sevenmaxis/discourse) itself, add some [change](https://github.com/sevenmaxis/discourse/commit/46c7f6ece856c12a67dd06747731d9b3f1c56ca1) to test.  
Went to my in [instance](http://37.48.87.4/), 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?

---

<div class="post-metadata">

### Author: ![sevenmaxis](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sevenmaxis](https://meta.discourse.org/u/sevenmaxis)
#### Post date: [Agosto 29, 2016, 2:00pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/2 "2016-08-29T14:00:47Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![P16](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@P16](https://meta.discourse.org/u/P16)
#### Post date: [Agosto 29, 2016, 2:22pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/3 "2016-08-29T14:22:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sevenmaxis](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sevenmaxis](https://meta.discourse.org/u/sevenmaxis)
#### Post date: [Agosto 29, 2016, 3:26pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/4 "2016-08-29T15:26:00Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [Agosto 29, 2016, 9:57pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/5 "2016-08-29T21:57:43Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sevenmaxis](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sevenmaxis](https://meta.discourse.org/u/sevenmaxis)
#### Post date: [Agosto 30, 2016, 9:30am UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/6 "2016-08-30T09:30:37Z")

</div>

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

```

---

<div class="post-metadata">

### Author: ![sevenmaxis](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sevenmaxis](https://meta.discourse.org/u/sevenmaxis)
#### Post date: [Agosto 30, 2016, 2:10pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/7 "2016-08-30T14:10:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [Agosto 30, 2016, 4:22pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/8 "2016-08-30T16:22:54Z")

</div>

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

```yml
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.

---

<div class="post-metadata">

### Author: ![sevenmaxis](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sevenmaxis](https://meta.discourse.org/u/sevenmaxis)
#### Post date: [Agosto 30, 2016, 5:11pm UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/9 "2016-08-30T17:11:17Z")

</div>

`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

---

<div class="post-metadata">

### Author: ![KeaBird](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@KeaBird](https://meta.discourse.org/u/KeaBird)
#### Post date: [Fevereiro 15, 2018, 7:12am UTC](https://meta.discourse.org/t/cant-change-repo-in-discourse-docker/49376/10 "2018-02-15T07:12:01Z")

</div>

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](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”]}
