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

Inherit USER from base image #2426

Merged
merged 3 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions jib-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ All notable changes to this project will be documented in this file.

### Fixed

- Fixes the problem not inheriting `USER` container configuration from a base image. ([#2421](https://github.com/GoogleContainerTools/jib/pull/2421))

## 0.13.1

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public Image call() throws LayerPropertyNotFoundException {
.setHealthCheck(baseImage.getHealthCheck())
.addExposedPorts(baseImage.getExposedPorts())
.addVolumes(baseImage.getVolumes())
.setUser(baseImage.getUser())
.setWorkingDirectory(baseImage.getWorkingDirectory());

// Add history elements for non-empty layers that don't have one yet
Expand Down Expand Up @@ -114,12 +115,14 @@ public Image call() throws LayerPropertyNotFoundException {
imageBuilder
.addEnvironment(containerConfiguration.getEnvironmentMap())
.setCreated(containerConfiguration.getCreationTime())
.setUser(containerConfiguration.getUser())
.setEntrypoint(computeEntrypoint(baseImage, containerConfiguration))
.setProgramArguments(computeProgramArguments(baseImage, containerConfiguration))
.addExposedPorts(containerConfiguration.getExposedPorts())
.addVolumes(containerConfiguration.getVolumes())
.addLabels(containerConfiguration.getLabels());
if (containerConfiguration.getUser() != null) {
imageBuilder.setUser(containerConfiguration.getUser());
}
if (containerConfiguration.getWorkingDirectory() != null) {
imageBuilder.setWorkingDirectory(containerConfiguration.getWorkingDirectory().toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void setUp() throws DigestException {
.addEnvironment(ImmutableMap.of("BASE_ENV", "BASE_ENV_VALUE", "BASE_ENV_2", "DEFAULT"))
.addLabel("base.label", "base.label.value")
.addLabel("base.label.2", "default")
.setUser("base:user")
.setWorkingDirectory("/base/working/directory")
.setEntrypoint(ImmutableList.of("baseImageEntrypoint"))
.setProgramArguments(ImmutableList.of("catalina.sh", "run"))
Expand Down Expand Up @@ -143,6 +144,7 @@ public void test_basicCase() {
baseImageLayers,
applicationLayers)
.call();
Assert.assertEquals("root", image.getUser());
Assert.assertEquals(
testDescriptorDigest, image.getLayers().asList().get(0).getBlobDescriptor().getDigest());
}
Expand Down Expand Up @@ -230,6 +232,22 @@ public void testOverrideWorkingDirectory() {
Assert.assertEquals("/my/directory", image.getWorkingDirectory());
}

@Test
public void test_inheritedUser() {
Mockito.when(mockContainerConfiguration.getUser()).thenReturn(null);

Image image =
new BuildImageStep(
mockBuildContext,
mockProgressEventDispatcherFactory,
baseImage,
baseImageLayers,
applicationLayers)
.call();

Assert.assertEquals("base:user", image.getUser());
}

@Test
public void test_inheritedEntrypoint() {
Mockito.when(mockContainerConfiguration.getEntrypoint()).thenReturn(null);
Expand Down
2 changes: 2 additions & 0 deletions jib-gradle-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.

### Fixed

- Fixes the problem not inheriting `USER` container configuration from a base image. ([#2421](https://github.com/GoogleContainerTools/jib/pull/2421))

## 2.2.0

### Added
Expand Down
2 changes: 2 additions & 0 deletions jib-maven-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.

### Fixed

- Fixes the problem not inheriting `USER` container configuration from a base image. ([#2421](https://github.com/GoogleContainerTools/jib/pull/2421))

## 2.2.0

### Added
Expand Down