File tree 3 files changed +97
-0
lines changed
3 files changed +97
-0
lines changed Original file line number Diff line number Diff line change
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
3
+ {
4
+ "name" : " Existing Dockerfile" ,
5
+ "build" : {
6
+ // Sets the run context to one level up instead of the .devcontainer folder.
7
+ "context" : " .." ,
8
+ // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9
+ "dockerfile" : " ../Dockerfile"
10
+ }
11
+
12
+ // Features to add to the dev container. More info: https://containers.dev/features.
13
+ // "features": {},
14
+
15
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
16
+ // "forwardPorts": [],
17
+
18
+ // Uncomment the next line to run commands after the container is created.
19
+ // "postCreateCommand": "cat /etc/os-release",
20
+
21
+ // Configure tool-specific properties.
22
+ // "customizations": {},
23
+
24
+ // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
25
+ // "remoteUser": "devcontainer"
26
+ }
Original file line number Diff line number Diff line change
1
+ FROM python:3.8
2
+
3
+ WORKDIR /workspace
4
+
5
+ RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc
6
+ RUN chmod +x mc
7
+
8
+ RUN pip install pydantic pyyaml
9
+
10
+
11
+ COPY * /workspace/
12
+
13
+
14
+ CMD python init.py
Original file line number Diff line number Diff line change
1
+ import subprocess
2
+ from pydantic import BaseModel , Field
3
+ from typing import Optional , List
4
+ import uuid
5
+ import os
6
+ import yaml
7
+
8
+ minio_address = os .getenv ("MINIO_HOST" )
9
+ root_user = os .getenv ("MINIO_ROOT_USER" )
10
+ root_password = os .getenv ("MINIO_ROOT_PASSWORD" )
11
+
12
+ alias = "local"
13
+
14
+
15
+ class Bucket (BaseModel ):
16
+ name : str
17
+
18
+
19
+ class User (BaseModel ):
20
+ name : str
21
+ access_key : str
22
+ secret_key : str
23
+ policies : List [str ]
24
+
25
+
26
+ class Config (BaseModel ):
27
+ users : List [User ]
28
+ buckets : List [Bucket ]
29
+
30
+
31
+ def main ():
32
+ with open ("./config.yaml" , "r" ) as f :
33
+ x = yaml .safe_load (f )
34
+ config = Config (** x )
35
+
36
+ subprocess .call (
37
+ f"./mc alias set { alias } { minio_address } { root_user } { root_password } " ,
38
+ shell = True ,
39
+ )
40
+
41
+ for bucket in config .buckets :
42
+ subprocess .call (f"./mc mb { alias } /{ bucket .name } " , shell = True )
43
+
44
+ for user in config .users :
45
+ subprocess .call (
46
+ f"./mc admin user add { alias } { user .access_key } { user .secret_key } " ,
47
+ shell = True ,
48
+ )
49
+ for policy in user .policies :
50
+ subprocess .call (
51
+ f"./mc admin policy attach { alias } { policy } --user { user .access_key } " ,
52
+ shell = True ,
53
+ )
54
+
55
+
56
+ if __name__ == "__main__" :
57
+ main ()
You can’t perform that action at this time.
0 commit comments