-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix shell commands on alpine linux and add instructions to build…
… runner from docker container
- Loading branch information
1 parent
5b9def9
commit ff3fbef
Showing
5 changed files
with
85 additions
and
7 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 @@ | ||
target |
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,45 @@ | ||
# https://shaneutt.com/blog/rust-fast-small-docker-image-builds/ | ||
|
||
FROM rustlang/rust:nightly-slim as cargo-build | ||
|
||
RUN apt-get update | ||
|
||
RUN apt-get install musl-tools -y | ||
|
||
RUN rustup target add x86_64-unknown-linux-musl | ||
|
||
WORKDIR /usr/src/myapp | ||
|
||
COPY Cargo.toml Cargo.toml | ||
|
||
RUN mkdir src/ | ||
|
||
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs | ||
|
||
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl | ||
|
||
RUN rm -f target/x86_64-unknown-linux-musl/release/deps/myapp* | ||
|
||
COPY . . | ||
|
||
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Final Stage | ||
# ------------------------------------------------------------------------------ | ||
|
||
FROM mhart/alpine-node:latest | ||
|
||
RUN addgroup -g 1000 myapp | ||
|
||
RUN adduser -D -s /bin/sh -u 1000 -G myapp myapp | ||
|
||
WORKDIR /home/myapp/bin/ | ||
|
||
COPY --from=cargo-build /usr/src/myapp/target/x86_64-unknown-linux-musl/release/code-runner-rust . | ||
|
||
RUN chown myapp:myapp -R code-runner-rust && chmod 777 /tmp | ||
|
||
USER myapp | ||
|
||
CMD ["./code-runner-rust"] |
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,13 @@ | ||
# Build code-runner-rust | ||
|
||
docker build -t code-runner-rust . | ||
docker exec -it --rm code-runner-rust:latest sh | ||
|
||
// https://www.shellhacks.com/docker-cp-command-copy-file-to-from-container/ | ||
|
||
docker cp <container-id>:/home/myapp/bin/code-runner-rust runner-alpine | ||
docker cp f5c291c14c6b:/home/myapp/bin/code-runner-rust runner-alpine | ||
|
||
echo '{ "language":"javascript", "stdin": "1|2", "command":"ls", "files": [{"name": "main.js", "content": "const fn"},{"name": "fn.js","content": "const fn"}]}' | ./code-runner-rust | ||
|
||
echo '{ "language":"javascript", "stdin": "1|2", "command":"", "files": [{"name": "main.js", "content": "const fn"},{"name": "fn.js","content": "const fn"}]}' | ./code-runner-rust |
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,9 @@ | ||
#!/bin/bash | ||
|
||
# cargo build --target x86_64-unknown-linux-musl --release | ||
|
||
docker build -t code-runner-rust . | ||
|
||
# need to create container and extract runner from it | ||
# docker exec -it --rm code-runner-rust:latest sh | ||
# docker cp <container-id>:/home/myapp/bin/code-runner-rust runner-alpine |
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