-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1414 from MAIF/wasm
Add support for wasm plugins in a route
- Loading branch information
Showing
82 changed files
with
37,410 additions
and
84 deletions.
There are no files selected for viewing
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,2 @@ | ||
# This folder is used by the Otoroshi tutorials | ||
|
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,3 @@ | ||
ui/node_modules | ||
**/node_modules | ||
server/node_modules |
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,5 @@ | ||
.DS_Store | ||
yarn.lock | ||
server/node_modules | ||
ui/node_modules | ||
server/.env |
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,42 @@ | ||
from ubuntu:20.04 | ||
|
||
WORKDIR /code | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update -y | ||
RUN apt-get install -y build-essential git curl | ||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash | ||
RUN apt-get install -y nodejs && apt-get install -y --no-install-recommends tzdata && apt-get install -y python3.9-distutils python3.9 python3.9-dev | ||
RUN apt-get install python3.9-distutils | ||
|
||
# RUN python3.9 -m pip install --upgrade pip | ||
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3.9 get-pip.py | ||
RUN echo 'export PATH=~/.local/bin/:$PATH' >> ~/.bashrc | ||
|
||
RUN pip3 install poetry git+https://github.com/extism/cli | ||
RUN extism install latest | ||
|
||
# Get rust | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
# Add wasm-unknown-unknown target | ||
RUN rustup target add wasm32-unknown-unknown | ||
|
||
ADD ui $HOME/ui | ||
ADD server $HOME/server | ||
|
||
# install ui | ||
WORKDIR $HOME/ui | ||
RUN npm install | ||
RUN npm run build | ||
RUN rm -rf node_modules | ||
|
||
WORKDIR $HOME/server | ||
RUN npm install | ||
|
||
EXPOSE 5001 | ||
CMD ["node", "index.js"] | ||
|
||
|
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,36 @@ | ||
#!/bin/sh | ||
|
||
LOCATION=`pwd` | ||
|
||
cleanup () { | ||
rm -rf ./node_modules | ||
} | ||
|
||
build () { | ||
docker build --no-cache -t otoroshi-wasm-manager . | ||
docker tag otoroshi-wasm-manager "maif/otoroshi-wasm-manager:$1" | ||
docker tag otoroshi-wasm-manager "maif/otoroshi-wasm-manager:latest" | ||
} | ||
|
||
echo "Docker images for otoroshi-wasm-manager version $2" | ||
|
||
case "${1}" in | ||
cleanup) | ||
cleanup | ||
;; | ||
build) | ||
cleanup | ||
build $2 | ||
;; | ||
push-all) | ||
cleanup | ||
build $2 | ||
docker push "maif/otoroshi-wasm-manager:$2" | ||
docker push "maif/otoroshi-wasm-manager:latest" | ||
;; | ||
*) | ||
echo "Build otoroshi-wasm-manager docker images" | ||
;; | ||
esac | ||
|
||
exit ${?} |
Empty file.
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,62 @@ | ||
require('dotenv').config(); | ||
|
||
const express = require('express'); | ||
const http = require('http'); | ||
const compression = require('compression'); | ||
const bodyParser = require('body-parser'); | ||
const path = require('path'); | ||
const { S3 } = require('./s3'); | ||
const swaggerUi = require('swagger-ui-express'); | ||
|
||
const swaggerDocument = require('./swagger.json'); | ||
swaggerDocument.servers = (process.env.MANAGER_EXPOSED_DOMAINS || []).split(',').map(url => ({ url })) | ||
|
||
const pluginsRouter = require('./routers/plugins'); | ||
const templatesRouter = require('./routers/templates'); | ||
const publicRouter = require('./routers/public'); | ||
const wasmRouter = require('./routers/wasm'); | ||
const { WebSocket } = require('./services/websocket'); | ||
|
||
const manager = require('./logger'); | ||
const log = manager.createLogger('wasm-manager'); | ||
|
||
const { Security } = require('./security/middlewares'); | ||
const { BuildingJob } = require('./services/building-job'); | ||
|
||
S3.initializeS3Connection() | ||
.then(() => { | ||
BuildingJob.start(); | ||
|
||
S3.createBucketIfMissing(); | ||
// S3.cleanBucket() | ||
// S3.listObjects() | ||
|
||
const app = express(); | ||
app.use(express.static(path.join(__dirname, '..', 'ui/build'))); | ||
app.use(compression()); | ||
app.use(bodyParser.raw({ | ||
type: 'application/octet-stream', | ||
limit: '10mb' | ||
})); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.use(bodyParser.text()); | ||
|
||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); | ||
|
||
app.use('/', Security.extractUserFromQuery); | ||
app.use('/api/plugins', pluginsRouter); | ||
app.use('/api/templates', templatesRouter); | ||
app.use('/api/wasm', wasmRouter); | ||
|
||
app.use('/', publicRouter); | ||
app.get('/', (_, res) => res.sendFile(path.join(__dirname, '..', 'ui/build', '/index.html'))); | ||
|
||
const server = http.createServer(app); | ||
|
||
WebSocket.createLogsWebSocket(server); | ||
|
||
const PORT = process.env.MANAGER_PORT || 5001; | ||
|
||
server.listen(PORT, () => log.info(`listening on ${PORT}`)); | ||
}) |
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,4 @@ | ||
const manager = require('simple-node-logger') | ||
.createLogManager(); | ||
|
||
module.exports = manager; |
Empty file.
Oops, something went wrong.