Migrated docker images to be versioned

This commit is contained in:
frikky
2020-11-17 15:54:42 +01:00
parent ae39da8ffd
commit c7a626bdbd
10 changed files with 93 additions and 55 deletions
+2 -1
View File
@@ -5,7 +5,8 @@ WORKDIR /app
RUN go get github.com/docker/docker/api/types github.com/docker/docker/api/types/container github.com/docker/docker/client
COPY orborus.go /app/orborus.go
RUN go mod init orborus
RUN go build
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o orborus .
FROM alpine:3.12
+4 -4
View File
@@ -1,11 +1,11 @@
NAME=orborus
VERSION=0.6.2
NAME=shuffle-orborus
VERSION=0.8.0
echo "Running docker build with $NAME:$VERSION"
#docker rmi frikky/shuffle:$NAME --force
docker build . -t frikky/shuffle:$NAME -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t frikky/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
#docker push frikky/$NAME:$VERSION
docker push frikky/shuffle:$NAME
#docker push frikky/shuffle:$NAME
# docker push docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION
#docker push ghcr.io/frikky/$NAME:$VERSION
docker push ghcr.io/frikky/$NAME:$VERSION
+30 -19
View File
@@ -22,6 +22,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
dockerclient "github.com/docker/docker/client"
"github.com/satori/go.uuid"
//network "github.com/docker/docker/api/types/network"
//natting "github.com/docker/go-connections/nat"
)
@@ -134,30 +135,34 @@ func deployWorker(image string, identifier string, env []string) {
Env: env,
}
log.Printf("Identifier: %s", identifier)
cont, err := dockercli.ContainerCreate(
context.Background(),
config,
hostConfig,
nil,
nil,
identifier,
)
if err != nil {
log.Printf("[ERROR] Container create error: %s", err)
if strings.Contains(fmt.Sprintf("%s", err), "Conflict. The container name ") {
uuid := uuid.NewV4()
identifier = fmt.Sprintf("%s-%s", identifier, uuid)
log.Printf("2 - Identifier: %s", identifier)
cont, err = dockercli.ContainerCreate(
context.Background(),
config,
hostConfig,
nil,
identifier,
)
identifier := fmt.Sprintf("%s-new", identifier)
cont, err = dockercli.ContainerCreate(
context.Background(),
config,
hostConfig,
nil,
nil,
identifier,
)
if err != nil {
log.Printf("[ERROR] Container create error(2): %s", err)
if err != nil {
log.Printf("[ERROR] Container create error(2): %s", err)
return
}
} else {
log.Printf("[ERROR] Container create error: %s", err)
return
}
}
@@ -222,27 +227,32 @@ func initializeImages() {
ctx := context.Background()
if appSdkVersion == "" {
appSdkVersion = "0.6.0"
appSdkVersion = "0.8.0"
log.Printf("[WARNING] SHUFFLE_APP_SDK_VERSION not defined. Defaulting to %s", appSdkVersion)
}
if workerVersion == "" {
workerVersion = "0.6.0"
workerVersion = "0.8.0"
log.Printf("[WARNING] SHUFFLE_WORKER_VERSION not defined. Defaulting to %s", workerVersion)
}
if baseimageregistry == "" {
baseimageregistry = "docker.io"
baseimageregistry = "ghcr.io"
log.Printf("Setting baseimageregistry")
}
if baseimagename == "" {
baseimagename = "frikky/shuffle"
baseimagename = "frikky"
log.Printf("Setting baseimagename")
}
// check whether they are the same first
images := []string{
fmt.Sprintf("%s/%s:app_sdk%s", baseimageregistry, baseimagename, baseimagetagsuffix),
fmt.Sprintf("%s/%s:worker%s", baseimageregistry, baseimagename, baseimagetagsuffix),
//fmt.Sprintf("%s/%s:app_sdk%s", baseimageregistry, baseimagename, baseimagetagsuffix),
//fmt.Sprintf("%s/%s:worker%s", baseimageregistry, baseimagename, baseimagetagsuffix),
fmt.Sprintf("%s/%s/shuffle-app_sdk:%s", baseimageregistry, baseimagename, appSdkVersion),
fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion),
// fmt.Sprintf("docker.io/%s:app_sdk", baseimagename),
// fmt.Sprintf("docker.io/%s:worker", baseimagename),
@@ -315,7 +325,8 @@ func main() {
//workerImage := fmt.Sprintf("%s/worker:%s", baseimagename, workerVersion)
// workerImage := fmt.Sprintf("docker.io/%s:worker", baseimagename)
// fmt.Sprintf("%s/%s:app_sdk%s", baseimageregistry, baseimagename, baseimagetagsuffix),
workerImage := fmt.Sprintf("%s/%s:worker%s", baseimageregistry, baseimagename, baseimagetagsuffix)
//workerImage := fmt.Sprintf("%s/%s:worker%s", baseimageregistry, baseimagename, baseimagetagsuffix)
workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion)
log.Printf("[INFO] Finished configuring docker environment")
+2 -2
View File
@@ -1,4 +1,4 @@
NAME=worker
NAME=shuffle-worker
VERSION=0.8.0
echo "Running docker build with $NAME:$VERSION"
@@ -9,4 +9,4 @@ docker build . -t frikky/shuffle:$NAME -t docker.pkg.github.com/frikky/shuffle/$
#docker push frikky/$NAME:$VERSION
docker push frikky/shuffle:$NAME
#docker push docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION
#docker push ghcr.io/frikky/$NAME:$VERSION
docker push ghcr.io/frikky/$NAME:$VERSION
+11 -8
View File
@@ -792,11 +792,20 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
// SKIP if it's not onprem
for _, nextAction := range nextActions {
action := getAction(workflowExecution, nextAction, environment)
// check visited and onprem
if arrayContains(visited, nextAction) {
log.Printf("ALREADY VISITIED (%s): %s", action.Label, nextAction)
continue
}
if action.AppName == "User Input" {
log.Printf("USER INPUT!")
if action.ID == workflowExecution.Start {
log.Printf("Skipping because it's the startnode")
visited = append(visited, action.ID)
executed = append(executed, action.ID)
continue
} else {
log.Printf("Should stop after this iteration because it's user-input based. %#v", action)
trigger := Trigger{}
@@ -827,12 +836,6 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
}
}
// check visited and onprem
if arrayContains(visited, nextAction) {
log.Printf("ALREADY VISITIED (%s): %s", action.Label, nextAction)
continue
}
// Not really sure how this edgecase happens.
// FIXME
@@ -866,7 +869,7 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
}
if continueOuter {
//log.Printf("Parents of %s aren't finished: %s", nextAction, strings.Join(parents[nextAction], ", "))
log.Printf("Parents of %s aren't finished: %s", nextAction, strings.Join(parents[nextAction], ", "))
//for _, tmpaction := range parents[nextAction] {
// action := getAction(workflowExecution, tmpaction)
// _ = action
@@ -1029,7 +1032,7 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
if len(workflowExecution.Results) == len(workflowExecution.Workflow.Actions) {
if len(workflowExecution.Results) == len(workflowExecution.Workflow.Actions)+extra {
shutdownCheck := true
ctx := context.Background()
for _, result := range workflowExecution.Results {