-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* merge side project in twake working with jitsi * all plugins now work * litle correction in readme * Update README.md Co-authored-by: tissarni <tissarni> Co-authored-by: Romaric Mourgues <rmourgues@linagora.com>
- Loading branch information
1 parent
c3a3628
commit 700080d
Showing
41 changed files
with
499 additions
and
8,047 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,26 @@ | ||
# Common node machine | ||
FROM node:16-bullseye-slim as node-base | ||
# syntax=docker/dockerfile:1 | ||
|
||
### Install dependancies | ||
|
||
#Docker mac issue | ||
RUN apt-get update && apt-get install -y libc6 | ||
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 | ||
FROM docker:20.10.17-dind-alpine3.16 | ||
|
||
### Install Twake | ||
|
||
WORKDIR /usr/src/app | ||
COPY backend/node/package*.json ./ | ||
RUN apk add --update nodejs-current npm bash curl | ||
|
||
# Test Stage | ||
FROM node-base as test | ||
WORKDIR /usr/src/app | ||
|
||
RUN npm install | ||
COPY backend/node/ . | ||
COPY plugins/ . | ||
|
||
# Development Stage | ||
FROM node-base as development | ||
VOLUME /usr/src/app | ||
RUN chmod -R +x scripts | ||
RUN mv scripts/* /bin | ||
RUN apk update | ||
RUN apk add git | ||
|
||
RUN npm install -g pino-pretty | ||
RUN npm install -g tsc-watch | ||
RUN npm install | ||
COPY backend/node/ . | ||
|
||
CMD ["npm", "run", "dev"] | ||
|
||
# Production Stage | ||
FROM node-base as production | ||
|
||
ARG NODE_ENV=production | ||
|
||
ENV NODE_ENV=development | ||
RUN npm install #Install dev dependancies for build | ||
COPY backend/node/ . | ||
ENV NODE_ENV=${NODE_ENV} | ||
RUN npm run build #Build in production mode | ||
RUN rm -R node_modules | ||
RUN npm install #Install prod dependancies after build | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "run", "serve"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ lerna-debug.log* | |
# Tests | ||
/coverage | ||
/.nyc_output | ||
plugins | ||
|
||
# IDEs and editors | ||
/.idea | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
# Twake plugins server | ||
# PluginsServer - This module is WIP and not ready for production ⚠️ | ||
|
||
### Run plugin server | ||
A simple to use docker image for Twake plugins. This image use docker in docker to permit to deploy plugin easily and quickly everywhere. Docker in Docker is useful but is not ready for production environment because you need to use the root container with privileged. Furthermore, with Dockerception 127.0.0.1 is not home so this is a little schema to help understanding how this container work with Twake. | ||
![Alt text](twake/plugins/HowItWorks.png "How it works !") | ||
|
||
1. Update config (TODO) | ||
# How to use this image | ||
|
||
2. `docker-compose up -d plugins` | ||
Here is a picture representing how script works together to let you install and manage plugins easily | ||
![Alt text](twake/plugins/HowScriptsWorks.png "Scripts") | ||
|
||
### Install new plugin | ||
## Start plugin server | ||
|
||
1. `docker-compose exec plugins yarn install-plugin https://github.com/linagora/Twake-Plugins-Jitsi` | ||
docker-compose -f <docker-compose.yml> up -d plugins | ||
|
||
2. `docker-compose restart plugins` | ||
## Add a plugin | ||
|
||
By using the command below, you clone a plugins repo, add it to a list of already installed plugins, build and run it and start the nginx reverse proxy. After this the plugin will be up and running on a port specified in the plugins.json list. | ||
If you need for example to add environment variable to your plugin you can add it with a string as <environnemen-variable> like this: "-e GIPHY_APIKEY=toto -e GIPHY_SERET=tata" | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins add <plugin-git-repo> <twake-plugin-id> <twake-plugin-secret> <environnement-variable> | ||
|
||
## Start all plugins installed | ||
|
||
This script will start all plugins installed and saved in plugin.json | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins start | ||
|
||
### build already installed plugin | ||
|
||
When you already have installed a plugin, Add script will not install a plugin a second time. So you can check the configuration in plugin.json a use build script to build your image. | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins build <plugin-git-repo> | ||
|
||
### Run already installed and built plugin | ||
|
||
If your plugin is installed and the image associated is built, just run the plugin. Before running a plugin manually check if the network (docker network ls) is already created, if not restart your nginx with script start_nginx. | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins start_nginx && docker-compose -f <docker-compose.yml> exec plugins up <plugin-name> | ||
|
||
## Update a plugin | ||
|
||
To update a plugin, use the update script that will pull last version of the plugin on github. | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins update <plugin-name> | ||
|
||
## delete a plugin | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins delete <plugin-name> | ||
|
||
## list all plugin installed | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins list | ||
|
||
## Start Nginx | ||
|
||
docker-compose -f <docker-compose.yml> exec plugins start_nginx |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
var fs = require("fs"); | ||
var child_process = require("child_process"); | ||
|
||
const plugin_repository = process.argv[2]; | ||
const plugin_name = process.argv[3]; | ||
var plugin_id = ""; | ||
var plugin_secret = ""; | ||
if (process.argv[4] && process.argv[5]) { | ||
plugin_id = process.argv[4]; | ||
plugin_secret = process.argv[5]; | ||
} | ||
var venv = ""; | ||
if (process.argv[6]) venv = process.argv[6]; | ||
|
||
var port = 8001; | ||
|
||
fs.readFile("/usr/src/app/plugins.json", function (err, data) { | ||
if (err) throw err; | ||
|
||
var json = JSON.parse(data).plugins; | ||
var existing = false; | ||
|
||
json.forEach((plugin) => { | ||
if (plugin.port >= port) { | ||
port = plugin.port + 1; | ||
} | ||
if (plugin.name === plugin_name) { | ||
console.log(`${plugin_name.toUpperCase()} is already saved`); | ||
existing = true; | ||
|
||
return existing; | ||
} | ||
}); | ||
|
||
if (existing) return; | ||
|
||
let obj = { | ||
name: plugin_name, | ||
repository: plugin_repository, | ||
port: port, | ||
id: plugin_id, | ||
secret: plugin_secret, | ||
venv: venv, | ||
}; | ||
|
||
json.push(obj); | ||
|
||
child_process.exec( | ||
`git clone ${plugin_repository} /usr/src/app/plugins/${plugin_name}`, | ||
(err) => { | ||
if (err) throw err; | ||
fs.writeFile( | ||
"/usr/src/app/plugins.json", | ||
JSON.stringify({ plugins: json }), | ||
(err) => { | ||
if (err) throw err; | ||
console.log( | ||
`${plugin_name.toUpperCase()} is now cloned and saved \nWaiting for ${plugin_name.toUpperCase()} build` | ||
); | ||
} | ||
); | ||
child_process.exec(`build ${plugin_name} && up ${plugin_name}`, (err) => { | ||
if (err) throw err; | ||
console.log( | ||
`${plugin_name.toUpperCase()} built and running on port ${port}` | ||
); | ||
child_process.exec(`start_nginx`, () => { | ||
console.log( | ||
`${plugin_name.toUpperCase()} Reachable from host on http://localhost:8080/plugins/${plugin_name}` | ||
); | ||
}); | ||
}); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var fs = require("fs"); | ||
var child_process = require("child_process"); | ||
|
||
const plugin_name = process.argv[2]; | ||
|
||
fs.readFile("/usr/src/app/plugins.json", function (err, data) { | ||
if (err) throw err; | ||
|
||
var json = JSON.parse(data).plugins; | ||
|
||
json.forEach((plugin) => { | ||
if (plugin.name === plugin_name) { | ||
existing = true; | ||
child_process.exec( | ||
`cd /usr/src/app/plugins/${plugin_name} && docker build -t ${plugin_name} . && cd ../..`, | ||
(err) => { | ||
if (err) throw err; | ||
} | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var fs = require("fs"); | ||
var child_process = require("child_process"); | ||
|
||
const plugin_name = process.argv[2]; | ||
|
||
fs.readFile("/usr/src/app/plugins.json", function (err, data) { | ||
if (err) throw err; | ||
|
||
var json = JSON.parse(data).plugins; | ||
var existing = false; | ||
|
||
json.forEach((plugin) => { | ||
if (plugin.name === plugin_name) { | ||
existing = true; | ||
child_process.exec( | ||
`cd /usr/src/app/plugins/ && rm -fr ${plugin_name} && docker stop ${plugin_name} && docker system prune -f -a --volumes `, | ||
(err) => { | ||
const new_json = json.filter((plugin) => plugin.name !== plugin_name); | ||
fs.writeFile( | ||
"/usr/src/app/plugins.json", | ||
JSON.stringify({ plugins: new_json }), | ||
(err) => { | ||
if (err) throw err; | ||
child_process.exec(`start_nginx`, () => { | ||
console.log(`nginx restarted`); | ||
}); | ||
console.log(`${plugin_name.toUpperCase()} deleted`); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
}); | ||
if (!existing) { | ||
console.log(`${plugin_name.toUpperCase()} is not yet installed`); | ||
} | ||
}); |
Oops, something went wrong.