Compare commits

..

No commits in common. "6120ce7a30ab5a3e81beb02e00f1dc340f2353c4" and "a0c6c27e8cb40b841237a1de1d4ecbf4ecf172db" have entirely different histories.

4 changed files with 16 additions and 24 deletions

View File

@ -2,8 +2,8 @@ version: '3.7'
services: services:
filed: filed:
build: build:
context: . context: filed
dockerfile: filed/Dockerfile.prod dockerfile: Dockerfile.prod
networks: networks:
bfile: bfile:
volumes: volumes:

View File

@ -2,17 +2,16 @@
FROM rust:alpine as builder FROM rust:alpine as builder
WORKDIR /opt/build WORKDIR /opt/build
COPY filed . COPY . .
COPY ./.git ./.git
RUN apk add --no-cache git musl-dev upx nodejs yarn && \ RUN apk add --no-cache musl-dev upx nodejs yarn && \
yarn global add uglify-js@3.17.4 yarn global add uglify-js
RUN cargo b -r RUN cargo b -r
RUN strip target/release/filed && upx --best target/release/filed RUN strip target/release/filed && upx --best target/release/filed
# --- deploy --- # --- deploy ---
FROM alpine:3.17 FROM busybox:musl
RUN mkdir /config RUN mkdir /config
WORKDIR /config WORKDIR /config

View File

@ -1,5 +1,5 @@
use std::{fs, path::PathBuf, ffi::OsStr, process::Command, error::Error}; use std::{fs, path::PathBuf, ffi::OsStr, process::Command};
use css_minify::optimizations::{Minifier, Level}; use css_minify::optimizations::{Minifier, Level};
@ -17,17 +17,17 @@ fn extfilter(valid: String, x: Option<&OsStr>) -> bool {
ext == valid ext == valid
} }
fn system(cmd: &str, args: &[&str]) -> Result<String, Box<dyn Error>> { fn system(cmd: &str, args: &[&str]) -> String {
let out = Command::new(cmd) let out = Command::new(cmd)
.args(args) .args(args)
.output() .output()
?; .unwrap();
if out.stderr.len() != 0 { if out.stderr.len() != 0 {
panic!("Got this while running {cmd} with \"{}\": {}", args.join(" "), String::from_utf8(out.stderr).unwrap()) panic!("Got this while running {cmd} with \"{}\": {}", args.join(" "), String::from_utf8(out.stderr).unwrap())
} }
Ok(String::from_utf8(out.stdout)?) String::from_utf8(out.stdout).unwrap()
} }
fn main() { fn main() {
@ -65,24 +65,17 @@ fn main() {
scripts.iter().for_each(|asset| { scripts.iter().for_each(|asset| {
Command::new("uglifyjs") Command::new("uglifyjs")
.arg("-c")
.arg(asset) .arg(asset)
.arg("-o") .arg("-o")
.arg(asset_path(asset)) .arg(asset_path(asset))
.arg("-c")
.spawn() .spawn()
.unwrap(); .unwrap();
}); });
let commit = system("git", &["rev-parse", "HEAD"]).map_err(|x| x.to_string()); let commit = system("git", &["rev-parse", "HEAD"]);
let branch = system("git", &["rev-parse", "--abbrev-ref", "HEAD"]).map_err(|x| x.to_string()); let branch = system("git", &["rev-parse", "--abbrev-ref", "HEAD"]);
match commit { println!("cargo:rustc-env=COMMIT_HASH={commit}");
Err(err) => panic!("Can't get commit: {}", err), println!("cargo:rustc-env=COMMIT_BRANCH={branch}");
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}")
}
} }

View File

@ -10,7 +10,7 @@ RUN cargo b -r
RUN strip target/release/janitor && upx --best target/release/janitor RUN strip target/release/janitor && upx --best target/release/janitor
# --- deploy --- # --- deploy ---
FROM alpipne:3.17 FROM busybox:musl
RUN mkdir /config RUN mkdir /config
WORKDIR /config WORKDIR /config