Use app name and deployment ID in build directory structure
Change build directory from builds/<app-id>-<random> to builds/<appname>/<deployment-id>-<random> for better organization and easier debugging.
This commit is contained in:
parent
2ed23912a9
commit
4ece7431af
@ -205,17 +205,18 @@ func (svc *Service) cloneRepository(
|
|||||||
deployment *models.Deployment,
|
deployment *models.Deployment,
|
||||||
) (string, func(), error) {
|
) (string, func(), error) {
|
||||||
// Use a subdirectory of DataDir for builds since it's mounted from the host
|
// Use a subdirectory of DataDir for builds since it's mounted from the host
|
||||||
// and accessible to Docker for bind mounts (unlike /tmp inside the container)
|
// and accessible to Docker for bind mounts (unlike /tmp inside the container).
|
||||||
buildsDir := filepath.Join(svc.config.DataDir, "builds")
|
// Structure: builds/<appname>/<deployment-id>-<random>
|
||||||
|
appBuildsDir := filepath.Join(svc.config.DataDir, "builds", app.Name)
|
||||||
|
|
||||||
err := os.MkdirAll(buildsDir, buildsDirPermissions)
|
err := os.MkdirAll(appBuildsDir, buildsDirPermissions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
svc.failDeployment(ctx, app, deployment, fmt.Errorf("failed to create builds dir: %w", err))
|
svc.failDeployment(ctx, app, deployment, fmt.Errorf("failed to create builds dir: %w", err))
|
||||||
|
|
||||||
return "", nil, fmt.Errorf("failed to create builds dir: %w", err)
|
return "", nil, fmt.Errorf("failed to create builds dir: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDir, err := os.MkdirTemp(buildsDir, app.ID+"-*")
|
tempDir, err := os.MkdirTemp(appBuildsDir, fmt.Sprintf("%d-*", deployment.ID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
svc.failDeployment(ctx, app, deployment, fmt.Errorf("failed to create temp dir: %w", err))
|
svc.failDeployment(ctx, app, deployment, fmt.Errorf("failed to create temp dir: %w", err))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user