appsody / stacks

Appsody application stacks. This repo will be archived soon.
https://appsody.dev
Apache License 2.0
89 stars 120 forks source link

Update Quarkus Dockerfile to run as non-root #778

Closed paulrobinson closed 4 years ago

paulrobinson commented 4 years ago

Proposed fix for https://github.com/appsody/stacks/issues/720

neeraj-laad commented 4 years ago

I do not like relying on a fixed user id 1001 as that has caused issues in the past with updating base images.

Can we just let the useradd command assign a uid?

paulrobinson commented 4 years ago

@neeraj-laad I've made those changes, but accidentally added them both to the same commit: 8bab3c21c2f933b675bc566c3794608a84f7dce9. You seem to squash commits, so I won't bother dissecting the changes out.

Kamran64 commented 4 years ago

Testing on macOS and I run into this error on appsody build/appsody stack validate:

[Docker] [getting-started-1.0-SNAPSHOT-runner:291]   (features):   5,632.16 ms
[Docker] [getting-started-1.0-SNAPSHOT-runner:291]     analysis:  87,110.63 ms
[Docker] [getting-started-1.0-SNAPSHOT-runner:291]     (clinit):  22,228.39 ms
[Docker] [getting-started-1.0-SNAPSHOT-runner:291]     universe:  64,471.16 ms
[Docker] [getting-started-1.0-SNAPSHOT-runner:291]      (parse):  41,804.07 ms
[Docker] Error: Image build request failed with exit status 137
[Docker] [INFO] ------------------------------------------------------------------------
[Docker] [INFO] BUILD FAILURE
[Docker] [INFO] ------------------------------------------------------------------------
[Docker] [INFO] Total time:  06:23 min
[Docker] [INFO] Finished at: 2020-04-28T10:46:06Z
[Docker] [INFO] ------------------------------------------------------------------------
[Docker] [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.3.2.Final:native-image (default) on project getting-started: Failed to generate native image: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[Docker] [ERROR]    [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[Docker] [ERROR]    at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:353)
[Docker] [ERROR]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[Docker] [ERROR]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[Docker] [ERROR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[Docker] [ERROR]    at java.lang.reflect.Method.invoke(Method.java:498)
[Docker] [ERROR]    at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
[Docker] [ERROR]    at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
[Docker] [ERROR]    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[Docker] [ERROR]    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
[Docker] [ERROR]    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
[Docker] [ERROR]    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
[Docker] [ERROR]    at java.lang.Thread.run(Thread.java:748)
[Docker] [ERROR]    at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[Docker] [ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1
[Docker] [ERROR]    at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:369)
[Docker] [ERROR]    at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:339)
[Docker] [ERROR]    ... 12 more
[Docker] [ERROR] -> [Help 1]
paulrobinson commented 4 years ago

@Kamran64 I can't reproduce this on my machine. Do you get this behaviour also with master of this stack? Just trying to understand if it's caused by a change in this PR, or if the problem already exists.

Kamran64 commented 4 years ago

@paulrobinson - Can confirm this fails for me on master too.

ianpartridge commented 4 years ago

I can't reproduce this either, running appsody stack validate locally on macOS 10.15.4:

@@@@@@@@@@@@@@@ Validate Summary Start @@@@@@@@@@@@@@@@
PASSED: Lint for stack:quarkus
PASSED: Package for stack:quarkus
PASSED: Init for stack:quarkus template:default
PASSED: Run for stack:quarkus template:default
PASSED: Test for stack:quarkus template:default
PASSED: Build for stack:quarkus template:default
PASSED: Init for stack:quarkus template:kafka
PASSED: Run for stack:quarkus template:kafka
PASSED: Test for stack:quarkus template:kafka
PASSED: Build for stack:quarkus template:kafka
Total PASSED: 10
Total FAILED: 0
@@@@@@@@@@@@@@@  Validate Summary End  @@@@@@@@@@@@@@@@