Skip to content

Commit

Permalink
docker: rust static linking
Browse files Browse the repository at this point in the history
  • Loading branch information
tbmc committed May 29, 2024
1 parent 6f9f009 commit f9651c6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "brain_fuck_interpreter"
name = "brainfuck_interpreter"
version = "0.1.0"
edition = "2021"

Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM rust:1.78 as builder
FROM rust:1.78-slim-buster as builder

WORKDIR /usr/src/brain_fuck_interpreter
WORKDIR /usr/src/brainfuck_interpreter
COPY . .

RUN cargo install --path .
RUN rustup target add x86_64-unknown-linux-musl \
&& cargo install --target=x86_64-unknown-linux-musl --path .

FROM node:22.2.0-alpine as run

Expand All @@ -19,6 +20,6 @@ COPY exec_all.sh exec_all.sh
RUN chmod +x exec_all.sh

# RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/brain_fuck_interpreter /usr/local/bin/brain_fuck_interpreter
COPY --from=builder /usr/local/cargo/bin/brainfuck_interpreter /usr/local/bin/brainfuck_interpreter

CMD ["sh", "exec_all.sh"]
10 changes: 9 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Brain Fuck Interpreter

## Intro
What is [BrainFuck](https://en.wikipedia.org/wiki/Brainfuck)?

A simple BrainFuck interpreter developed in Rust.

You can access it here:
https://brainfuck_interpreter.tbmc.ovh/


## Example
Hello world in BrainFuck:

```brainfuck
Expand Down Expand Up @@ -60,3 +61,10 @@ Case : Valeur
> va à la case 4
. imprime le caractère '\n'(nouvelle ligne) (10)
```

## Dev

Install rust exec before running server
``bash
cargo install --path .
``
2 changes: 1 addition & 1 deletion src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::runtime::Runtime;
use crate::syntax_checker::syntax_check;

pub fn interpret_script_file(filename: &str) -> Result<(), String> {
let content = fs::read_to_string(filename).expect("This should not fail! May be file does not exist!");
let content = fs::read_to_string(filename).expect("File does not exist!");
return interpret_code(content.as_str());
}

Expand Down
2 changes: 1 addition & 1 deletion websocketServer/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { runWebSocketServer } from './websocket';
runWebSocketServer();

server.listen(3001);
console.log('Listening WebSocket on port 3001');
console.log('Listening HTTP and WebSocket on port 3001');
4 changes: 1 addition & 3 deletions websocketServer/src/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import type {
import { server } from './proxy';

function getExecutable(): string {
return process.platform === 'win32'
? 'brain_fuck_interpreter.exe'
: 'brain_fuck_interpreter';
return 'brainfuck_interpreter';
}

export function runWebSocketServer() {
Expand Down

0 comments on commit f9651c6

Please sign in to comment.