From 9c3871bdc5fe8172ef80abf225760e2ad8c2eef6 Mon Sep 17 00:00:00 2001 From: Maddox Werts Date: Fri, 18 Apr 2025 14:04:48 -0400 Subject: [PATCH] Initial commit --- .gitignore | 25 +++++++++++++++++++++++++ README.md | 7 +++++++ docker/build/Dockerfile | 28 ++++++++++++++++++++++++++++ docker/build/build.sh | 8 ++++++++ project/Cargo.toml | 6 ++++++ project/src/main.rs | 3 +++ scripts/build/build.sh | 9 +++++++++ scripts/build/docker.sh | 7 +++++++ scripts/build/pull.sh | 11 +++++++++++ 9 files changed, 104 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 docker/build/Dockerfile create mode 100644 docker/build/build.sh create mode 100644 project/Cargo.toml create mode 100644 project/src/main.rs create mode 100755 scripts/build/build.sh create mode 100755 scripts/build/docker.sh create mode 100755 scripts/build/pull.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d2f260 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# ---> Rust +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# RustRover +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# Result +build/* \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1ada7e2 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +

Dockerized-Rust

+

A Template for Rust Projects

+ +## About this Template +This template should be used when developing **Rust** apps. It's designed to be *lightweight* and *Fast*. I would recommend using this **with** my **Rust-LS** container as it makes Rust Development so much more fun and streamlined + +Just adopt this into your project and it should take care of itself! \ No newline at end of file diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile new file mode 100644 index 0000000..09046be --- /dev/null +++ b/docker/build/Dockerfile @@ -0,0 +1,28 @@ +## BACKEND ## +# Parent image +FROM debian + +# Creating directories +RUN mkdir /work /src /app +WORKDIR /work + +# Installing Deps +RUN apt update -y +RUN apt install -y wget build-essential libssl-dev pkg-config + +# Downloading Rust Install Script +RUN wget https://sh.rustup.rs -O /tmp/rust.sh +RUN chmod +x /tmp/rust.sh + +# Installing Rust Toolchain +RUN /tmp/rust.sh -y + +# Getting Environment Variable +ENV PROJ_NAME=example + +# Copying Build Script +COPY docker/build/build.sh /bin/build.sh +RUN chmod +x /bin/build.sh + +## RUNTILE ## +CMD ["bash", "/bin/build.sh"] \ No newline at end of file diff --git a/docker/build/build.sh b/docker/build/build.sh new file mode 100644 index 0000000..3e05f0c --- /dev/null +++ b/docker/build/build.sh @@ -0,0 +1,8 @@ +# Copying source code to working directory +cp -r /src/* . + +# Building the app +/root/.cargo/bin/cargo build + +# Copying app to Result Directory +cp target/debug/$PROJ_NAME /app/$PROJ_NAME \ No newline at end of file diff --git a/project/Cargo.toml b/project/Cargo.toml new file mode 100644 index 0000000..3a7e011 --- /dev/null +++ b/project/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "example" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/project/src/main.rs b/project/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/project/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/scripts/build/build.sh b/scripts/build/build.sh new file mode 100755 index 0000000..de9638e --- /dev/null +++ b/scripts/build/build.sh @@ -0,0 +1,9 @@ +# Clearing The Screen +clear + +# Building the Rust App +docker run --rm -it \ + -v "$PWD/project:/src:Z" \ + -v "$PWD/build:/app:Z" \ + -e "PROJ_NAME=example" \ + rust-buildbot $@ \ No newline at end of file diff --git a/scripts/build/docker.sh b/scripts/build/docker.sh new file mode 100755 index 0000000..eb3b007 --- /dev/null +++ b/scripts/build/docker.sh @@ -0,0 +1,7 @@ +# Clearing The Screen +clear + +# Building the Docker Container +docker build . \ + -t rust-buildbot \ + -f docker/build/Dockerfile \ No newline at end of file diff --git a/scripts/build/pull.sh b/scripts/build/pull.sh new file mode 100755 index 0000000..50b9cfa --- /dev/null +++ b/scripts/build/pull.sh @@ -0,0 +1,11 @@ +# Clearing Screen +clear + +# Pulling Docker Image +docker pull git.lan/objnull/rust-buildbot:latest + +# Rename Image +docker tag git.lan/objnull/rust-buildbot:latest rust-buildbot:latest + +# Clean-Up +docker image rm git.lan/objnull/rust-buildbot:latest