-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from tareknaser/backend
Implement Backend Service and Compile Button
- Loading branch information
Showing
28 changed files
with
7,497 additions
and
2,399 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,5 @@ | ||
.github | ||
node_modules | ||
packages/*/node_modules | ||
target | ||
Dockerfile |
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,52 @@ | ||
name: Docker CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Needed for cargo-make | ||
- name: Set up Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Install cargo make | ||
run: cargo install cargo-make | ||
|
||
- name: get Sysbox | ||
run: wget https://downloads.nestybox.com/sysbox/releases/v0.6.1/sysbox-ce_0.6.1-0.linux_amd64.deb | ||
|
||
- name: Install Sysbox | ||
run: sudo apt-get install ./sysbox-ce_0.6.1-0.linux_amd64.deb | ||
|
||
- name: Configure Sysbox runtime | ||
run: sudo cp sysbox/daemon.json /etc/docker/daemon.json | ||
|
||
- name: Restart docker service | ||
run: sudo systemctl restart docker.service | ||
|
||
- name: Build docker | ||
run: cargo make docker-build | ||
|
||
- name: Run docker | ||
run: cargo make docker-run | ||
|
||
- name: Allow Docker image to boot up | ||
uses: juliangruber/sleep-action@v1 | ||
with: | ||
time: 120s | ||
|
||
# Needed to run tests | ||
- name: Install npm dependencies | ||
run: cargo make deps-npm | ||
|
||
- name: Test | ||
run: cargo make test-app | ||
|
||
- name: Show logs | ||
run: cargo make docker-log |
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 |
---|---|---|
|
@@ -505,4 +505,6 @@ $RECYCLE.BIN/ | |
*.lnk | ||
|
||
|
||
package-lock.json | ||
package-lock.json | ||
|
||
packages/_generated/*/src |
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
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,55 @@ | ||
# Start from a rust base image | ||
FROM rust:1.76.0 as base | ||
|
||
# Set the current directory | ||
WORKDIR /app | ||
|
||
# Copy everthing that is not dockerignored to the image | ||
COPY . . | ||
|
||
# Start from base image | ||
FROM base as builder | ||
|
||
# Rust setup | ||
RUN rustup toolchain install stable | ||
RUN rustup toolchain install nightly-2024-02-04 | ||
RUN rustup target add wasm32-unknown-unknown | ||
RUN cargo install cargo-make | ||
|
||
# Install Node | ||
RUN apt-get --yes update | ||
RUN apt-get --yes upgrade | ||
ENV NVM_DIR /usr/local/nvm | ||
ENV NODE_VERSION v18.16.1 | ||
RUN mkdir -p /usr/local/nvm && apt-get update && echo "y" | apt-get install curl | ||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | ||
RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION" | ||
ENV NODE_PATH $NVM_DIR/versions/node/$NODE_VERSION/bin | ||
ENV PATH $NODE_PATH:$PATH | ||
|
||
# Install dependencies | ||
RUN cargo make deps-wasm | ||
RUN cargo make deps-npm | ||
|
||
# Build | ||
RUN cargo make build-server | ||
RUN cargo make build-bindings | ||
RUN cargo make build-app | ||
RUN cargo make build-backend | ||
|
||
|
||
# Final image | ||
|
||
# Start from a base image (comes with docker) | ||
FROM nestybox/ubuntu-jammy-systemd-docker:latest | ||
|
||
# Copy the built files | ||
COPY --from=builder /app/packages/app/dist /app/packages/app/dist | ||
COPY --from=builder /app/target/release/backend /app/target/release/backend | ||
|
||
# Startup scripts | ||
COPY sysbox/on-start.sh /usr/bin | ||
RUN chmod +x /usr/bin/on-start.sh | ||
|
||
# Entrypoint | ||
ENTRYPOINT [ "on-start.sh" ] |
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
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
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,23 @@ | ||
[package] | ||
name = "backend" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
clap = { version = "4.5", features = ["derive", "env"] } | ||
serde_json = "1.0" | ||
tempfile = "3.10" | ||
tokio = { version = "1.28.2", features = [ | ||
"macros", | ||
"time", | ||
"process", | ||
"rt-multi-thread", | ||
] } | ||
anyhow = "1.0" | ||
log = "0.4" | ||
|
||
typescript-type-def = "0.5" | ||
actix-web = "4.5" | ||
actix-files = "0.6" |
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,20 @@ | ||
use clap::Parser; | ||
|
||
/// Command line options for the backend | ||
#[derive(Parser, Clone)] | ||
pub struct Opts { | ||
#[arg( | ||
short = 'p', | ||
long = "port", | ||
default_value = "8080", | ||
env = "PORT", | ||
help = "Port to listen on" | ||
)] | ||
pub port: u16, | ||
|
||
#[arg(long = "host", default_value = "localhost", env = "HOST", help = "Host to listen on")] | ||
pub host: String, | ||
|
||
#[arg(long = "frontend_folder", help = "Path to the frontend folder")] | ||
pub frontend_folder: Option<String>, | ||
} |
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,5 @@ | ||
mod cli; | ||
mod services; | ||
|
||
pub use cli::Opts; | ||
pub use services::{route_compile, CompilationRequest, CompilationResult}; |
Oops, something went wrong.