From b1463519d797ac7b76240ccf3b533ce60cac1bde Mon Sep 17 00:00:00 2001 From: blek Date: Wed, 1 Nov 2023 00:46:54 +1000 Subject: [PATCH 1/3] fix prod dockerfile build error --- docker-compose.prod.yml | 4 ++-- filed/Dockerfile.prod | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index a2d464c..4ac8eb2 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -2,8 +2,8 @@ version: '3.7' services: filed: build: - context: filed - dockerfile: Dockerfile.prod + context: . + dockerfile: filed/Dockerfile.prod networks: bfile: volumes: diff --git a/filed/Dockerfile.prod b/filed/Dockerfile.prod index f67f2e6..eee77aa 100644 --- a/filed/Dockerfile.prod +++ b/filed/Dockerfile.prod @@ -2,7 +2,8 @@ FROM rust:alpine as builder WORKDIR /opt/build -COPY . . +COPY filed . +COPY ./.git ./.git RUN apk add --no-cache musl-dev upx nodejs yarn && \ yarn global add uglify-js -- 2.40.1 From 6302d11acd0e7ea46198bd47406ad913caf7fec5 Mon Sep 17 00:00:00 2001 From: blek Date: Wed, 1 Nov 2023 01:26:57 +1000 Subject: [PATCH 2/3] fix filed dockerfile and use alpine as a base image --- filed/Dockerfile.prod | 6 +++--- janitor/Dockerfile.prod | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/filed/Dockerfile.prod b/filed/Dockerfile.prod index eee77aa..86f20c6 100644 --- a/filed/Dockerfile.prod +++ b/filed/Dockerfile.prod @@ -5,14 +5,14 @@ WORKDIR /opt/build COPY filed . COPY ./.git ./.git -RUN apk add --no-cache musl-dev upx nodejs yarn && \ - yarn global add uglify-js +RUN apk add --no-cache git musl-dev upx nodejs yarn && \ + yarn global add uglify-js@3.17.4 RUN cargo b -r RUN strip target/release/filed && upx --best target/release/filed # --- deploy --- -FROM busybox:musl +FROM alpine:3.17 RUN mkdir /config WORKDIR /config diff --git a/janitor/Dockerfile.prod b/janitor/Dockerfile.prod index 9eab590..8829da5 100644 --- a/janitor/Dockerfile.prod +++ b/janitor/Dockerfile.prod @@ -10,7 +10,7 @@ RUN cargo b -r RUN strip target/release/janitor && upx --best target/release/janitor # --- deploy --- -FROM busybox:musl +FROM alpipne:3.17 RUN mkdir /config WORKDIR /config -- 2.40.1 From 6120ce7a30ab5a3e81beb02e00f1dc340f2353c4 Mon Sep 17 00:00:00 2001 From: blek Date: Wed, 1 Nov 2023 01:28:00 +1000 Subject: [PATCH 3/3] get rid of function panics in the build.rs --- filed/build.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/filed/build.rs b/filed/build.rs index 04b9494..a3b0f11 100644 --- a/filed/build.rs +++ b/filed/build.rs @@ -1,5 +1,5 @@ -use std::{fs, path::PathBuf, ffi::OsStr, process::Command}; +use std::{fs, path::PathBuf, ffi::OsStr, process::Command, error::Error}; use css_minify::optimizations::{Minifier, Level}; @@ -17,17 +17,17 @@ fn extfilter(valid: String, x: Option<&OsStr>) -> bool { ext == valid } -fn system(cmd: &str, args: &[&str]) -> String { +fn system(cmd: &str, args: &[&str]) -> Result> { let out = Command::new(cmd) .args(args) .output() - .unwrap(); + ?; if out.stderr.len() != 0 { panic!("Got this while running {cmd} with \"{}\": {}", args.join(" "), String::from_utf8(out.stderr).unwrap()) } - String::from_utf8(out.stdout).unwrap() + Ok(String::from_utf8(out.stdout)?) } fn main() { @@ -65,17 +65,24 @@ fn main() { scripts.iter().for_each(|asset| { Command::new("uglifyjs") - .arg("-c") .arg(asset) .arg("-o") .arg(asset_path(asset)) + .arg("-c") .spawn() .unwrap(); }); - let commit = system("git", &["rev-parse", "HEAD"]); - let branch = system("git", &["rev-parse", "--abbrev-ref", "HEAD"]); + let commit = system("git", &["rev-parse", "HEAD"]).map_err(|x| x.to_string()); + let branch = system("git", &["rev-parse", "--abbrev-ref", "HEAD"]).map_err(|x| x.to_string()); - println!("cargo:rustc-env=COMMIT_HASH={commit}"); - println!("cargo:rustc-env=COMMIT_BRANCH={branch}"); + match commit { + Err(err) => panic!("Can't get commit: {}", err), + Ok(commit) => println!("cargo:rustc-env=COMMIT_HASH={commit}") + } + + match branch { + Err(err) => panic!("Can't get commit: {}", err), + Ok(branch) => println!("cargo:rustc-env=COMMIT_BRANCH={branch}") + } } \ No newline at end of file -- 2.40.1