FROM rocketchat/base:8 ENV RC_VERSION 0.65.2 MAINTAINER buildmaster@rocket.chat # Install http-proxy for port forwarding RUN npm install -g http-proxy # Original RocketChat installation RUN set -x \ && curl -SLf "https://releases.rocket.chat/${RC_VERSION}/download/" -o rocket.chat.tgz \ && curl -SLf "https://releases.rocket.chat/${RC_VERSION}/asc" -o rocket.chat.tgz.asc \ && gpg --verify rocket.chat.tgz.asc \ && mkdir -p /app \ && tar -zxf rocket.chat.tgz -C /app \ && rm rocket.chat.tgz rocket.chat.tgz.asc \ && cd /app/bundle/programs/server \ && npm install \ && npm cache clear --force \ && chown -R rocketchat:rocketchat /app # Create proxy script RUN mkdir -p /app/proxy \ && echo 'const httpProxy = require("http-proxy");' > /app/proxy/proxy.js \ && echo 'const proxy = httpProxy.createProxyServer({});' >> /app/proxy/proxy.js \ && echo 'const server = require("http").createServer(function(req, res) {' >> /app/proxy/proxy.js \ && echo ' proxy.web(req, res, { target: "http://localhost:7860" });' >> /app/proxy/proxy.js \ && echo '});' >> /app/proxy/proxy.js \ && echo 'console.log("Proxy server listening on port 3000");' >> /app/proxy/proxy.js \ && echo 'server.listen(3000);' >> /app/proxy/proxy.js USER rocketchat VOLUME /app/uploads WORKDIR /app/bundle # Modified environment variables to accommodate proxy ENV DEPLOY_METHOD=docker \ NODE_ENV=production \ MONGO_URL=mongodb://mongo:27017/rocketchat \ HOME=/tmp \ PORT=7860 \ ROOT_URL=http://localhost:3000 \ Accounts_AvatarStorePath=/app/uploads # Expose both ports EXPOSE 3000 7860 # Modified startup command to run both the proxy and RocketChat CMD ["sh", "-c", "node ../proxy/proxy.js & node main.js"]