Update Dockerfile.wasm · sheeeng/rustpython-rustpython@97c9b23 · GitHub
Skip to content

Commit 97c9b23

Browse files
committed
Update Dockerfile.wasm
1 parent 19e783d commit 97c9b23

8 files changed

Lines changed: 315 additions & 291 deletions

File tree

.dockerignore

Lines changed: 19 additions & 2 deletions

Cargo.lock

Lines changed: 193 additions & 227 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.31-slim
1+
FROM rust:1.36-slim
22

33
WORKDIR /rustpython
44

Dockerfile.wasm

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
FROM rust:1.31-slim
2-
3-
RUN apt-get update && apt-get install curl gnupg -y && \
4-
curl -o- https://deb.nodesource.com/setup_10.x | bash && \
5-
apt-get install nodejs -y && \
6-
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && \
7-
npm i -g serve
1+
FROM rust:1.36-slim AS rust
82

93
WORKDIR /rustpython
104

11-
COPY . .
5+
USER root
6+
ENV USER=root
7+
8+
9+
RUN apt-get update && apt-get install curl libssl-dev pkg-config -y && \
10+
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
11+
12+
COPY Cargo.toml Cargo.lock ./
13+
COPY src src
14+
COPY vm vm
15+
COPY derive derive
16+
COPY parser parser
17+
COPY bytecode bytecode
18+
COPY compiler compiler
19+
COPY wasm/lib wasm/lib
20+
21+
RUN cd wasm/lib/ && wasm-pack build --release
22+
23+
24+
FROM node:alpine AS node
25+
26+
WORKDIR /rustpython-demo
27+
28+
COPY --from=rust /rustpython/wasm/lib/pkg rustpython_wasm
29+
30+
COPY wasm/demo .
31+
32+
RUN npm install && npm run dist -- --env.noWasmPack --env.rustpythonPkg=rustpython_wasm
33+
34+
35+
FROM node:slim
36+
37+
WORKDIR /rustpython-demo
38+
39+
RUN npm i -g serve
40+
41+
COPY --from=node /rustpython-demo/dist .
1242

13-
RUN cd ./wasm/lib/ && \
14-
cargo build --release && \
15-
cd ../demo && \
16-
npm install && \
17-
npm run dist
43+
CMD [ "serve", "-l", "80", "/rustpython-demo" ]
1844

19-
CMD [ "serve", "/rustpython/wasm/demo/dist" ]
45+
EXPOSE 80

wasm/.prettierrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"singleQuote": true,
3-
"tabWidth": 4
2+
"singleQuote": true,
3+
"tabWidth": 4
44
}

wasm/demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"main": "index.js",
66
"dependencies": {
77
"codemirror": "^5.42.0",
8-
"serve": "^11.0.2",
98
"xterm": "^3.8.0"
109
},
1110
"devDependencies": {
@@ -18,7 +17,8 @@
1817
"webpack": "^4.16.3",
1918
"webpack-cli": "^3.1.0",
2019
"webpack-dev-server": "^3.1.5",
21-
"start-server-and-test": "^1.7.11"
20+
"start-server-and-test": "^1.7.11",
21+
"serve": "^11.0.2"
2222
},
2323
"scripts": {
2424
"dev": "webpack-dev-server -d",

wasm/demo/src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as rp from '../../lib/pkg';
1+
import * as rp from 'rustpython';
22
import CodeMirror from 'codemirror';
33
import 'codemirror/mode/python/python';
44
import 'codemirror/addon/comment/comment';

wasm/demo/webpack.config.js

Lines changed: 57 additions & 42 deletions

0 commit comments

Comments
 (0)