Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add amd64 platform by default #455

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/docker/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ type Builder struct {
Tags []string
Dockerfile string
CacheFrom []string
Platform string
}

func NewBuilder(buildArgs map[string]*string, tags []string, dockerfile string, cacheFrom []string) Builder {
func NewBuilder(buildArgs map[string]*string, tags []string, dockerfile string, cacheFrom []string, platform string) Builder {
return Builder{
BuildArgs: buildArgs,
Tags: tags,
Dockerfile: dockerfile,
CacheFrom: cacheFrom,
Platform: platform,
}
}

Expand Down Expand Up @@ -113,6 +115,7 @@ func (b *Builder) buildWithDocker(
Dockerfile: relDockerfile,
Tags: tags,
BuildArgs: buildArgs,
Platform: b.Platform,
}

resp, err := cli.ImageBuild(context.Background(), buildCtx, buildOpts)
Expand Down
5 changes: 4 additions & 1 deletion internal/docker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import (
type Registry struct {
Registry string
Token string
Platform string
}

func NewRegistry(registry, token string) Registry {
func NewRegistry(registry, token, platform string) Registry {
return Registry{
Registry: registry,
Token: token,
Platform: platform,
}
}

Expand All @@ -45,6 +47,7 @@ func (r *Registry) Push(ctx context.Context, w io.Writer, image string, tags []s
resp, err := cli.ImagePush(ctx, image+":"+tags[0], types.ImagePushOptions{
RegistryAuth: r.Token,
All: true,
Platform: r.Platform,
})
if err != nil {
return fmt.Errorf("unable to push image: %s", err)
Expand Down
12 changes: 11 additions & 1 deletion internal/manager/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@ func (e *Manager) Push(ui terminal.UI) error {

tagLatest := fmt.Sprintf("%s-latest", e.Project.Env)
imageUri := fmt.Sprintf("%s/%s", e.App.DockerRegistry, image)
platform := "linux/amd64"
if e.Project.PreferRuntime == "docker-arm64" {
platform = "linux/arm64"
}

r := docker.NewRegistry(*repository.RepositoryUri, token)
r := docker.NewRegistry(*repository.RepositoryUri, token, platform)

err = r.Push(context.Background(), s.TermOutput(), imageUri, []string{e.Project.Tag, tagLatest})
if err != nil {
Expand Down Expand Up @@ -277,11 +281,17 @@ func (e *Manager) Build(ui terminal.UI) error {

cache := []string{fmt.Sprintf("%s:%s", imageUri, fmt.Sprintf("%s-latest", e.Project.Env))}

platform := "linux/amd64"
if e.Project.PreferRuntime == "docker-arm64" {
platform = "linux/arm64"
}

b := docker.NewBuilder(
buildArgs,
tags,
dockerfile,
cache,
platform,
)

err = b.Build(ui, s, e.Project.RootDir)
Expand Down