How can I add a gemfile to the docker container?

import
docker

(Luke Mackenzie) #1

I’ve installed discourse on a Vagrant box using this guide:

(had to remove link as discourse was complaining I can only post two links even though I was only including two links, wtf ?)

I’d like to make use of https://github.com/initforthe/forum2discourse and the instructions are aimed someone who knows a bit more about ruby than I do (which is nothing)

I’m running discourse in the docker container on CoreOS (Vagrant on a local machine) and it is working as expected

I have a database ready to go in another container with the punBB data I want to import.

How can I -

Add forum2discourse gem to the discourse gemfile, and bundle install.

Run the relevant rake task within bundle exec 

Do I need to alter a config file and rebuild the discourse container?


(Luke Mackenzie) #2

Guide used was discourse/INSTALL.md at master · discourse/discourse · GitHub


(Noushi) #3

Hi Luke,

You can access the Discourse instance by running ./launcher enter app.
There you have access to the Discourse root shell.

Hope it helps.

Cheers,
Reda


(Luke Mackenzie) #4

Thanks. Is that using nsenter as described here ?

And I would add new line gem 'forum2discourse' to the discourse Gemfile?

I’m also not sure how I would then run the rake task.


(Noushi) #5

You’re welcome.

Yes, nsenter is the underlying method.

If you want permanent changes, I would suggest you change the after_code hooks in containers/app.yml.

Your changes won’t be reverted when updating Discourse.

When you’re done editing app.yml, call ./launcher rebuild app.


(Jeff Atwood) #6

Good news, @techapj is working on a PunBB converter now.


(Luke Mackenzie) #7

Great news @codinghorror ! @techAPJ please get in touch with me - happy to test this for you as I need to import a punBB forum for a real client. Please let me know when you have some code ready.


(Luke Mackenzie) #8

Thanks again @noushi. Unfortunately, I don’t have the requisite knowledge to edit that file with the correct commands. How would I execute a command to add a gem to the Gemfile?

after_code:
    - exec:
        cd: $home/??
        cmd:
          - sed -i "\$a gem \'forum2discourse\'" Gemfile
          - bundle install
          - export F2D_CONNECTION_STRING=mysql://root@127.0.0.1:3306/database_name
          - bundle exec rake forum2discourse:import_punbb

I tried running the bundle command manually after doing ./launcher enter app and editing the gemfile but get:

You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the Gemfile freeze 
by running `bundle install --no-deployment`.

You have added to the Gemfile:
* forum2discourse

Is it safe to run bundle install --no-deployment ?


(Noushi) #9

You’re welcome @codecowboy .

I took a quick look at forum2discourse’s readme, I don’t think that the after_code method is the right way, plus the export F2D won’t probably do anything (if a shell is spawned for each line).

What you should do is call launcher enter app, then:

cd /tmp
git clone https://github.com/initforthe/forum2discourse
bundle exec gem build forum2discourse.gemspec
bundle exec gem install forum2discourse-0.0.0.gem

Then

F2D_CONNECTION_STRING=mysql://root@your_punbb_mysql_server:3306/your_punbb_database_name # <-- adapt this to your specific setup

Then:

bundle exec rake forum2discourse:import_punbb

(Jeff Atwood) #10

It will be in the scripts folder with all the other converters.


(Luke Mackenzie) #11

Thanks Jeff. What branch would it be in / how would I get notified when it is ready? @techAPJ


(Arpit Jalan) #12

It’s almost ready, I will ping you here personally as soon as I push it! :smile:


(Dean Taylor) #13

(Arpit Jalan) #14

Here you go @codecowboy :gift: