1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

switch to minio for s3

This commit is contained in:
Robin Appelman 2023-06-13 20:28:34 +02:00
commit ce6f5c0d4c
5 changed files with 28 additions and 28 deletions

View file

@ -37,7 +37,6 @@ jobs:
context: "images/php" context: "images/php"
push: true push: true
tags: icewind1991/haze-php:${{ matrix.php-version }}${{ matrix.variant }} tags: icewind1991/haze-php:${{ matrix.php-version }}${{ matrix.variant }}
dockerfile: "images/php/Dockerfile"
build-args: | build-args: |
PHP_VERSION=${{ matrix.php-version }} PHP_VERSION=${{ matrix.php-version }}
BASE_IMAGE=${{ matrix.variant == '-dbg' && 'icewind1991/php-dbg' || 'php' }} BASE_IMAGE=${{ matrix.variant == '-dbg' && 'icewind1991/php-dbg' || 'php' }}
@ -50,7 +49,6 @@ jobs:
context: "images/haze" context: "images/haze"
push: true push: true
tags: icewind1991/haze:${{ matrix.php-version }}${{ matrix.variant }} tags: icewind1991/haze:${{ matrix.php-version }}${{ matrix.variant }}
dockerfile: "images/haze/Dockerfile"
build-args: | build-args: |
PHP_VERSION=${{ matrix.php-version }}${{ matrix.variant }} PHP_VERSION=${{ matrix.php-version }}${{ matrix.variant }}
cache-from: type=gha cache-from: type=gha

View file

@ -3,10 +3,10 @@
'arguments' => [ 'arguments' => [
'bucket' => 'nextcloud', 'bucket' => 'nextcloud',
'autocreate' => true, 'autocreate' => true,
'key' => 'dummy', 'key' => 'minio',
'secret' => 'dummyj', 'secret' => 'minio123',
'hostname' => 's3', 'hostname' => 's3',
'port' => 4566, 'port' => 9000,
'use_ssl' => false, 'use_ssl' => false,
'use_path_style' => true, 'use_path_style' => true,
'uploadPartSize' => 52428800, 'uploadPartSize' => 52428800,

View file

@ -172,6 +172,10 @@ pub async fn container_logs(
pub struct ExitCode(i64); pub struct ExitCode(i64);
impl ExitCode { impl ExitCode {
pub fn is_ok(&self) -> bool {
self.0 == 0
}
pub fn to_result(&self) -> Result<()> { pub fn to_result(&self) -> Result<()> {
match self.0 { match self.0 {
0 => Ok(()), 0 => Ok(()),

View file

@ -13,10 +13,11 @@ use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use tokio::time::{sleep, timeout}; use tokio::time::{sleep, timeout};
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq, Default)]
#[allow(dead_code)] #[allow(dead_code)]
pub enum PhpVersion { pub enum PhpVersion {
Php82, Php82,
#[default]
Php81, Php81,
Php80, Php80,
Php74, Php74,
@ -184,9 +185,3 @@ impl PhpVersion {
.wrap_err("Timeout after 15 seconds") .wrap_err("Timeout after 15 seconds")
} }
} }
impl Default for PhpVersion {
fn default() -> Self {
PhpVersion::Php81
}
}

View file

@ -20,29 +20,35 @@ pub enum ObjectStore {
impl ObjectStore { impl ObjectStore {
fn image(&self) -> &str { fn image(&self) -> &str {
match self { match self {
ObjectStore::S3 => "localstack/localstack:2.1.0", ObjectStore::S3 | ObjectStore::S3m | ObjectStore::S3mb => {
ObjectStore::S3m => "localstack/localstack:2.1.0", "minio/minio:RELEASE.2023-01-20T02-05-44Z.hotfix.b9b60d73d"
ObjectStore::S3mb => "localstack/localstack:2.1.0", }
ObjectStore::Azure => "arafato/azurite:2.6.5", ObjectStore::Azure => "arafato/azurite:2.6.5",
} }
} }
fn self_env(&self) -> Vec<&str> { fn self_env(&self) -> Vec<&str> {
match self { match self {
ObjectStore::S3 => vec!["DEBUG=1", "SERVICES=s3"], ObjectStore::S3 | ObjectStore::S3m | ObjectStore::S3mb => {
ObjectStore::S3m => vec!["DEBUG=1", "SERVICES=s3"], vec!["MINIO_ACCESS_KEY=minio", "MINIO_SECRET_KEY=minio123"]
ObjectStore::S3mb => vec!["DEBUG=1", "SERVICES=s3"], }
ObjectStore::Azure => vec![], ObjectStore::Azure => vec![],
} }
} }
fn host_name(&self) -> &str { fn host_name(&self) -> &str {
match self { match self {
ObjectStore::S3 => "s3", ObjectStore::S3 | ObjectStore::S3m | ObjectStore::S3mb => "s3",
ObjectStore::S3m => "s3",
ObjectStore::S3mb => "s3",
ObjectStore::Azure => "azure", ObjectStore::Azure => "azure",
} }
} }
fn args(&self) -> &[&str] {
match self {
ObjectStore::S3 | ObjectStore::S3m | ObjectStore::S3mb => &["server", "/data"],
_ => &[],
}
}
} }
#[async_trait::async_trait] #[async_trait::async_trait]
@ -88,6 +94,7 @@ impl ServiceTrait for ObjectStore {
"haze-type" => self.name(), "haze-type" => self.name(),
"haze-cloud-id" => cloud_id "haze-cloud-id" => cloud_id
}), }),
cmd: Some(self.args().into()),
networking_config: Some(NetworkingConfig { networking_config: Some(NetworkingConfig {
endpoints_config: hashmap! { endpoints_config: hashmap! {
network => EndpointSettings { network => EndpointSettings {
@ -114,20 +121,16 @@ impl ServiceTrait for ObjectStore {
match self { match self {
ObjectStore::S3 | ObjectStore::S3mb => { ObjectStore::S3 | ObjectStore::S3mb => {
let mut output = Vec::new(); let mut output = Vec::new();
exec( let exit = exec(
docker, docker,
format!("{}-object", cloud_id), format!("{}-object", cloud_id),
"root", "root",
vec!["curl", "localhost:4566/health"], vec!["curl", "localhost:9000/minio/health/ready"],
vec![], vec![],
Some(&mut output), Some(&mut output),
) )
.await?; .await?;
let output = String::from_utf8(output).into_diagnostic()?; Ok(exit.is_ok())
Ok(
output.contains(r#""s3": "running""#)
|| output.contains(r#""s3": "available""#),
)
} }
_ => { _ => {
let info = docker let info = docker