Skip to content

Commit b4092c2

Browse files
authored
Merge pull request #310 from lmnr-ai/dev
Machine manager, upload PDF, api for queue, small fixes, dataset pagination
2 parents e017baa + 859093d commit b4092c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+11308
-5815
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Backend build
2+
3+
on:
4+
pull_request:
5+
types:
6+
- synchronize
7+
- opened
8+
- reopened
9+
paths:
10+
- 'app-server/**'
11+
12+
jobs:
13+
build-push:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Cache Docker layers
24+
uses: actions/cache@v4
25+
with:
26+
path: /tmp/.buildx-cache
27+
key: ${{ runner.os }}-buildx-app-server-pr-${{ hashFiles('Cargo.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-buildx-app-server-pr-
30+
31+
- name: Build Docker image
32+
uses: docker/build-push-action@v6
33+
with:
34+
context: ./app-server
35+
push: false
36+
platforms: linux/amd64
37+
cache-from: type=local,src=/tmp/.buildx-cache
38+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

app-server/Cargo.lock

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app-server/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ sha3 = "0.10.8"
6666
aws-sdk-s3 = "1.63.0"
6767
base64 = "0.22.1"
6868
sodiumoxide = "0.2.7"
69+
actix-ws = "0.3.0"
70+
tokio-tungstenite = "*"
71+
6972

7073
[build-dependencies]
7174
tonic-build = "0.12.3"

app-server/Dockerfile

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
1-
# Uses the bullseye-slim debian image per the rust recommendation.
2-
FROM rust:1.81-slim-bullseye AS builder
3-
4-
# Install g++ and other build essentials for compiling openssl/tls dependencies
5-
RUN apt update
6-
RUN apt install -y build-essential
1+
# Build stage with cargo chef for dependency caching
2+
FROM rust:1.81-slim-bullseye AS chef
3+
WORKDIR /app-server
74

8-
# Install other openssl / native tls dependencies
9-
RUN apt-get update
10-
RUN apt-get install -y \
5+
# Install build dependencies and cargo-chef
6+
RUN apt-get update && apt-get install -y \
7+
build-essential \
118
pkg-config \
129
libssl-dev \
1310
protobuf-compiler \
1411
libfontconfig1-dev \
15-
libfontconfig \
16-
libclang-dev
12+
libfontconfig \
13+
libclang-dev \
14+
&& rm -rf /var/lib/apt/lists/* \
15+
&& cargo install cargo-chef
16+
17+
# Prepare recipe for dependency caching
18+
FROM chef AS planner
19+
COPY . .
20+
RUN cargo chef prepare --recipe-path recipe.json
1721

18-
# Clean up some unnecessary apt artifacts
19-
RUN rm -rf /var/lib/apt/lists/*
22+
# Build dependencies - this layer is cached
23+
FROM chef AS builder
24+
COPY --from=planner /app-server/recipe.json recipe.json
25+
# Build dependencies
26+
RUN cargo chef cook --release --recipe-path recipe.json
2027

21-
WORKDIR /app-server
28+
# Build application
2229
COPY . .
30+
RUN cargo build --release --all
31+
32+
# Final runtime stage
33+
FROM debian:bullseye-slim AS runtime
34+
WORKDIR /app-server
35+
36+
# Install only runtime dependencies
37+
RUN apt-get update && apt-get install -y \
38+
libssl1.1 \
39+
libfontconfig1 \
40+
ca-certificates \
41+
&& rm -rf /var/lib/apt/lists/*
42+
43+
COPY --from=builder /app-server/target/release/app-server .
44+
# Copy data files for name generation
45+
COPY data/ /app-server/data/
2346

2447
EXPOSE 8000
25-
ARG DATABASE_URL
26-
ENV DATABASE_URL=${DATABASE_URL}
27-
ENV SQLX_OFFLINE=true
28-
RUN cargo build --release --all
48+
EXPOSE 8001
2949

30-
CMD ["./target/release/app-server"]
50+
CMD ["./app-server"]

app-server/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1717
.out_dir("./src/code_executor/")
1818
.compile_protos(&[proto_file], &["proto"])?;
1919

20+
let proto_file = "./proto/machine_manager_grpc.proto";
21+
22+
tonic_build::configure()
23+
.protoc_arg("--experimental_allow_proto3_optional") // for older systems
24+
.build_client(true)
25+
.build_server(false)
26+
.out_dir("./src/machine_manager/")
27+
.compile_protos(&[proto_file], &["proto"])?;
28+
2029
tonic_build::configure()
2130
.protoc_arg("--experimental_allow_proto3_optional") // for older systems
2231
.build_client(false)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
syntax = "proto3";
2+
package machine_manager_service_grpc;
3+
4+
message StartMachineRequest {}
5+
6+
message StartMachineResponse {
7+
string machine_id = 1;
8+
}
9+
10+
enum ComputerAction {
11+
KEY = 0;
12+
TYPE = 1;
13+
MOUSE_MOVE = 2;
14+
LEFT_CLICK = 3;
15+
LEFT_CLICK_DRAG = 4;
16+
RIGHT_CLICK = 5;
17+
MIDDLE_CLICK = 6;
18+
DOUBLE_CLICK = 7;
19+
SCREENSHOT = 8;
20+
CURSOR_POSITION = 9;
21+
}
22+
23+
message ComputerActionCoordinate {
24+
int32 x = 1;
25+
int32 y = 2;
26+
}
27+
28+
message ComputerActionRequest {
29+
string machine_id = 1;
30+
ComputerAction action = 2;
31+
optional string text = 3;
32+
optional ComputerActionCoordinate coordinates = 4;
33+
}
34+
35+
message ComputerActionResponse {
36+
optional string output = 1;
37+
optional string error = 2;
38+
optional string base64_image = 3;
39+
optional string system = 4;
40+
}
41+
42+
message TerminateMachineRequest {
43+
string machine_id = 1;
44+
}
45+
46+
message TerminateMachineResponse {
47+
bool success = 1;
48+
}
49+
50+
service MachineManagerService {
51+
rpc StartMachine(StartMachineRequest) returns (StartMachineResponse);
52+
rpc TerminateMachine(TerminateMachineRequest) returns (TerminateMachineResponse);
53+
rpc ExecuteComputerAction(ComputerActionRequest) returns (ComputerActionResponse);
54+
}

0 commit comments

Comments
 (0)