How to build a Rocket.Chat docker image

Can anyone help me with how to build a docker image from the official github (develop branch)?

I have been relying on the develop build published on docker hub, but as of late it has fallen into unreliability. I figured I’d just build my own from the repo.

However, I can’t seem to find the proper instructions on how to do this. I keep seeing references to a “bundle”, but I see nothing on the repo. Here is what I am currently doing:

  1. Clone the official Rocket.Chat github repo.
  2. Checkout the develop branch.
  3. Inside of the root of the repo, I issue the following command:
~/repos/Rocket.Chat# docker build -t (my own docker registry)/bkraul/rocketchat:develop -f .docker/Dockerfile .

The image appears to begin building, but I get this feedback:

Sending build context to Docker daemon  23.82MB
Step 1/10 : FROM rocketchat/base:8
 ---> 1dc2a21e1890
Step 2/10 : ADD . /app
 ---> 0d7171700ae0
Step 3/10 : MAINTAINER buildmaster@rocket.chat
 ---> Running in 1575411cf1b2
Removing intermediate container 1575411cf1b2
 ---> 3930b5bed2bf
Step 4/10 : RUN set -x  && cd /app/bundle/programs/server  && npm install  && npm cache clear --force  && chown -R rocketchat:rocketchat /app
 ---> Running in 5205b844ad01
+ cd /app/bundle/programs/server
/bin/sh: 1: cd: can't cd to /app/bundle/programs/server
The command '/bin/sh -c set -x  && cd /app/bundle/programs/server  && npm install  && npm cache clear --force  && chown -R rocketchat:rocketchat /app' returned a non-zero code: 2

Again, where do I find this “bundle”?

I’d appreciate the help!

@lucia.guevgeozian, I noticed you posted a reply to a similar question (but more geared towards customizing). Could you please help me understand the bundle situation?

either generate a build with meteor build or download a tar from our releases. Then place the extracted bundle folder next to the Dockerfile in a folder.

Then running should work as intended

Thanks, @aaron.ogle. I’m trying to understand. As you can see my goal is to build a rocketchat image in exactly the same way as the build that is being published in the docker develop tag. So I do not know how downloading a tar from the releases would get me there.

Do you have a copy of the Dockerfile/script that creates the docker develop tag, and if so could you post it here?

The exact dockerfile that generates the tag is in our repo: https://github.com/RocketChat/Rocket.Chat/blob/develop/.docker/Dockerfile

I’m guessing this is the exact same one you are trying.

We do a meteor build in our ci and then at the end of the build take the bundle folder produced and we tar it up and ship it off, as well as produce the docker image.

You can see from our circle ci that first we install meteor: https://github.com/RocketChat/Rocket.Chat/blob/develop/.circleci/config.yml#L91

Then we build Rocket.Chat: https://github.com/RocketChat/Rocket.Chat/blob/develop/.circleci/config.yml#L150
https://github.com/RocketChat/Rocket.Chat/blob/develop/.circleci/config.yml#L158 - this line being the one that does the actual build and will spit out a bundle in the folder specified.

Then you can see here where we do an image build: https://github.com/RocketChat/Rocket.Chat/blob/develop/.circleci/config.yml#L301

So… you could probably do something like:

meteor build --server-only --directory /tmp/rc-build
cp .docker/Dockerfile /tmp/rc-build
cd /tmp/rc-build
docker build -t someimage .

After of course doing the normal dev steps to install npm dependencies

I see, so it is a little bit more complicated than just building a single Dockerfile. I will read up on all of this, in the hopes of success.

Thanks for pointing me in the right direction!

Yes definitely not just a docker build -t image . :slight_smile:

At some point we had a local multi-stage dockerfile that would build full image. But since it had meteor build inside it was a bit flaky so we never published to the repo. In theory you could make one by reading through our circleci though :slight_smile:

One last question @aaron.ogle, do you use a specific circleci docker container to do your testing/building? If so, which one is it?

circle ci actually tests the bundle prior to building the docker image from that bundle.

A bit of a pro tip if curious…

I had to build a docker image for the threads PR:

If I clicked the build details:

Then grab the artifacts from that build:
image

I was able to drop it in a folder extract it, and drop the Dockerfile in the same folder and do a docker build from that specific commit :slight_smile:

i have this problem
MongoNetworkError: failed to connect to server [mongo:27017] on first connect [Error: getaddrinfo ENOTFOUND mongo

Hi,

I’m not sure that this relates here.

Can you please open a new thread and supply us with your server information and what you did to get to this error

You can use this template to give us the right information

Please do NOT open an issue on github…! It is reserved for bugs.

We can help you here.

Thanks

Hi,
Were you able to build docker image and run it on mac os.
I have been reeling under this problem for some days now.

I can build the image but cant really get to run it somehow gives sharp error.

I am having issue running Sharp in docker image

Something went wrong installing the “sharp” module

/app/bundle/programs/server/npm/node_modules/sharp/build/Release/sharp.node: invalid ELF header

Could someone please help me out with this
I have a meteor app that I build on mac using :

meteor npm install --arch=x64 --platform=linux sharp
meteor build --server-only --directory $1 --architecture os.linux.x86_64

However when I run the docker container I get above error and I am unable to start. the app.

Any help here will be hugely appreciated thanks