Skip to content

Commit

Permalink
fix single function release build
Browse files Browse the repository at this point in the history
  • Loading branch information
No9 committed Feb 2, 2021
1 parent 3f2a1b1 commit b6ca585
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "roche"
version = "0.3.1"
version = "0.3.2"
authors = ["Anthony Whalley <anton@venshare.com>"]
edition = "2018"
description = "A cli to build serverless rust applications"
Expand Down
24 changes: 23 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ pub fn generateimagetag(buildtype: String) -> Option<String> {
let img = format!("{}/{}{}", l, buildtype, dir);
Some(img)
}
None => None,
None => {
let img = format!("{}{}", buildtype, dir);
Some(img)
}
}
}

Expand Down Expand Up @@ -508,7 +511,26 @@ fn main() -> Result<()> {
let runtimeimage = build_matches
.value_of("runtimeimage")
.unwrap_or(runtime_image.as_str());

let mut tmp_docker_file = str::replace(RELEASE_BUILD, "BASE_IMAGE", buildimage);

if Path::new("lib.rs").exists() {
tmp_docker_file = str::replace(
tmp_docker_file.as_str(),
"#LIB_RS",
"COPY lib.rs /app-build/src",
);
tmp_docker_file = str::replace(
tmp_docker_file.as_str(),
"#TEST",
"RUN cargo test --lib --release",
);
}
if Path::new(".env").exists() {
tmp_docker_file =
str::replace(tmp_docker_file.as_str(), "#ENV", "COPY .env /app-build/src");
}

tmp_docker_file = str::replace(tmp_docker_file.as_str(), "RUNTIME_IMAGE", runtimeimage);

let process = match Command::new("docker")
Expand Down
7 changes: 4 additions & 3 deletions src/template/Release.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM BASE_IMAGE as builder
COPY functions.rs /app-build/src
COPY lib.rs /app-build/src
COPY .env /app-build/src
RUN cargo build --release && cargo test --lib --release
#LIB_RS
#ENV
RUN cargo build --release
#TEST
FROM RUNTIME_IMAGE
RUN addgroup -S rocheuser && adduser -S rocheuser -G rocheuser
WORKDIR "/app"
Expand Down

0 comments on commit b6ca585

Please sign in to comment.