Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
21dcca47b5
commit
c5568f2bea
3
.env
Normal file
3
.env
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
AWS_ENDPOINT_URL=http://127.0.0.1:10000
|
||||||
|
AWS_ACCESS_KEY_ID=minioadmin
|
||||||
|
AWS_SECRET_ACCESS_KEY=minioadminpassword
|
@ -1,5 +1,10 @@
|
|||||||
use std::{ops::Deref, sync::Arc};
|
use std::{ops::Deref, sync::Arc};
|
||||||
|
|
||||||
|
use aws_config::{BehaviorVersion, Region};
|
||||||
|
use aws_sdk_s3::config::Credentials;
|
||||||
|
|
||||||
|
use self::infra::aws_s3::s3_client;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SharedApp(Arc<App>);
|
pub struct SharedApp(Arc<App>);
|
||||||
|
|
||||||
@ -23,9 +28,44 @@ pub struct App {
|
|||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub async fn new() -> anyhow::Result<Self> {
|
pub async fn new() -> anyhow::Result<Self> {
|
||||||
let shared_config = aws_config::load_from_env().await;
|
Ok(Self {
|
||||||
let client = aws_sdk_s3::Client::new(&shared_config);
|
s3_client: s3_client().await?,
|
||||||
|
})
|
||||||
Ok(Self { s3_client: client })
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod infra {
|
||||||
|
pub mod aws_s3 {
|
||||||
|
use aws_config::{BehaviorVersion, Region};
|
||||||
|
use aws_sdk_s3::config::Credentials;
|
||||||
|
|
||||||
|
pub async fn s3_client() -> anyhow::Result<aws_sdk_s3::Client> {
|
||||||
|
let shared_config = aws_config::defaults(BehaviorVersion::latest())
|
||||||
|
.region(Region::new("eu-west-1"))
|
||||||
|
.credentials_provider(Credentials::new(
|
||||||
|
std::env::var("AWS_ACCESS_KEY_ID")?,
|
||||||
|
std::env::var("AWS_SECRET_ACCESS_KEY")?,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
"flux_releaser",
|
||||||
|
));
|
||||||
|
|
||||||
|
let config = aws_sdk_s3::config::Builder::from(&shared_config.load().await)
|
||||||
|
.endpoint_url(std::env::var("AWS_ENDPOINT_URL")?)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let client = aws_sdk_s3::Client::from_conf(config);
|
||||||
|
|
||||||
|
let buckets = client.list_buckets().send().await?;
|
||||||
|
|
||||||
|
buckets
|
||||||
|
.buckets
|
||||||
|
.iter()
|
||||||
|
.flatten()
|
||||||
|
.flat_map(|b| &b.name)
|
||||||
|
.for_each(|n| tracing::debug!("test: found aws bucket: {}", n));
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
templates/docker-compose.yaml
Normal file
27
templates/docker-compose.yaml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
minio:
|
||||||
|
image: quay.io/minio/minio
|
||||||
|
container_name: minio
|
||||||
|
hostname: minio
|
||||||
|
command: server --address 0.0.0.0:10000 --console-address 0.0.0.0:10001 /data
|
||||||
|
ports:
|
||||||
|
- '127.0.0.1:10000:10000'
|
||||||
|
- '127.0.0.1:10001:10001'
|
||||||
|
environment:
|
||||||
|
- MINIO_ROOT_USER=minioadmin
|
||||||
|
- MINIO_ROOT_PASSWORD=minioadminpassword
|
||||||
|
|
||||||
|
createbuckets:
|
||||||
|
image: minio/mc
|
||||||
|
depends_on:
|
||||||
|
- minio
|
||||||
|
entrypoint: >
|
||||||
|
/bin/sh -c "
|
||||||
|
/usr/bin/mc alias set myminio http://minio:10000 minioadmin minioadminpassword;
|
||||||
|
/usr/bin/mc admin info myminio;
|
||||||
|
/usr/bin/mc mb myminio/mybucket;
|
||||||
|
/usr/bin/mc policy set public myminio/mybucket;
|
||||||
|
exit 0;
|
||||||
|
"
|
Loading…
Reference in New Issue
Block a user