run docker daemon manually in CI environment

This commit is contained in:
Late Night Defender 2024-05-16 17:23:43 +07:00
parent 640ae4392d
commit c9acf34a5b
2 changed files with 10 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"time" "time"
"context" "context"
"os"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
@ -19,6 +20,14 @@ func dockerPullMongo() {
ExecSystem("docker pull mongo") ExecSystem("docker pull mongo")
} }
func checkDockerExistence() {
filePath := "/var/run/docker.sock"
_, err := os.Stat(filePath)
if os.IsNotExist(err) {
ExecSystem("dockerd &")
}
}
func dockerRunMongo() { func dockerRunMongo() {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)

View file

@ -87,6 +87,7 @@ func main() {
checkSettings() checkSettings()
instDeps() instDeps()
genKeys() genKeys()
checkDockerExistence()
dockerNetworkCreate() dockerNetworkCreate()
dockerPullMongo() dockerPullMongo()
dockerRunMongo() dockerRunMongo()