Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local development based on Docker #16746

Open
Wirone opened this issue Feb 28, 2020 · 12 comments
Open

Local development based on Docker #16746

Wirone opened this issue Feb 28, 2020 · 12 comments

Comments

@Wirone
Copy link

Wirone commented Feb 28, 2020

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:

  • Traefik support out of the box with configurable host (label traefik.frontend.rule=Host:${ROCKETCHAT_HOST:-rocketchat.local})
  • Support for Docker Host Manager (env DOMAIN_NAME: "default:${ROCKETCHAT_HOST:-rocketchat.local}") (fork because this PR wasn't merged but it's much better to define developer-friendly host rather than default, convention-based hosts)
  • mounting local code as volume so node_modules would be stored outside of container and can be easily re-used and changes in code would have immediately effect in the running container
  • ignoring all non-app stuff in .dockerignore, such as CI configs
  • Makefile with helpful jobs for running app and tests locally
  • Docs for building customized production-ready Docker images
@Wirone
Copy link
Author

Wirone commented Mar 5, 2020

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

@sampaiodiego
Copy link
Member

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

we're definitely accepting contributions on this matter.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2020

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.

@github-actions github-actions bot added the stat: stale Stale issues will be automatically closed if no activity label Jul 4, 2020
@Wirone
Copy link
Author

Wirone commented Jul 4, 2020

@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 🙂

@github-actions github-actions bot removed the stat: stale Stale issues will be automatically closed if no activity label Jul 4, 2020
@mrtndwrd
Copy link
Contributor

mrtndwrd commented Jul 6, 2020

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
Copy link
Member

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
Copy link
Contributor

github-actions bot commented Oct 7, 2020

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.

@github-actions github-actions bot added the stat: stale Stale issues will be automatically closed if no activity label Oct 7, 2020
@Wirone
Copy link
Author

Wirone commented Oct 7, 2020

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 😉

@mrtndwrd
Copy link
Contributor

mrtndwrd commented Oct 7, 2020

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)

@github-actions github-actions bot removed the stat: stale Stale issues will be automatically closed if no activity label Oct 7, 2020
@xkungfu
Copy link

xkungfu commented Jan 5, 2021

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

@Wirone
Copy link
Author

Wirone commented Jun 23, 2022

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
Copy link
Contributor

TBG-FR commented Sep 30, 2022

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"
  1. Create a Docker-Compose by copying RocketChat/Docker.Official.Image 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 😅

@tassoevan tassoevan added stat: triaged Issue reviewed and properly tagged and removed Triaged labels Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants