Update Dockerfile.wasm

This commit is contained in:
coolreader18
2019-07-18 10:48:13 -05:00
parent 19e783d285
commit 97c9b2316e
8 changed files with 315 additions and 291 deletions

View File

@@ -1,2 +1,19 @@
target
**/node_modules
**/target/
**/*.rs.bk
**/*.bytecode
**/__pycache__/*
**/*.pytest_cache
.*sw*
.repl_history.txt
.vscode
wasm-pack.log
.idea/
tests/snippets/resources
flame-graph.html
flame.txt
flamescope.json
**/node_modules/
wasm/**/dist/
wasm/lib/pkg/

420
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
FROM rust:1.31-slim
FROM rust:1.36-slim
WORKDIR /rustpython

View File

@@ -1,19 +1,45 @@
FROM rust:1.31-slim
RUN apt-get update && apt-get install curl gnupg -y && \
curl -o- https://deb.nodesource.com/setup_10.x | bash && \
apt-get install nodejs -y && \
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && \
npm i -g serve
FROM rust:1.36-slim AS rust
WORKDIR /rustpython
COPY . .
USER root
ENV USER=root
RUN cd ./wasm/lib/ && \
cargo build --release && \
cd ../demo && \
npm install && \
npm run dist
CMD [ "serve", "/rustpython/wasm/demo/dist" ]
RUN apt-get update && apt-get install curl libssl-dev pkg-config -y && \
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
COPY Cargo.toml Cargo.lock ./
COPY src src
COPY vm vm
COPY derive derive
COPY parser parser
COPY bytecode bytecode
COPY compiler compiler
COPY wasm/lib wasm/lib
RUN cd wasm/lib/ && wasm-pack build --release
FROM node:alpine AS node
WORKDIR /rustpython-demo
COPY --from=rust /rustpython/wasm/lib/pkg rustpython_wasm
COPY wasm/demo .
RUN npm install && npm run dist -- --env.noWasmPack --env.rustpythonPkg=rustpython_wasm
FROM node:slim
WORKDIR /rustpython-demo
RUN npm i -g serve
COPY --from=node /rustpython-demo/dist .
CMD [ "serve", "-l", "80", "/rustpython-demo" ]
EXPOSE 80

View File

@@ -1,4 +1,4 @@
{
"singleQuote": true,
"tabWidth": 4
"singleQuote": true,
"tabWidth": 4
}

View File

@@ -5,7 +5,6 @@
"main": "index.js",
"dependencies": {
"codemirror": "^5.42.0",
"serve": "^11.0.2",
"xterm": "^3.8.0"
},
"devDependencies": {
@@ -18,7 +17,8 @@
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5",
"start-server-and-test": "^1.7.11"
"start-server-and-test": "^1.7.11",
"serve": "^11.0.2"
},
"scripts": {
"dev": "webpack-dev-server -d",

View File

@@ -1,4 +1,4 @@
import * as rp from '../../lib/pkg';
import * as rp from 'rustpython';
import CodeMirror from 'codemirror';
import 'codemirror/mode/python/python';
import 'codemirror/addon/comment/comment';

View File

@@ -6,49 +6,64 @@ const fs = require('fs');
const interval = setInterval(() => console.log('keepalive'), 1000 * 60 * 5);
module.exports = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
mode: 'development',
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.ejs',
templateParameters: {
snippets: fs
.readdirSync(path.join(__dirname, 'snippets'))
.map(filename =>
path.basename(filename, path.extname(filename))
),
defaultSnippetName: 'fibonacci',
defaultSnippet: fs.readFileSync(
path.join(__dirname, 'snippets/fibonacci.py')
module.exports = (env = {}) => {
const config = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
mode: 'development',
resolve: {
alias: {
rustpython: path.resolve(
__dirname,
env.rustpythonPkg || '../lib/pkg'
)
}
}),
new MiniCssExtractPlugin({
filename: 'styles.css'
}),
new WasmPackPlugin({
crateDirectory: path.join(__dirname, '../lib')
}),
{
apply(compiler) {
compiler.hooks.done.tap('clearInterval', () => {
clearInterval(interval);
});
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.ejs',
templateParameters: {
snippets: fs
.readdirSync(path.join(__dirname, 'snippets'))
.map(filename =>
path.basename(filename, path.extname(filename))
),
defaultSnippetName: 'fibonacci',
defaultSnippet: fs.readFileSync(
path.join(__dirname, 'snippets/fibonacci.py')
)
}
}),
new MiniCssExtractPlugin({
filename: 'styles.css'
}),
{
apply(compiler) {
compiler.hooks.done.tap('clearInterval', () => {
clearInterval(interval);
});
}
}
}
]
]
};
if (!env.noWasmPack) {
config.plugins.push(
new WasmPackPlugin({
crateDirectory: path.join(__dirname, '../lib')
})
);
}
return config;
};