mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Merge pull request #11134 from rhatdan/buildx
Alias build to buildx, so it won't fail
This commit is contained in:
@ -67,6 +67,18 @@ var (
|
|||||||
podman image build --layers --force-rm --tag imageName .`,
|
podman image build --layers --force-rm --tag imageName .`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildxBuildCmd = &cobra.Command{
|
||||||
|
Args: buildCmd.Args,
|
||||||
|
Use: buildCmd.Use,
|
||||||
|
Short: buildCmd.Short,
|
||||||
|
Long: buildCmd.Long,
|
||||||
|
RunE: buildCmd.RunE,
|
||||||
|
ValidArgsFunction: buildCmd.ValidArgsFunction,
|
||||||
|
Example: `podman buildx build .
|
||||||
|
podman buildx build --creds=username:password -t imageName -f Containerfile.simple .
|
||||||
|
podman buildx build --layers --force-rm --tag imageName .`,
|
||||||
|
}
|
||||||
|
|
||||||
buildOpts = buildFlagsWrapper{}
|
buildOpts = buildFlagsWrapper{}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,11 +103,24 @@ func init() {
|
|||||||
Parent: imageCmd,
|
Parent: imageCmd,
|
||||||
})
|
})
|
||||||
buildFlags(imageBuildCmd)
|
buildFlags(imageBuildCmd)
|
||||||
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
||||||
|
Command: buildxBuildCmd,
|
||||||
|
Parent: buildxCmd,
|
||||||
|
})
|
||||||
|
buildFlags(buildxBuildCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFlags(cmd *cobra.Command) {
|
func buildFlags(cmd *cobra.Command) {
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
||||||
|
// buildx build --load ignored, but added for compliance
|
||||||
|
flags.Bool("load", false, "buildx --load")
|
||||||
|
_ = flags.MarkHidden("load")
|
||||||
|
|
||||||
|
// buildx build --progress ignored, but added for compliance
|
||||||
|
flags.String("progress", "auto", "buildx --progress")
|
||||||
|
_ = flags.MarkHidden("progress")
|
||||||
|
|
||||||
// Podman flags
|
// Podman flags
|
||||||
flags.BoolVarP(&buildOpts.SquashAll, "squash-all", "", false, "Squash all layers into a single layer")
|
flags.BoolVarP(&buildOpts.SquashAll, "squash-all", "", false, "Squash all layers into a single layer")
|
||||||
|
|
||||||
|
29
cmd/podman/images/buildx.go
Normal file
29
cmd/podman/images/buildx.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package images
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/containers/podman/v3/cmd/podman/registry"
|
||||||
|
"github.com/containers/podman/v3/cmd/podman/validate"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Command: podman _buildx_
|
||||||
|
// This is a hidden command, which was added to make converting
|
||||||
|
// from Docker to Podman easier.
|
||||||
|
// For now podman buildx build just calls into podman build
|
||||||
|
// If we are adding new buildx features, we will add them by default
|
||||||
|
// to podman build.
|
||||||
|
buildxCmd = &cobra.Command{
|
||||||
|
Use: "buildx",
|
||||||
|
Short: "Build images",
|
||||||
|
Long: "Build images",
|
||||||
|
RunE: validate.SubCommandExists,
|
||||||
|
Hidden: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
||||||
|
Command: buildxCmd,
|
||||||
|
})
|
||||||
|
}
|
@ -33,7 +33,9 @@ func TestShellCompletionFunctions(t *testing.T) {
|
|||||||
func checkCommand(t *testing.T, cmd *cobra.Command) {
|
func checkCommand(t *testing.T, cmd *cobra.Command) {
|
||||||
if cmd.HasSubCommands() {
|
if cmd.HasSubCommands() {
|
||||||
for _, childCmd := range cmd.Commands() {
|
for _, childCmd := range cmd.Commands() {
|
||||||
checkCommand(t, childCmd)
|
if !childCmd.Hidden {
|
||||||
|
checkCommand(t, childCmd)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not check if completion for that command is provided
|
// if not check if completion for that command is provided
|
||||||
|
@ -43,6 +43,8 @@ containers can be left in container storage. Use the `podman ps --all --storage`
|
|||||||
command to see these containers. External containers can be removed with the
|
command to see these containers. External containers can be removed with the
|
||||||
`podman rm --storage` command.
|
`podman rm --storage` command.
|
||||||
|
|
||||||
|
`podman buildx build` command is an alias of `podman build`. Not all `buildx build` features are available in Podman. The `buildx build` option is provided for scripting compatibility.
|
||||||
|
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
#### **--add-host**=*host*
|
#### **--add-host**=*host*
|
||||||
|
@ -29,6 +29,27 @@ EOF
|
|||||||
run_podman rmi -f build_test
|
run_podman rmi -f build_test
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "podman buildx - basic test" {
|
||||||
|
rand_filename=$(random_string 20)
|
||||||
|
rand_content=$(random_string 50)
|
||||||
|
|
||||||
|
tmpdir=$PODMAN_TMPDIR/build-test
|
||||||
|
mkdir -p $tmpdir
|
||||||
|
dockerfile=$tmpdir/Dockerfile
|
||||||
|
cat >$dockerfile <<EOF
|
||||||
|
FROM $IMAGE
|
||||||
|
RUN echo $rand_content > /$rand_filename
|
||||||
|
EOF
|
||||||
|
|
||||||
|
run_podman buildx build --load -t build_test --format=docker $tmpdir
|
||||||
|
is "$output" ".*COMMIT" "COMMIT seen in log"
|
||||||
|
|
||||||
|
run_podman run --rm build_test cat /$rand_filename
|
||||||
|
is "$output" "$rand_content" "reading generated file in image"
|
||||||
|
|
||||||
|
run_podman rmi -f build_test
|
||||||
|
}
|
||||||
|
|
||||||
@test "podman build test -f -" {
|
@test "podman build test -f -" {
|
||||||
rand_filename=$(random_string 20)
|
rand_filename=$(random_string 20)
|
||||||
rand_content=$(random_string 50)
|
rand_content=$(random_string 50)
|
||||||
|
Reference in New Issue
Block a user