This repository was archived by the owner on Aug 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 11from dataclasses import dataclass , field
2+ from datetime import datetime
23from enum import Enum
34from pathlib import Path
45from typing import List , TYPE_CHECKING
56
67from gcp_pilot .datastore import Document
78from gcp_pilot .storage import CloudStorage
9+ from google .api_core .exceptions import NotFound
810from slugify import slugify
911
1012import settings
@@ -49,10 +51,23 @@ def local_dockerfile(self) -> Path:
4951 return settings .PROJECT_DIR / 'engine' / self .name / 'Dockerfile'
5052
5153 async def upload_dockerfile (self ):
54+ target_file_name = f'buildpack/{ self .name } /Dockerfile'
55+
5256 gcs = CloudStorage ()
5357
58+ # versioning
59+ try :
60+ timestamp = int (datetime .now ().timestamp ())
61+ await gcs .copy (
62+ source_file_name = target_file_name ,
63+ target_file_name = f"{ target_file_name } .{ timestamp } " ,
64+ source_bucket_name = settings .FLAMINGO_GCS_BUCKET ,
65+ target_bucket_name = settings .FLAMINGO_GCS_BUCKET ,
66+ )
67+ except NotFound :
68+ pass
69+
5470 # TODO: invalidate GCS file cache?
55- target_file_name = f'buildpack/{ self .name } /Dockerfile'
5671 blob = await gcs .upload (
5772 bucket_name = settings .FLAMINGO_GCS_BUCKET ,
5873 source_file = str (self .local_dockerfile ),
You can’t perform that action at this time.
0 commit comments