Dockerfile Parts (#428)

* De-duplicate Dockerfiles by using a bash file to concatenate common parts

Resolves #375.

Dockerfiles are still committed to the repo to avoid a dependency on bash.

* Add a CI job to confirm the committed dockerfiles are the currently generated ones

* Create dedicated Dockerfiles per processor network

Ensures the compromising of network-specific dependencies doesn't lead to a
compromise of the build process for all processors.

* Dockerfile corrections

* Correct call to build processor Docker image in tests/processor
This commit is contained in:
Luke Parker
2023-11-12 23:55:15 -05:00
committed by GitHub
parent c328e5ea68
commit 351436a258
32 changed files with 511 additions and 154 deletions

View File

@@ -54,7 +54,14 @@ pub fn build(name: String) {
if HashSet::from(["bitcoin", "ethereum", "monero"]).contains(name.as_str()) {
dockerfile_path = dockerfile_path.join("coins");
}
dockerfile_path = dockerfile_path.join(&name).join("Dockerfile");
if name.contains("-processor") {
dockerfile_path = dockerfile_path
.join("processor")
.join(name.split('-').next().unwrap())
.join("Dockerfile");
} else {
dockerfile_path = dockerfile_path.join(&name).join("Dockerfile");
}
// For all services, if the Dockerfile was edited after the image was built we should rebuild
let mut last_modified =
@@ -71,7 +78,7 @@ pub fn build(name: String) {
meta(repo_path.join("substrate").join("primitives")),
meta(repo_path.join("message-queue")),
],
"processor" => vec![
"bitcoin-processor" | "ethereum-processor" | "monero-processor" => vec![
meta(repo_path.join("common")),
meta(repo_path.join("crypto")),
meta(repo_path.join("coins")),

View File

@@ -29,28 +29,26 @@ pub fn processor_instance(
port: u32,
message_queue_key: <Ristretto as Ciphersuite>::F,
) -> TestBodySpecification {
serai_docker_tests::build("processor".to_string());
let mut entropy = [0; 32];
OsRng.fill_bytes(&mut entropy);
let network_str = match network {
NetworkId::Serai => panic!("starting a processor for Serai"),
NetworkId::Bitcoin => "bitcoin",
NetworkId::Ethereum => "ethereum",
NetworkId::Monero => "monero",
};
let image = format!("{network_str}-processor");
serai_docker_tests::build(image.clone());
TestBodySpecification::with_image(
Image::with_repository("serai-dev-processor").pull_policy(PullPolicy::Never),
Image::with_repository(format!("serai-dev-{image}")).pull_policy(PullPolicy::Never),
)
.replace_env(
[
("MESSAGE_QUEUE_KEY".to_string(), hex::encode(message_queue_key.to_repr())),
("ENTROPY".to_string(), hex::encode(entropy)),
(
"NETWORK".to_string(),
(match network {
NetworkId::Serai => panic!("starting a processor for Serai"),
NetworkId::Bitcoin => "bitcoin",
NetworkId::Ethereum => "ethereum",
NetworkId::Monero => "monero",
})
.to_string(),
),
("NETWORK".to_string(), network_str.to_string()),
("NETWORK_RPC_LOGIN".to_string(), format!("{RPC_USER}:{RPC_PASS}")),
("NETWORK_RPC_PORT".to_string(), port.to_string()),
("DB_PATH".to_string(), "./processor-db".to_string()),