Skip to content

Commit

Permalink
fix: Fix Issue with Podman Unable to Create PHP Runtime Website
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 committed Dec 3, 2024
1 parent 8e3a06b commit 9612e98
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
19 changes: 19 additions & 0 deletions backend/app/service/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,25 @@ func checkImageExist(client *client.Client, imageItem string) bool {
return false
}

func checkImageLike(imageName string) bool {
cli, err := docker.NewDockerClient()
if err != nil {
return false
}
images, err := cli.ImageList(context.Background(), image.ListOptions{})
if err != nil {
return false
}
for _, img := range images {
for _, tag := range img.RepoTags {
if strings.Contains(tag, imageName) {
return true
}
}
}
return false
}

func pullImages(ctx context.Context, client *client.Client, imageName string) error {
options := image.PullOptions{}
repos, _ := imageRepoRepo.List()
Expand Down
7 changes: 1 addition & 6 deletions backend/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
switch runtime.Type {
case constant.RuntimePHP:
if runtime.Resource == constant.ResourceAppstore {
client, err := docker.NewDockerClient()
if err != nil {
return err
}
defer client.Close()
if !checkImageExist(client, runtime.Image) {
if !checkImageLike(runtime.Image) {
return buserr.WithName("ErrImageNotExist", runtime.Name)
}
var (
Expand Down

0 comments on commit 9612e98

Please sign in to comment.