generated from OBJNULL/Dockerized-Rust
Initial commit
This commit is contained in:
commit
4eaef537f0
9 changed files with 104 additions and 0 deletions
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
@ -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/*
|
7
README.md
Normal file
7
README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<h1 align="center">Dockerized-Rust</h1>
|
||||||
|
<p align="center">A Template for Rust Projects</p>
|
||||||
|
|
||||||
|
## 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!
|
28
docker/build/Dockerfile
Normal file
28
docker/build/Dockerfile
Normal file
|
@ -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"]
|
8
docker/build/build.sh
Normal file
8
docker/build/build.sh
Normal file
|
@ -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
|
6
project/Cargo.toml
Normal file
6
project/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "example"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
3
project/src/main.rs
Normal file
3
project/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
9
scripts/build/build.sh
Executable file
9
scripts/build/build.sh
Executable file
|
@ -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 $@
|
7
scripts/build/docker.sh
Executable file
7
scripts/build/docker.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
# Clearing The Screen
|
||||||
|
clear
|
||||||
|
|
||||||
|
# Building the Docker Container
|
||||||
|
docker build . \
|
||||||
|
-t rust-buildbot \
|
||||||
|
-f docker/build/Dockerfile
|
11
scripts/build/pull.sh
Executable file
11
scripts/build/pull.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue