RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
39.84k stars 10.24k forks source link

Local development based on Docker #16746

Open Wirone opened 4 years ago

Wirone commented 4 years ago

Current development workflow is described in README.md as:

git clone https://github.com/RocketChat/Rocket.Chat.git
cd Rocket.Chat
meteor npm install
meteor npm start

with Git and Meteor as prerequisites.

It does not make sense in modern app development to pollute local machine with dev dependencies (Meteor and NPM packages) and also does not ensure that app is run on the same environment.

Unfortunately docker-compose.yml does not offer local stack based on local code since rocketchat service is run from rocketchat/rocket.chat:latest.

Would be great if there was local development process based on Docker stack, with RocketChat service built from local files, so developer could easily do docker-compose up -d and start the app and work on the code (changes should automatically restart server).

Worth considering:

Wirone commented 4 years ago

@sampaiodiego @rodrigok could you look at this? Is it something you consider?

sampaiodiego commented 4 years ago

hi @Wirone we have tried to this already a few times without success..

we're definitely accepting contributions on this matter.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Wirone commented 4 years ago

@sampaiodiego if you point me where I can find requirements (Node, NPM versions, other dependencies) for running RocketChat, I could try it, but I can't promise anything πŸ™‚

mrtndwrd commented 4 years ago

This is a script I use to build a production docker container:

version=$(meteor npm version | grep 'Rocket.Chat' | egrep -o '[0-9]+.[0-9]+.[0-9]+')
ref=$(git rev-parse --short HEAD)

meteor npm install
meteor build --server-only --directory /tmp/build-pr

cd /tmp/build-pr
cp /home/maarten/projects/github/rocketchat/.docker/Dockerfile .
sudo docker build -t <docker_repo_url>:$version-$ref .

meteor npm install is the command that makes sure all the dependencies are installed. You'll need to install Meteor for it to work of course. The README mentions using meteor npm start instead of meteor build to run the dev environment.

sampaiodiego commented 4 years ago

I have successfully used this Dockerfile to have a running container able to build rocket.chat, but as you can see it clones Rocket.Chat repo to the image, changing this to reading from the host's filesystem might do the trick:


FROM node:12.16.1

VOLUME /tmp/rc-build

# ENV NODE_VERSION 12.16.1
# ENV NODE_ENV production

# OS environment
RUN set -ex \
 && apt update \
 && apt-get install -y build-essential python3.5-dev vim \
 && groupadd -g 65533 -r rocketchat \
 && useradd -u 65533 -r -g rocketchat rocketchat \
 && command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh \
 && mkdir /app \
 && chown rocketchat:rocketchat /app

# User environment
USER rocketchat

ENV HOME /app

WORKDIR /app

RUN export PATH=$HOME/.local/bin:$PATH \
 && curl -O https://bootstrap.pypa.io/get-pip.py \
 && python3.5 get-pip.py --user \
 && pip install awscli --upgrade --user

RUN set -ex \
 && git clone https://github.com/RocketChat/Rocket.Chat.git
#  && cd Rocket.Chat \
#  && meteor --version \
#  && meteor npm i 
github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Wirone commented 3 years ago

Unfortunately I don't use RocketChat anymore since I've changed company that I'm working with, but personally I think this is basic functionality for contributors, who would like to work with RocketChat, but don't want install all the requirements on their computer. Such setup would also make development consistent between all people (Node version etc.). Please consider giving it higher priority, @sampaiodiego :wink:

mrtndwrd commented 3 years ago

As somebody who contributed (once) I wholeheartedly agree wit Wirone that a docker-based setup would make life a lot easier for contributors!

Especially considering that there are pre-push git hooks that can lead to pretty serous headaches (or at least there were when I tried)

xkungfu commented 3 years ago

very sad for this unresolved issue... anyone else work on this ?or is there another solution?

Wirone commented 2 years ago

As an alternative, maybe you can use approach similar to Gitlab and provide some SDK that will ease development (installing and running everything that is needed to work with the app)? Not necessarily as complex as GDK, but covering basic environment... Maybe use asdf and provide .tool-versions so it will work exactly the same way on every developer's computer?

Just thinking out loud πŸ˜‰

TBG-FR commented 1 year ago

I used to have a setup using the official Docker-Compose and a modified Dockerfile that just needed a npm run ... to start a "dev" RocketChat, but it's been a while and I can't find it / make it again with the changes done (file structure changed, docker related files too, and you're "forced" to use yarn)

Here is what I used recently (clone https://github.com/RocketChat/Rocket.Chat and then add these two files ✌️ )

  1. Find the meteor version required with cat apps/meteor/.meteor/release

  2. Create a Dockerfile, that use the found version in FROM geoffreybooth/meteor-base:VERSION

    
    # Use an image with meteor already there, as meteor installation can be loading for a while (sometimes forever)
    FROM geoffreybooth/meteor-base:2.5.6

Update packages and install required tools

RUN apt-get update && apt-get dist-upgrade -y RUN apt-get install -y build-essential git curl python3-minimal pkg-config

Define work directory

WORKDIR /usr/src/app/apps/meteor

Install yarn globally

RUN meteor npm install --global yarn

Run RocketChat in dev mode

CMD "meteor yarn dev"


3. Create a `Docker-Compose` by copying [RocketChat/Docker.Official.Image](https://github.com/RocketChat/Docker.Official.Image/blob/master/compose.yml) and making slight modifications to use our Dockerfile

services: rocketchat:

image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest}

build:
  dockerfile: Dockerfile
  context: .
# command: >
#   bash -c
#     "for i in `seq 1 30`; do
#       node main.js &&
#       s=$$? && break || s=$$?;
#       echo \"Tried $$i times. Waiting 5 secs...\";
#       sleep 5;
#     done; (exit $$s)"
volumes:
  # Map the whole app files (to avoid a COPY/ADD in Dockerfile)
  - ./:/usr/src/app

[...]



Hope that will help some of you guys ! It's always frustrating to be blocked by dev env when you want to contribute πŸ˜