feat(docker): dockerized and added auto upload actions
Some checks failed
Cloud Actions / Dockerhub (push) Failing after 54s

This commit is contained in:
darkicewolf50 2025-05-22 16:01:55 -06:00
parent 4065642393
commit 56b5463142
5 changed files with 91 additions and 5 deletions

View File

@ -0,0 +1,45 @@
# name of the workflow.
# this is optional.
name: Cloud Actions
# events that will trigger this workflow.
# here, we only have "pull_request", so the workflow will run
# whenever we create a pull request.
# other examples: [push] and [pull_request, push]
on:
pull_request:
push:
branches:
- master
# each workflow must have at least one job.
# jobs run in parallel by default (we can change that).
# each job groups together a series of steps to accomplish a purpose.
jobs:
Dockerhub:
runs-on: ubuntu-latest
# if: ${{ github.ref == 'refs/heads/master' || github.event.pull_request.merged == true }} # Runs if it's a push to 'main' or a merged PR to 'main'
steps:
- name: checkout
uses: actions/checkout@v3
- name: Login to Dockerhub # log into docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }} # Using secret for Docker username
password: ${{ secrets.DOCKER_PASSWORD }} # Using secret for Docker password
id: docker-login
- name: build container image # build the container
run: docker compose build --no-cache
id: docker-build
- name: Upload to Dockerhub
run: docker push darkicewolf50/darkicewolf50cloud:latest
if: ${{ steps.docker-login.outcome == 'success' && steps.docker-build.outcome == 'success' }}
- name: Upload with Git SHA tag
run: |
docker tag darkicewolf50/darkicewolf50cloud:latest darkicewolf50/darkicewolf50cloud:${{ github.sha }}
docker push darkicewolf50/darkicewolf50cloud:${{ github.sha }}

View File

@ -1,3 +1,9 @@
# darkicewolf50Cloud
My backend application, self-hosted and primarily written in Rust
My backend application, self-hosted and primarily written in Rust
This is a mirror of the repo, live code is hosted [here](https://gitea.bajacloud.duckdns.org/darkicewolf50/darkicewolf50Cloud) as well as any testing of the code.
I do not consent for this code to be used in any training data for AI or AI like products or services.
This is only uploaded here so that I can bet those sweet sweet green marks on my gituhb profile.

11
docker-compose.yaml Normal file
View File

@ -0,0 +1,11 @@
services:
bajacloud:
container_name: darkicewolf50cloud
image: darkicewolf50/darkicewolf50cloud:latest
# restart: unless-stopped
build: . # do not include in delpoyment version
ports:
- 5050:8000
volumes:
- ./database:/database
- ./blogs:/blogs

24
dockerfile Normal file
View File

@ -0,0 +1,24 @@
# ----------- Build Stage -----------
FROM rust:1.87-slim AS builder
WORKDIR /darkicewolf50_cloud
# Install build dependencies
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
# Copy source and build
COPY . .
RUN cargo build --release
# ----------- Runtime Stage -----------
FROM debian:bookworm-slim
# Install runtime dependencies (e.g., for OpenSSL if needed)
RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /darkicewolf50_cloud
COPY --from=builder /darkicewolf50_cloud/target/release/darkicewolf50_cloud .
EXPOSE 8000
CMD ["./darkicewolf50_cloud"]

View File

@ -42,7 +42,7 @@ struct TechDes {
#[get("/skills")]
pub async fn skills_home(req: HttpRequest) -> impl Responder {
log_incoming(req, "GET", "/skills");
let raw_yaml: String = fs::read_to_string("./data_txt/skill_level.yaml").unwrap();
let raw_yaml: String = fs::read_to_string("/database/skill_level.yaml").unwrap();
// .expect("Cannot open file or missing file.");
let vec_yaml = yaml_rust2::YamlLoader::load_from_str(&raw_yaml).unwrap()[0].clone();
@ -82,7 +82,7 @@ pub async fn project(limit: web::Path<usize>, req: HttpRequest) -> impl Responde
let limit = limit.into_inner();
let raw_yaml: String = fs::read_to_string("./data_txt/projects.yaml").unwrap();
let raw_yaml: String = fs::read_to_string("/database/projects.yaml").unwrap();
let vec_yaml = yaml_rust2::YamlLoader::load_from_str(&raw_yaml).unwrap()[0].clone();
let raw_vec: Vec<ProjectDes> = vec_yaml
@ -130,7 +130,7 @@ pub async fn get_blog(
) -> impl Responder {
log_incoming(req, "GET", "/blogs/blog/{blog_name}");
let blog_name = blog_name.into_inner();
let file_path = format!("./data_txt/blogs/{blog_name}.md");
let file_path = format!("/blogs/{}.md", blog_name);
let path = Path::new(&file_path);
let Ok(blog_text) = fs::read_to_string(&path) else {
@ -180,7 +180,7 @@ pub async fn get_blogs_preview(props: web::Path<(u8, u32)>, req: HttpRequest) ->
let (num_limit, page_num) = props.into_inner();
let mut available_blogs: Vec<String> = Vec::new();
let dir = Path::new("./data_txt/blogs");
let dir = Path::new("/blogs");
if dir.is_dir() {
for entry in fs::read_dir(dir).unwrap() {
let entry = entry