From f3aafb6595b033787777efe52c25b4b7216845db Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Thu, 9 Jan 2025 06:00:50 -0300 Subject: [PATCH 1/4] chore: adds Gitpod Flex support --- .devcontainer/Dockerfile | 53 ++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 18 ++++++++++ .gitpod.yml => .gitpod/.gitpod.yml | 0 .gitpod/automations.yaml | 11 +++++++ 4 files changed, 82 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json rename .gitpod.yml => .gitpod/.gitpod.yml (100%) create mode 100644 .gitpod/automations.yaml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000000..afec348e3cfab --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,53 @@ +# Use a base image with Ubuntu +FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu + +# Copy package.json to the container +COPY package.json /tmp/package.json + +# Install necessary packages +RUN apt-get update && apt-get install -y \ + apt-transport-https \ + build-essential \ + ca-certificates \ + curl \ + git \ + jq \ + libssl-dev && \ + rm -rf /var/lib/apt/lists/* + +# Extract Node.js version from package.json +RUN NODE_VERSION=$(jq -r '.engines.node' /tmp/package.json) && \ + echo "Node version from package.json: $NODE_VERSION" + +# Install Node.js and npm +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt-get install -y nodejs + +# Install Deno +RUN curl -fsSL https://deno.land/install.sh | sh && \ + echo 'export PATH="$HOME/.deno/bin:$PATH"' >> /etc/bash.bashrc + +# Install NVM and set Node version +ENV NVM_DIR=/root/.nvm +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash && \ + . $NVM_DIR/nvm.sh && \ + NODE_VERSION=$(jq -r '.engines.node' /tmp/package.json) && \ + nvm install $NODE_VERSION && \ + nvm use $NODE_VERSION && \ + nvm alias default $NODE_VERSION && \ + echo 'export NVM_DIR="$NVM_DIR"' >> /etc/bash.bashrc && \ + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /etc/bash.bashrc && \ + echo 'export PATH="$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH"' >> /etc/bash.bashrc + +# Install Yarn globally +RUN npm install -g yarn + +# Install Meteor +RUN curl https://install.meteor.com/?release=$(curl -so- https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/apps/meteor/.meteor/release | cut -d@ -f2) | sh && \ + echo 'export PATH=$PATH:/home/gitpod/.meteor' >> /etc/bash.bashrc + +# Set the working directory to ensure permissions are correct +WORKDIR /workspaces/Rocket.Chat + +# Install dependencies +RUN yarn diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000000..1b2960d1d2060 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +{ + "name": "Rocket.Chat Gitpod", + "build": { + "context": "..", + "dockerfile": "./Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + "forwardPorts": [3000], + "customizations": { + "vscode": { + "extensions": [ + "esbenp.prettier-vscode" + ] + } + } +} diff --git a/.gitpod.yml b/.gitpod/.gitpod.yml similarity index 100% rename from .gitpod.yml rename to .gitpod/.gitpod.yml diff --git a/.gitpod/automations.yaml b/.gitpod/automations.yaml new file mode 100644 index 0000000000000..22b9b6f177d33 --- /dev/null +++ b/.gitpod/automations.yaml @@ -0,0 +1,11 @@ +services: + development-server: + name: Rocket.Chat development server + description: Starts the Rocket.Chat development server + triggeredBy: + - postDevcontainerStart + - manual + commands: + start: | + nvm use $(jq -r '.engines.node' package.json) && \ + yarn dsv From cb8ed1d3803755349d17fc015027b0c13fcf4fd7 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Thu, 9 Jan 2025 22:48:52 -0300 Subject: [PATCH 2/4] chore: handle paths on Dockerfile --- .devcontainer/Dockerfile | 59 +++++++++++++--------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index afec348e3cfab..ae893dcf02aee 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,53 +1,32 @@ -# Use a base image with Ubuntu FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu -# Copy package.json to the container COPY package.json /tmp/package.json -# Install necessary packages RUN apt-get update && apt-get install -y \ apt-transport-https \ build-essential \ ca-certificates \ curl \ - git \ jq \ libssl-dev && \ rm -rf /var/lib/apt/lists/* -# Extract Node.js version from package.json -RUN NODE_VERSION=$(jq -r '.engines.node' /tmp/package.json) && \ - echo "Node version from package.json: $NODE_VERSION" - -# Install Node.js and npm -RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ - apt-get install -y nodejs - -# Install Deno -RUN curl -fsSL https://deno.land/install.sh | sh && \ - echo 'export PATH="$HOME/.deno/bin:$PATH"' >> /etc/bash.bashrc - -# Install NVM and set Node version -ENV NVM_DIR=/root/.nvm -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash && \ - . $NVM_DIR/nvm.sh && \ - NODE_VERSION=$(jq -r '.engines.node' /tmp/package.json) && \ - nvm install $NODE_VERSION && \ - nvm use $NODE_VERSION && \ - nvm alias default $NODE_VERSION && \ - echo 'export NVM_DIR="$NVM_DIR"' >> /etc/bash.bashrc && \ - echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /etc/bash.bashrc && \ - echo 'export PATH="$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH"' >> /etc/bash.bashrc - -# Install Yarn globally -RUN npm install -g yarn - -# Install Meteor -RUN curl https://install.meteor.com/?release=$(curl -so- https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/apps/meteor/.meteor/release | cut -d@ -f2) | sh && \ - echo 'export PATH=$PATH:/home/gitpod/.meteor' >> /etc/bash.bashrc - -# Set the working directory to ensure permissions are correct -WORKDIR /workspaces/Rocket.Chat - -# Install dependencies -RUN yarn +ENV NVM_DIR /usr/local/nvm +RUN mkdir -p $NVM_DIR && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash && \ + bash -c ". $NVM_DIR/nvm.sh && nvm install $(jq -r '.engines.node' /tmp/package.json) && npm install -g yarn" + +RUN echo "export NVM_DIR=$NVM_DIR" >> /etc/bash.bashrc && \ + echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> /etc/bash.bashrc + +ENV DENO_INSTALL=/usr/local/deno +RUN mkdir -p $DENO_INSTALL && \ + curl -fsSL https://deno.land/install.sh | sh + +ENV DENO_INSTALL="/usr/local/deno" +ENV PATH="$DENO_INSTALL/bin:$PATH" + +RUN echo 'export DENO_INSTALL="/usr/local/deno"' >> /etc/bash.bashrc && \ + echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /etc/bash.bashrc + +CMD ["bash"] From 1d24fdc9b02ba18fdfb4d09cbc5938f015510896 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Thu, 9 Jan 2025 22:49:34 -0300 Subject: [PATCH 3/4] chore: makes RC service export 3000 port --- .gitpod/automations.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitpod/automations.yaml b/.gitpod/automations.yaml index 22b9b6f177d33..be8ea9f0bc880 100644 --- a/.gitpod/automations.yaml +++ b/.gitpod/automations.yaml @@ -1,11 +1,15 @@ services: development-server: name: Rocket.Chat development server - description: Starts the Rocket.Chat development server + description: Starts the Rocket.Chat development server (yarn dsv) triggeredBy: - postDevcontainerStart - manual commands: start: | - nvm use $(jq -r '.engines.node' package.json) && \ + yarn yarn dsv + ready: | + export ROOT_URL=$(gitpod environment port open 3000 --name "Rocket.Chat application" | sed 's|https://||') + echo $ROOT_URL + gitpod environment port open 3000 --name "Rocket.Chat application" From 79db866056e1a7d35dec1f085b4e2ba3528f1011 Mon Sep 17 00:00:00 2001 From: Ricardo Garim Date: Thu, 9 Jan 2025 23:06:56 -0300 Subject: [PATCH 4/4] chore: adds Meteor on devcontainer --- .devcontainer/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ae893dcf02aee..46c3c8bdd656f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -29,4 +29,13 @@ ENV PATH="$DENO_INSTALL/bin:$PATH" RUN echo 'export DENO_INSTALL="/usr/local/deno"' >> /etc/bash.bashrc && \ echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /etc/bash.bashrc +ENV METEOR_INSTALL="/usr/local/meteor" +ENV PATH="$METEOR_INSTALL/bin:$PATH" + +RUN curl https://install.meteor.com/ | sh && \ + mv ~/.meteor $METEOR_INSTALL + +RUN echo 'export METEOR_INSTALL="/usr/local/meteor"' >> /etc/bash.bashrc && \ + echo 'export PATH="$METEOR_INSTALL/bin:$PATH"' >> /etc/bash.bashrc + CMD ["bash"]