mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
podman-remote: enable support for additional build-context on macOS, remote
Feature of additional build context added here https://github.com/containers/buildah/pull/3978 already exists on `podman` following PR just enables this feature of `podman-remote` and `podman on macOS` setups. Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
@ -99,7 +99,7 @@ different stages in COPY instruction.
|
|||||||
|
|
||||||
Valid values could be:
|
Valid values could be:
|
||||||
|
|
||||||
* Local directory – e.g. --build-context project2=../path/to/project2/src
|
* Local directory – e.g. --build-context project2=../path/to/project2/src (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
|
||||||
* HTTP URL to a tarball – e.g. --build-context src=https://example.org/releases/src.tar
|
* HTTP URL to a tarball – e.g. --build-context src=https://example.org/releases/src.tar
|
||||||
* Container image – specified with a container-image:// prefix, e.g. --build-context alpine=container-image://alpine:3.15, (also accepts docker://, docker-image://)
|
* Container image – specified with a container-image:// prefix, e.g. --build-context alpine=container-image://alpine:3.15, (also accepts docker://, docker-image://)
|
||||||
|
|
||||||
|
@ -70,68 +70,69 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
query := struct {
|
query := struct {
|
||||||
AddHosts string `schema:"extrahosts"`
|
AddHosts string `schema:"extrahosts"`
|
||||||
AdditionalCapabilities string `schema:"addcaps"`
|
AdditionalCapabilities string `schema:"addcaps"`
|
||||||
AllPlatforms bool `schema:"allplatforms"`
|
AdditionalBuildContexts string `schema:"additionalbuildcontexts"`
|
||||||
Annotations string `schema:"annotations"`
|
AllPlatforms bool `schema:"allplatforms"`
|
||||||
AppArmor string `schema:"apparmor"`
|
Annotations string `schema:"annotations"`
|
||||||
BuildArgs string `schema:"buildargs"`
|
AppArmor string `schema:"apparmor"`
|
||||||
CacheFrom string `schema:"cachefrom"`
|
BuildArgs string `schema:"buildargs"`
|
||||||
CgroupParent string `schema:"cgroupparent"` // nolint
|
CacheFrom string `schema:"cachefrom"`
|
||||||
Compression uint64 `schema:"compression"`
|
CgroupParent string `schema:"cgroupparent"` // nolint
|
||||||
ConfigureNetwork string `schema:"networkmode"`
|
Compression uint64 `schema:"compression"`
|
||||||
CPPFlags string `schema:"cppflags"`
|
ConfigureNetwork string `schema:"networkmode"`
|
||||||
CpuPeriod uint64 `schema:"cpuperiod"` // nolint
|
CPPFlags string `schema:"cppflags"`
|
||||||
CpuQuota int64 `schema:"cpuquota"` // nolint
|
CpuPeriod uint64 `schema:"cpuperiod"` // nolint
|
||||||
CpuSetCpus string `schema:"cpusetcpus"` // nolint
|
CpuQuota int64 `schema:"cpuquota"` // nolint
|
||||||
CpuSetMems string `schema:"cpusetmems"` // nolint
|
CpuSetCpus string `schema:"cpusetcpus"` // nolint
|
||||||
CpuShares uint64 `schema:"cpushares"` // nolint
|
CpuSetMems string `schema:"cpusetmems"` // nolint
|
||||||
DNSOptions string `schema:"dnsoptions"`
|
CpuShares uint64 `schema:"cpushares"` // nolint
|
||||||
DNSSearch string `schema:"dnssearch"`
|
DNSOptions string `schema:"dnsoptions"`
|
||||||
DNSServers string `schema:"dnsservers"`
|
DNSSearch string `schema:"dnssearch"`
|
||||||
Devices string `schema:"devices"`
|
DNSServers string `schema:"dnsservers"`
|
||||||
Dockerfile string `schema:"dockerfile"`
|
Devices string `schema:"devices"`
|
||||||
DropCapabilities string `schema:"dropcaps"`
|
Dockerfile string `schema:"dockerfile"`
|
||||||
Envs []string `schema:"setenv"`
|
DropCapabilities string `schema:"dropcaps"`
|
||||||
Excludes string `schema:"excludes"`
|
Envs []string `schema:"setenv"`
|
||||||
ForceRm bool `schema:"forcerm"`
|
Excludes string `schema:"excludes"`
|
||||||
From string `schema:"from"`
|
ForceRm bool `schema:"forcerm"`
|
||||||
HTTPProxy bool `schema:"httpproxy"`
|
From string `schema:"from"`
|
||||||
IdentityLabel bool `schema:"identitylabel"`
|
HTTPProxy bool `schema:"httpproxy"`
|
||||||
Ignore bool `schema:"ignore"`
|
IdentityLabel bool `schema:"identitylabel"`
|
||||||
Isolation string `schema:"isolation"`
|
Ignore bool `schema:"ignore"`
|
||||||
Jobs int `schema:"jobs"` // nolint
|
Isolation string `schema:"isolation"`
|
||||||
LabelOpts string `schema:"labelopts"`
|
Jobs int `schema:"jobs"` // nolint
|
||||||
Labels string `schema:"labels"`
|
LabelOpts string `schema:"labelopts"`
|
||||||
Layers bool `schema:"layers"`
|
Labels string `schema:"labels"`
|
||||||
LogRusage bool `schema:"rusage"`
|
Layers bool `schema:"layers"`
|
||||||
Manifest string `schema:"manifest"`
|
LogRusage bool `schema:"rusage"`
|
||||||
MemSwap int64 `schema:"memswap"`
|
Manifest string `schema:"manifest"`
|
||||||
Memory int64 `schema:"memory"`
|
MemSwap int64 `schema:"memswap"`
|
||||||
NamespaceOptions string `schema:"nsoptions"`
|
Memory int64 `schema:"memory"`
|
||||||
NoCache bool `schema:"nocache"`
|
NamespaceOptions string `schema:"nsoptions"`
|
||||||
OSFeatures []string `schema:"osfeature"`
|
NoCache bool `schema:"nocache"`
|
||||||
OSVersion string `schema:"osversion"`
|
OSFeatures []string `schema:"osfeature"`
|
||||||
OutputFormat string `schema:"outputformat"`
|
OSVersion string `schema:"osversion"`
|
||||||
Platform []string `schema:"platform"`
|
OutputFormat string `schema:"outputformat"`
|
||||||
Pull bool `schema:"pull"`
|
Platform []string `schema:"platform"`
|
||||||
PullPolicy string `schema:"pullpolicy"`
|
Pull bool `schema:"pull"`
|
||||||
Quiet bool `schema:"q"`
|
PullPolicy string `schema:"pullpolicy"`
|
||||||
Registry string `schema:"registry"`
|
Quiet bool `schema:"q"`
|
||||||
Rm bool `schema:"rm"`
|
Registry string `schema:"registry"`
|
||||||
RusageLogFile string `schema:"rusagelogfile"`
|
Rm bool `schema:"rm"`
|
||||||
Remote string `schema:"remote"`
|
RusageLogFile string `schema:"rusagelogfile"`
|
||||||
Seccomp string `schema:"seccomp"`
|
Remote string `schema:"remote"`
|
||||||
Secrets string `schema:"secrets"`
|
Seccomp string `schema:"seccomp"`
|
||||||
SecurityOpt string `schema:"securityopt"`
|
Secrets string `schema:"secrets"`
|
||||||
ShmSize int `schema:"shmsize"`
|
SecurityOpt string `schema:"securityopt"`
|
||||||
Squash bool `schema:"squash"`
|
ShmSize int `schema:"shmsize"`
|
||||||
TLSVerify bool `schema:"tlsVerify"`
|
Squash bool `schema:"squash"`
|
||||||
Tags []string `schema:"t"`
|
TLSVerify bool `schema:"tlsVerify"`
|
||||||
Target string `schema:"target"`
|
Tags []string `schema:"t"`
|
||||||
Timestamp int64 `schema:"timestamp"`
|
Target string `schema:"target"`
|
||||||
Ulimits string `schema:"ulimits"`
|
Timestamp int64 `schema:"timestamp"`
|
||||||
UnsetEnvs []string `schema:"unsetenv"`
|
Ulimits string `schema:"ulimits"`
|
||||||
|
UnsetEnvs []string `schema:"unsetenv"`
|
||||||
}{
|
}{
|
||||||
Dockerfile: "Dockerfile",
|
Dockerfile: "Dockerfile",
|
||||||
IdentityLabel: true,
|
IdentityLabel: true,
|
||||||
@ -375,6 +376,14 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
additionalTags = append(additionalTags, possiblyNormalizedTag)
|
additionalTags = append(additionalTags, possiblyNormalizedTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var additionalBuildContexts = map[string]*buildahDefine.AdditionalBuildContext{}
|
||||||
|
if _, found := r.URL.Query()["additionalbuildcontexts"]; found {
|
||||||
|
if err := json.Unmarshal([]byte(query.AdditionalBuildContexts), &additionalBuildContexts); err != nil {
|
||||||
|
utils.BadRequest(w, "additionalbuildcontexts", query.AdditionalBuildContexts, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var buildArgs = map[string]string{}
|
var buildArgs = map[string]string{}
|
||||||
if _, found := r.URL.Query()["buildargs"]; found {
|
if _, found := r.URL.Query()["buildargs"]; found {
|
||||||
if err := json.Unmarshal([]byte(query.BuildArgs), &buildArgs); err != nil {
|
if err := json.Unmarshal([]byte(query.BuildArgs), &buildArgs); err != nil {
|
||||||
@ -562,12 +571,13 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||||
buildOptions := buildahDefine.BuildOptions{
|
buildOptions := buildahDefine.BuildOptions{
|
||||||
AddCapabilities: addCaps,
|
AddCapabilities: addCaps,
|
||||||
AdditionalTags: additionalTags,
|
AdditionalBuildContexts: additionalBuildContexts,
|
||||||
Annotations: annotations,
|
AdditionalTags: additionalTags,
|
||||||
CPPFlags: cppflags,
|
Annotations: annotations,
|
||||||
Args: buildArgs,
|
CPPFlags: cppflags,
|
||||||
AllPlatforms: query.AllPlatforms,
|
Args: buildArgs,
|
||||||
|
AllPlatforms: query.AllPlatforms,
|
||||||
CommonBuildOpts: &buildah.CommonBuildOptions{
|
CommonBuildOpts: &buildah.CommonBuildOptions{
|
||||||
AddHost: addhosts,
|
AddHost: addhosts,
|
||||||
ApparmorProfile: apparmor,
|
ApparmorProfile: apparmor,
|
||||||
|
@ -81,6 +81,13 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
for _, tag := range options.AdditionalTags {
|
for _, tag := range options.AdditionalTags {
|
||||||
params.Add("t", tag)
|
params.Add("t", tag)
|
||||||
}
|
}
|
||||||
|
if additionalBuildContexts := options.AdditionalBuildContexts; len(additionalBuildContexts) > 0 {
|
||||||
|
additionalBuildContextMap, err := jsoniter.Marshal(additionalBuildContexts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
params.Set("additionalbuildcontexts", string(additionalBuildContextMap))
|
||||||
|
}
|
||||||
if buildArgs := options.Args; len(buildArgs) > 0 {
|
if buildArgs := options.Args; len(buildArgs) > 0 {
|
||||||
bArgs, err := jsoniter.MarshalToString(buildArgs)
|
bArgs, err := jsoniter.MarshalToString(buildArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -193,21 +193,10 @@ skip_if_remote "volumes don't work with podman-remote" \
|
|||||||
"buildah bud --volume" \
|
"buildah bud --volume" \
|
||||||
"buildah-bud-policy"
|
"buildah-bud-policy"
|
||||||
|
|
||||||
# Most of this should work in podman remote after API implementation other than where context is host.
|
|
||||||
skip_if_remote "--build-context option not implemented in podman-remote" \
|
skip_if_remote "--build-context option not implemented in podman-remote" \
|
||||||
"build-with-additional-build-context and COPY, test pinning image" \
|
|
||||||
"build-with-additional-build-context and COPY, stagename and additional-context conflict" \
|
|
||||||
"build-with-additional-build-context and COPY, additionalContext and numeric value of stage" \
|
|
||||||
"build-with-additional-build-context and COPY, additionalContext and numeric value of stage" \
|
|
||||||
"build-with-additional-build-context and COPY, additional context from host" \
|
"build-with-additional-build-context and COPY, additional context from host" \
|
||||||
"build-with-additional-build-context and COPY, additional context from external URL" \
|
|
||||||
"build-with-additional-build-context and RUN --mount=from=, additional-context is URL and mounted from subdir" \
|
|
||||||
"build-with-additional-build-context and RUN --mount=from=, additional-context not image and also test conflict with stagename" \
|
"build-with-additional-build-context and RUN --mount=from=, additional-context not image and also test conflict with stagename" \
|
||||||
"build-with-additional-build-context and RUN --mount=from=, additional-context and also test conflict with stagename" \
|
|
||||||
"bud-multiple-platform for --all-platform with additional-build-context" \
|
|
||||||
"build-with-additional-build-context and FROM, stagename and additional-context conflict" \
|
|
||||||
"bud with Containerfile.in, via envariable" \
|
"bud with Containerfile.in, via envariable" \
|
||||||
"build-with-additional-build-context and FROM, pin busybox to alpine"
|
|
||||||
|
|
||||||
# Requires a local file outside context dir
|
# Requires a local file outside context dir
|
||||||
skip_if_remote "local keyfile not sent to podman-remote" \
|
skip_if_remote "local keyfile not sent to podman-remote" \
|
||||||
|
Reference in New Issue
Block a user