Skip to content

Commit

Permalink
Merge #2508 #2510 #2517
Browse files Browse the repository at this point in the history
2508: Add documentation for .dockerignore r=TomSweeneyRedHat a=rhatdan

<!--
Thanks for sending a pull request!

Please make sure you've read and understood our contributing guidelines
(https://github.com/containers/buildah/blob/master/CONTRIBUTING.md) as well as ensuring
that all your commits are signed with `git commit -s`.
-->

#### What type of PR is this?

<!--
Please label this pull request according to what type of issue you are
addressing, especially if this is a release targeted pull request.

Uncomment only one `/kind <>` line, hit enter to put that in a new line, and
remove leading whitespace from that line:
-->

> /kind api-change
> /kind bug
> /kind cleanup
> /kind deprecation
> /kind design
> /kind documentation
> /kind failing-test 
> /kind feature
> /kind flake
> /kind other

#### What this PR does / why we need it:

#### How to verify it

#### Which issue(s) this PR fixes:

<!--
Automatically closes linked issue when PR is merged.
Uncomment the following comment block and include the issue
number or None on one line.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`, or `None`.
-->

<!--
Fixes #
or
None
-->

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

<!--
If no, just write `None` in the release-note block below. If yes, a release note
is required: Enter your extended release note in the block below. If the PR
requires additional action from users switching to the new release, include the
string "action required".

For more information on release notes please follow the kubernetes model:
https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note

```



2510: Add BuilderIdentityAnnotation to identify buildah version used to bui… r=TomSweeneyRedHat a=rhatdan

…ld image

We were adding this for buildah commit but not for buildah bud.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

<!--
Thanks for sending a pull request!

Please make sure you've read and understood our contributing guidelines
(https://github.com/containers/buildah/blob/master/CONTRIBUTING.md) as well as ensuring
that all your commits are signed with `git commit -s`.
-->

#### What type of PR is this?

<!--
Please label this pull request according to what type of issue you are
addressing, especially if this is a release targeted pull request.

Uncomment only one `/kind <>` line, hit enter to put that in a new line, and
remove leading whitespace from that line:
-->

> /kind api-change
> /kind bug
> /kind cleanup
> /kind deprecation
> /kind design
> /kind documentation
> /kind failing-test 
> /kind feature
> /kind flake
> /kind other

#### What this PR does / why we need it:

#### How to verify it

#### Which issue(s) this PR fixes:

<!--
Automatically closes linked issue when PR is merged.
Uncomment the following comment block and include the issue
number or None on one line.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`, or `None`.
-->

<!--
Fixes #
or
None
-->

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

<!--
If no, just write `None` in the release-note block below. If yes, a release note
is required: Enter your extended release note in the block below. If the PR
requires additional action from users switching to the new release, include the
string "action required".

For more information on release notes please follow the kubernetes model:
https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note

```



2517: conformance: add a test for COPY from subdirectory r=rhatdan a=nalind

#### What type of PR is this?

/kind cleanup

#### What this PR does / why we need it:

Add a conformance test for containers/podman#6847, making sure that we test copying from a subdirectory of the build context to a new directory.

#### How to verify it

Compare the combination of build context and Dockerfile content to the reported issue, and if doesn't look like we're doing the same thing here, we'll need to correct the test.

#### Which issue(s) this PR fixes:

None

#### Special notes for your reviewer:

The test doesn't need to pass, since we're not requiring that conformance tests pass in CI yet, but this ensures that when we do make it a requirement, we don't miss the case.

#### Does this PR introduce a user-facing change?

```
None
```



Co-authored-by: Daniel J Walsh <dwalsh@redhat.com>
Co-authored-by: Nalin Dahyabhai <nalin@redhat.com>
  • Loading branch information
3 people authored Aug 6, 2020
4 parents 913e8ff + 69f735b + 2c6b0da + 9fc9a22 commit af7f69c
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 2 deletions.
47 changes: 47 additions & 0 deletions docs/buildah-add.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,52 @@ buildah add containerID 'https://github.com/containers/buildah/blob/master/READM

buildah add containerID 'passwd' 'certs.d' /etc

## FILES

### `.dockerignore`

If the file .dockerignore exists in the context directory, `buildah copy` reads
its contents. Buildah uses the content to exclude files and directories from
the context directory, when copying content into the image.

Users can specify a series of Unix shell globals in a .dockerignore file to
identify files to exclude.

Buildah supports a special wildcard string `**` which matches any number of
directories (including zero). For example, **/*.go will exclude all files that
end with .go that are found in all directories.

Example .dockerignore file:

```
# comment
*/temp*
**/temp*
temp?
```

`*/temp*`
Excludes files and directories whose names start with temp in any immediate subdirectory of the root. For example, the plain file /somedir/temporary.txt is excluded, as is the directory /somedir/temp.

`**/temp*`
Excludes files and directories starting with temp from any subdirectory.

`temp?`
Excludes files and directories in the root directory whose names are a one-character extension of temp. For example, /tempa and /tempb are excluded.

Lines starting with ! (exclamation mark) can be used to make exceptions to
exclusions. The following is an example .dockerignore file that uses this
mechanism:
```
*.md
!README.md
```

All markdown files except README.md are excluded from the context.

For more information see:

https://docs.docker.com/engine/reference/builder/#dockerignore-file

## SEE ALSO
buildah(1)
46 changes: 46 additions & 0 deletions docs/buildah-bud.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,52 @@ are stored while pulling and pushing images. Defaults to '/var/tmp'.

## Files

### `.dockerignore`

If the file .dockerignore exists in the context directory, `buildah bud` reads
its contents. Buildah uses the content to exclude files and directories from
the context directory, when executing COPY and ADD directives in the
Containerfile/Dockerfile

Users can specify a series of Unix shell globals in a .dockerignore file to
identify files to exclude.

Buildah supports a special wildcard string `**` which matches any number of
directories (including zero). For example, **/*.go will exclude all files that
end with .go that are found in all directories.

Example .dockerignore file:

```
# comment
*/temp*
**/temp*
temp?
```

`*/temp*`
Excludes files and directories whose names start with temp in any immediate subdirectory of the root. For example, the plain file /somedir/temporary.txt is excluded, as is the directory /somedir/temp.

`**/temp*`
Excludes files and directories starting with temp from any subdirectory.

`temp?`
Excludes files and directories in the root directory whose names are a one-character extension of temp. For example, /tempa and /tempb are excluded.

Lines starting with ! (exclamation mark) can be used to make exceptions to
exclusions. The following is an example .dockerignore file that uses this
mechanism:
```
*.md
!README.md
```

All markdown files except README.md are excluded from the context.

For more information see:

https://docs.docker.com/engine/reference/builder/#dockerignore-file

**registries.conf** (`/etc/containers/registries.conf`)

registries.conf is the configuration file which specifies which container registries should be consulted when completing image names which do not include a registry or domain portion.
Expand Down
47 changes: 47 additions & 0 deletions docs/buildah-copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,52 @@ buildah copy containerID 'https://github.com/containers/buildah' '/tmp'

buildah copy containerID 'passwd' 'certs.d' /etc

## FILES

### `.dockerignore`

If the file .dockerignore exists in the context directory, `buildah copy` reads
its contents. Buildah uses the content to exclude files and directories from
the context directory, when copying content into the image.

Users can specify a series of Unix shell globals in a .dockerignore file to
identify files to exclude.

Buildah supports a special wildcard string `**` which matches any number of
directories (including zero). For example, **/*.go will exclude all files that
end with .go that are found in all directories.

Example .dockerignore file:

```
# comment
*/temp*
**/temp*
temp?
```

`*/temp*`
Excludes files and directories whose names start with temp in any immediate subdirectory of the root. For example, the plain file /somedir/temporary.txt is excluded, as is the directory /somedir/temp.

`**/temp*`
Excludes files and directories starting with temp from any subdirectory.

`temp?`
Excludes files and directories in the root directory whose names are a one-character extension of temp. For example, /tempa and /tempb are excluded.

Lines starting with ! (exclamation mark) can be used to make exceptions to
exclusions. The following is an example .dockerignore file that uses this
mechanism:
```
*.md
!README.md
```

All markdown files except README.md are excluded from the context.

For more information see:

https://docs.docker.com/engine/reference/builder/#dockerignore-file

## SEE ALSO
buildah(1)
1 change: 1 addition & 0 deletions imagebuildah/stage_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,7 @@ func (s *StageExecutor) commit(ctx context.Context, createdBy string, emptyLayer
s.builder.SetHealthcheck(nil)
}
s.builder.ClearLabels()
s.builder.SetLabel(buildah.BuilderIdentityAnnotation, buildah.Version)
for k, v := range config.Labels {
s.builder.SetLabel(k, v)
}
Expand Down
27 changes: 25 additions & 2 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,15 @@ symlink(subdir)"
}

@test "bud-from-scratch-label" {
run_buildah --version
local -a output_fields=($output)
buildah_version=${output_fields[2]}
want_output='map["io.buildah.version":"'$buildah_version'" "test":"label"]'

target=scratch-image
run_buildah bud --label "test=label" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
run_buildah inspect --format '{{printf "%q" .Docker.Config.Labels}}' ${target}
expect_output 'map["test":"label"]'
expect_output "$want_output"
}

@test "bud-from-scratch-annotation" {
Expand Down Expand Up @@ -1789,12 +1794,17 @@ _EOF
}

@test "bud-no-change-label" {
run_buildah --version
local -a output_fields=($output)
buildah_version=${output_fields[2]}
want_output='map["io.buildah.version":"'$buildah_version'" "test":"label"]'

_prefetch alpine
parent=alpine
target=no-change-image
run_buildah bud --label "test=label" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/no-change
run_buildah inspect --format '{{printf "%q" .Docker.Config.Labels}}' ${target}
expect_output 'map["test":"label"]'
expect_output "$want_output"
}

@test "bud-no-change-annotation" {
Expand Down Expand Up @@ -2134,3 +2144,16 @@ EOM
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t testctr -f ${TESTSDIR}/bud/copy-chown/Containerfile.chown_user ${TESTSDIR}/bud/copy-chown
expect_output --substring "myuser myuser"
}

@test "bud-builder-identity" {
_prefetch alpine
parent=alpine
target=no-change-image
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
run_buildah --version
local -a output_fields=($output)
buildah_version=${output_fields[2]}

run_buildah inspect --format '{{ index .Docker.Config.Labels "io.buildah.version"}}' $target
expect_output "$buildah_version"
}
10 changes: 10 additions & 0 deletions tests/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,16 @@ var internalTestCases = []testCase{
fsSkip: []string{"(dir):dir"},
},

{
name: "copy from subdir to new directory",
contextDir: "copydir",
dockerfileContents: strings.Join([]string{
"FROM scratch",
"COPY dir/file /subdir/",
}, "\n"),
fsSkip: []string{"(dir):subdir"},
},

{
name: "copy to renamed file",
contextDir: "copyrename",
Expand Down

0 comments on commit af7f69c

Please sign in to comment.