Initial commit
This commit is contained in:
26
package.py
Normal file
26
package.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import docker
|
||||
|
||||
from docker import DockerClient
|
||||
|
||||
# Container Management
|
||||
|
||||
## Build Image
|
||||
def build(client: DockerClient, app: str):
|
||||
with open(f"{app}/Dockerfile") as dockerfile:
|
||||
image, _ = client.images.build(fileobj=dockerfile, tag="")
|
||||
return image
|
||||
|
||||
## Run Image
|
||||
def run(client: DockerClient, image, app: str):
|
||||
container = client.containers.run(image, detach=True, name=app)
|
||||
|
||||
# Main Packaging Function
|
||||
def pkg(app, version):
|
||||
client = docker.from_env()
|
||||
|
||||
try:
|
||||
image = build(client, app)
|
||||
|
||||
container = run(client, image, app)
|
||||
except Exception as e:
|
||||
print("Error")
|
||||
Reference in New Issue
Block a user