Skip to content

Commit

Permalink
build(Docker): 🐛 fix workspace bug and remove openssl static link
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason0729 committed Jan 7, 2024
1 parent fc5636b commit a49f469
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 53 deletions.
26 changes: 0 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ opentelemetry-otlp = { version = "0.14.0", features = ["metrics"] }

[dependencies.reqwest]
version = "0.11.22"
default-features = false
features = ["rustls-tls", "json"]

[dependencies.k256]
Expand Down Expand Up @@ -77,7 +78,7 @@ features = ["derive"]

[dependencies.tonic]
version = "0.10.2"
features = ["transport", "channel", "codegen", "prost"]
features = ["transport", "channel", "codegen", "prost","tls"]

[dependencies.spin]
version = "0.9.8"
Expand Down
11 changes: 5 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ ARG ARCH
WORKDIR /complier

RUN apt update -y
RUN apt install musl-tools protobuf-compiler pkg-config libssl-dev -y
RUN apt install musl-tools protobuf-compiler pkg-config make -y

RUN cargo install just

RUN rustup target add ${ARCH}-unknown-linux-musl

WORKDIR /complier
COPY . .
RUN OPENSSL_STATIC=1 OPENSSL_DIR=/usr/include/openssl cargo install --target ${ARCH}-unknown-linux-musl --path backend
RUN cargo install --target ${ARCH}-unknown-linux-musl --path backend

FROM scratch
# WORKDIR are used instead of mkdir
WORKDIR /database
WORKDIR /config
WORKDIR /cert
WORKDIR /backend
COPY --from=builder /usr/local/cargo/bin/backend /backend
COPY --from=builder /usr/local/cargo/bin/backend /

CMD ["/backend/backend"]
CMD ["/backend"]
1 change: 0 additions & 1 deletion backend/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ entity-codegen:
rm entity/src/prelude.rs

release-docker:
just prepare
sudo docker build --build-arg ARCH=$(uname -m) -f ./Dockerfile -t mdoj-backend ..

run:
Expand Down
4 changes: 2 additions & 2 deletions judger/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.temp
*.log
/config.toml
/nsjail-docker
/config
/config
/Dockerfile
3 changes: 1 addition & 2 deletions judger/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
/config.toml
/judger.proto
/config
/plugins-out
/ws-Cargo.toml
/plugins-out
18 changes: 8 additions & 10 deletions judger/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG ARCH
WORKDIR /complier

RUN apt update -y
RUN apt install musl-tools protobuf-compiler -y
RUN apt install musl-tools protobuf-compiler pkg-config make -y

RUN cargo install just

Expand All @@ -15,20 +15,18 @@ COPY . .

RUN cargo install --target ${ARCH}-unknown-linux-musl --path judger

WORKDIR /environment
RUN mkdir -p .temp

FROM scratch
WORKDIR /database
WORKDIR /config
WORKDIR /.temp
WORKDIR /plugins/rootfs
WORKDIR /
COPY --from=builder /usr/local/cargo/bin/judger /
COPY nsjail-3.1 /
# don't load plugins, should be mounted manually in runtime
WORKDIR /
COPY plugins/rlua-54/rootfs /plugins
COPY plugins/rlua-54/spec.toml /plugins

COPY judger/nsjail-3.1 /

WORKDIR /plugins/rlua-54
COPY judger/plugins/rlua-54/rootfs .
COPY judger/plugins/rlua-54/spec.toml .

WORKDIR /
CMD ["/judger"]
5 changes: 1 addition & 4 deletions judger/justfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
release-docker:
MUSL_TARGET=$(uname -m)-linux-musl
cd plugins/rlua-54 && sh ./build.sh
cp ../proto/judger.proto .
cp ../Cargo.toml ws-Cargo.toml
sudo docker build --build-arg ARCH=$(uname -m) -f ./Dockerfile -t mdoj-judger ..

build-plugin:
Expand Down Expand Up @@ -30,7 +27,7 @@ clean:
sudo docker images rm nsjail-3.1-$(uname -m)-linux-musl
sudo docker images rm protobuf-3.21.1-$(uname -m)-linux-musl
sudo docker images rm libnl-3.2.25-$(uname -m)-linux-musl
sudo docker images rm musl-cross-make-$(uname -m)-linux-musl
sudo docker images rm musl-cross-make-$(uname -m)-linux-musl

test:
sudo rm -rf .temp/*
Expand Down
2 changes: 1 addition & 1 deletion judger/plugins/rlua-54/spec.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# memory in byte, time in microsecond
info = "A Lua 5.4 runtime build both real workloads and sandbox tests"
info = "A lightweight Lua 5.4 runtime build for both secure sandboxing and modj-sandbox test"
extension = "lua" # same extension means same language
name = "rlua-54" # must be same as dictionary name
uid = "1c41598f-e253-4f81-9ef5-d50bf1e4e74f" # be sure it's unique
Expand Down

0 comments on commit a49f469

Please sign in to comment.