Skip to content

Commit

Permalink
feat: parameterize nakama image
Browse files Browse the repository at this point in the history
  • Loading branch information
zulkhair committed Nov 13, 2024
1 parent 64feb1f commit 4f9e89d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
1 change: 0 additions & 1 deletion common/docker/client_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (c *Client) buildImages(ctx context.Context, dockerServices ...service.Serv

// Remove the container
err := c.removeContainer(ctx, dockerService.Name)
fmt.Printf("Removing container %s\n", dockerService.Image)
if err != nil {
p.Send(multispinner.ProcessState{
Icon: style.CrossIcon.Render(),
Expand Down
21 changes: 20 additions & 1 deletion common/docker/service/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package service

import (
"fmt"
"strings"

"github.com/docker/docker/api/types/container"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"

"pkg.world.dev/world-cli/common/config"
)
Expand Down Expand Up @@ -62,10 +64,26 @@ func EVM(cfg *config.Config) Service {
"thank slam unknown fury script among bread social switch glide wool clog flag enroll"
}

evmImage := "ghcr.io/argus-labs/world-engine-evm:latest"
if cfg.DockerEnv["EVM_IMAGE"] != "" {
evmImage = cfg.DockerEnv["EVM_IMAGE"]
}

var platform ocispec.Platform
if cfg.DockerEnv["EVM_IMAGE_PLATFORM"] != "" {
evmImagePlatform := strings.Split(cfg.DockerEnv["EVM_IMAGE_PLATFORM"], "/")
if len(evmImagePlatform) == 2 { //nolint:gomnd //2 is the expected length
platform = ocispec.Platform{
Architecture: evmImagePlatform[1],
OS: evmImagePlatform[0],
}
}
}

return Service{
Name: getEVMContainerName(cfg),
Config: container.Config{
Image: "ghcr.io/argus-labs/world-engine-evm:1.4.1",
Image: evmImage,
Env: []string{
fmt.Sprintf("DA_BASE_URL=%s", daBaseURL),
fmt.Sprintf("DA_AUTH_TOKEN=%s", cfg.DockerEnv["DA_AUTH_TOKEN"]),
Expand All @@ -85,5 +103,6 @@ func EVM(cfg *config.Config) Service {
RestartPolicy: container.RestartPolicy{Name: "unless-stopped"},
NetworkMode: container.NetworkMode(cfg.DockerEnv["CARDINAL_NAMESPACE"]),
},
Platform: platform,
}
}
27 changes: 22 additions & 5 deletions common/docker/service/nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"fmt"
"strconv"
"strings"
"time"

"github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -53,6 +54,25 @@ func Nakama(cfg *config.Config) Service {
}
}

nakamaImage := "ghcr.io/argus-labs/world-engine-nakama:latest"
if cfg.DockerEnv["NAKAMA_IMAGE"] != "" {
nakamaImage = cfg.DockerEnv["NAKAMA_IMAGE"]
}

platform := ocispec.Platform{
Architecture: "amd64",
OS: "linux",
}
if cfg.DockerEnv["NAKAMA_IMAGE_PLATFORM"] != "" {
nakamaImagePlatform := strings.Split(cfg.DockerEnv["NAKAMA_IMAGE_PLATFORM"], "/")
if len(nakamaImagePlatform) == 2 { //nolint:gomnd //2 is the expected length
platform = ocispec.Platform{
Architecture: nakamaImagePlatform[1],
OS: nakamaImagePlatform[0],
}
}
}

// prometheus metrics export is disabled if port is 0
// src: https://heroiclabs.com/docs/nakama/getting-started/configuration/#metrics
prometheusPort := 0
Expand All @@ -65,7 +85,7 @@ func Nakama(cfg *config.Config) Service {
return Service{
Name: getNakamaContainerName(cfg),
Config: container.Config{
Image: "ghcr.io/argus-labs/world-engine-nakama:1.2.9",
Image: nakamaImage,
Env: []string{
fmt.Sprintf("CARDINAL_CONTAINER=%s", getCardinalContainerName(cfg)),
fmt.Sprintf("CARDINAL_ADDR=%s:4040", getCardinalContainerName(cfg)),
Expand Down Expand Up @@ -100,9 +120,6 @@ func Nakama(cfg *config.Config) Service {
RestartPolicy: container.RestartPolicy{Name: "unless-stopped"},
NetworkMode: container.NetworkMode(cfg.DockerEnv["CARDINAL_NAMESPACE"]),
},
Platform: ocispec.Platform{
Architecture: "amd64",
OS: "linux",
},
Platform: platform,
}
}

0 comments on commit 4f9e89d

Please # to comment.