Skip to content

Commit

Permalink
Default to Ubuntu base image (railwayapp#712)
Browse files Browse the repository at this point in the history
* default base image to ubuntu

* update insta snapshots

* install openssl for node provider

* update snapshot tests

* update snapshot tests

* update nixpkgs archive

* fix clojure provider

* point to latest ubuntu image
  • Loading branch information
coffee-cup committed Dec 16, 2022
1 parent 6d64ee5 commit 5912927
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 20 deletions.
7 changes: 5 additions & 2 deletions src/nixpacks/images.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pub const DEFAULT_BASE_IMAGE: &str = "ghcr.io/railwayapp/nixpacks:debian-1670889918";
pub const DEBIAN_SLIM_IMAGE: &str = "debian:bullseye-slim";
pub const UBUNTU_BASE_IMAGE: &str = "ghcr.io/railwayapp/nixpacks:ubuntu-1671044363";
pub const DEBIAN_BASE_IMAGE: &str = "ghcr.io/railwayapp/nixpacks:debian-1670889918";
pub const DEFAULT_BASE_IMAGE: &str = UBUNTU_BASE_IMAGE;

pub const STANDALONE_IMAGE: &str = "ubuntu:jammy";
4 changes: 2 additions & 2 deletions src/nixpacks/nix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub mod pkg;

// This line is automatically updated.
// Last Modified: 2022-09-12 17:11:54 UTC+0000
// https://github.com/NixOS/nixpkgs/commit/a0b7e70db7a55088d3de0cc370a59f9fbcc906c3
pub const NIXPKGS_ARCHIVE: &str = "a0b7e70db7a55088d3de0cc370a59f9fbcc906c3";
// https://github.com/NixOS/nixpkgs/commit/ffca9ffaaafb38c8979068cee98b2644bd3f14cb
pub const NIXPKGS_ARCHIVE: &str = "ffca9ffaaafb38c8979068cee98b2644bd3f14cb";

#[derive(Eq, PartialEq, Default, Debug, Clone)]
struct NixGroup {
Expand Down
2 changes: 1 addition & 1 deletion src/nixpacks/plan/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl NixpacksBuildPlanGenerator<'_> {
plan.add_variables(Environment::clone_variables(env));
}

plan.pin();
plan.pin(env.is_config_variable_truthy("DEBIAN"));

Ok(plan)
}
Expand Down
13 changes: 9 additions & 4 deletions src/nixpacks/plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use self::{
phase::{Phase, Phases, StartPhase},
topological_sort::topological_sort,
};
use super::images::DEFAULT_BASE_IMAGE;
use super::images::{DEBIAN_BASE_IMAGE, UBUNTU_BASE_IMAGE};
use crate::nixpacks::{
app::{App, StaticAssets},
environment::{Environment, EnvironmentVariables},
Expand Down Expand Up @@ -268,10 +268,15 @@ impl BuildPlan {
BuildPlan::new(&phases, start)
}

pub fn pin(&mut self) {
pub fn pin(&mut self, use_debian: bool) {
self.providers = Some(Vec::new());
if self.build_image.is_none() {
self.build_image = Some(DEFAULT_BASE_IMAGE.to_string());
let base_image = if use_debian {
DEBIAN_BASE_IMAGE
} else {
UBUNTU_BASE_IMAGE
};
self.build_image = Some(base_image.to_string());
}

self.resolve_phase_names();
Expand Down Expand Up @@ -410,7 +415,7 @@ mod test {
)
.unwrap();

plan.pin();
plan.pin(false);
assert_eq!(
plan.get_phase("setup").unwrap().nix_pkgs,
Some(vec!["nodejs".to_string(), "yarn".to_string()])
Expand Down
4 changes: 2 additions & 2 deletions src/nixpacks/plan/phase.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::nixpacks::{
images::{DEBIAN_SLIM_IMAGE, DEFAULT_BASE_IMAGE},
images::{DEFAULT_BASE_IMAGE, STANDALONE_IMAGE},
nix::{pkg::Pkg, NIXPKGS_ARCHIVE},
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -219,7 +219,7 @@ impl StartPhase {
}

pub fn run_in_slim_image(&mut self) {
self.run_image = Some(DEBIAN_SLIM_IMAGE.to_string());
self.run_image = Some(STANDALONE_IMAGE.to_string());
}

pub fn add_file_dependency<S: Into<String>>(&mut self, file: S) {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/clojure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Provider for ClojureProvider {
};

// based on project config, uberjar can be created under ./target/uberjar or ./target, This ensure file will be found on the same place whatevery the project config is
let move_file_cmd = "if [ -f /app/target/uberjar/*standalone.jar ]; then mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi";
let move_file_cmd = "if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi";
let mut build = Phase::build(Some(format!("{build_cmd}; {move_file_cmd}")));
build.depends_on_phase("setup");

Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__clojure.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expression: plan
"setup"
],
"cmds": [
"lein uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
"lein uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
]
},
"setup": {
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__clojure_jdk11.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expression: plan
"setup"
],
"cmds": [
"lein uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
"lein uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
]
},
"setup": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expression: plan
"setup"
],
"cmds": [
"lein uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
"lein uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
]
},
"setup": {
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__clojure_ring_app.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expression: plan
"setup"
],
"cmds": [
"lein ring uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
"lein ring uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
]
},
"setup": {
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__go.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ expression: plan
},
"start": {
"cmd": "./out",
"runImage": "debian:bullseye-slim"
"runImage": "ubuntu:jammy"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ expression: plan
},
"start": {
"cmd": "./out",
"runImage": "debian:bullseye-slim"
"runImage": "ubuntu:jammy"
}
}
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__go_gin.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ expression: plan
},
"start": {
"cmd": "./out",
"runImage": "debian:bullseye-slim"
"runImage": "ubuntu:jammy"
}
}
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__go_mod.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ expression: plan
},
"start": {
"cmd": "./out",
"runImage": "debian:bullseye-slim"
"runImage": "ubuntu:jammy"
}
}

0 comments on commit 5912927

Please sign in to comment.