Docker build vs Docker run don't behave the same - docker

I try to build a Docker image with an Archlinux base.
The problem is that I don't have the same result when building the docker image and when doing commands by hand.
$ cat Dockerfile
FROM archlinux/base
RUN pacman -Suy --noconfirm --noprogressbar
$ docker build .
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.3s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 37B done
#2 DONE 0.2s
#3 [internal] load metadata for docker.io/archlinux/base:latest
#3 DONE 0.0s
#4 [1/2] FROM docker.io/archlinux/base
#4 CACHED
#5 [2/2] RUN pacman -Suy --noconfirm --noprogressbar
#5 0.692 :: Synchronizing package databases...
#5 1.449 downloading core.db...
#5 3.139 downloading extra.db...
#5 8.344 downloading community.db...
#5 15.38 :: Starting full system upgrade...
#5 15.40 resolving dependencies...
#5 15.55 looking for conflicting packages...
#5 15.56
#5 15.56 Packages (26) archlinux-keyring-20200820-1 bash-5.0.018-1 ca-certificates-mozilla-3.56-1 curl-7.72.0-2 file-5.39-1 filesystem-2020.08.21-1 gcc-libs-10.2.0-1 glib2-2.64.5-1 glibc-2.32-3 hwids-20200813.1-1 iana-etc-20200812-1 kbd-2.3.0-2 libcap-2.42-1 libgpg-error-1.39-1 libp11-kit-0.23.21-1 libutil-linux-2.36-2 libxcrypt-4.4.17-1 linux-api-headers-5.7-1 p11-kit-0.23.21-1 pacman-mirrorlist-20200801-1 pam-1.4.0-3 pambase-20200721.1-2 sqlite-3.33.0-2 systemd-246.3-1 systemd-libs-246.3-1 util-linux-2.36-2
#5 15.56
#5 15.56 Total Download Size: 63.83 MiB
#5 15.56 Total Installed Size: 297.78 MiB
#5 15.56 Net Upgrade Size: 7.41 MiB
#5 15.56
#5 15.56 :: Proceed with installation? [Y/n]
#5 15.56 :: Retrieving packages...
#5 15.94 downloading archlinux-keyring-20200820-1-any.pkg.tar.zst...
#5 18.60 downloading linux-api-headers-5.7-1-any.pkg.tar.zst...
#5 21.09 downloading iana-etc-20200812-1-any.pkg.tar.zst...
#5 23.08 downloading filesystem-2020.08.21-1-x86_64.pkg.tar.zst...
#5 23.73 downloading glibc-2.32-3-x86_64.pkg.tar.zst...
#5 30.46 downloading gcc-libs-10.2.0-1-x86_64.pkg.tar.zst...
#5 38.65 downloading bash-5.0.018-1-x86_64.pkg.tar.zst...
#5 42.37 downloading libp11-kit-0.23.21-1-x86_64.pkg.tar.zst...
#5 44.24 downloading libcap-2.42-1-x86_64.pkg.tar.zst...
#5 44.99 downloading libgpg-error-1.39-1-x86_64.pkg.tar.zst...
#5 46.48 downloading systemd-libs-246.3-1-x86_64.pkg.tar.zst...
#5 48.72 downloading p11-kit-0.23.21-1-x86_64.pkg.tar.zst...
#5 50.07 downloading ca-certificates-mozilla-3.56-1-x86_64.pkg.tar.zst...
#5 52.28 downloading libutil-linux-2.36-2-x86_64.pkg.tar.zst...
#5 54.72 downloading curl-7.72.0-2-x86_64.pkg.tar.zst...
#5 57.60 downloading glib2-2.64.5-1-x86_64.pkg.tar.zst...
#5 60.93 downloading hwids-20200813.1-1-any.pkg.tar.zst...
#5 63.00 downloading pambase-20200721.1-2-any.pkg.tar.zst...
#5 63.38 downloading pam-1.4.0-3-x86_64.pkg.tar.zst...
#5 65.26 downloading kbd-2.3.0-2-x86_64.pkg.tar.zst...
#5 68.25 downloading pacman-mirrorlist-20200801-1-any.pkg.tar.zst...
#5 68.63 downloading sqlite-3.33.0-2-x86_64.pkg.tar.zst...
#5 72.16 downloading libxcrypt-4.4.17-1-x86_64.pkg.tar.zst...
#5 73.20 downloading file-5.39-1-x86_64.pkg.tar.zst...
#5 75.09 downloading util-linux-2.36-2-x86_64.pkg.tar.zst...
#5 79.08 downloading systemd-246.3-1-x86_64.pkg.tar.zst...
#5 85.13 checking keyring...
#5 85.28 checking package integrity...
#5 86.18 loading package files...
#5 86.21 checking for file conflicts...
#5 86.21 checking available disk space...
#5 86.23 error: Partition /etc/resolv.conf is mounted read only
#5 86.23 error: Partition /etc/hosts is mounted read only
#5 86.23 error: not enough free disk space
#5 86.23 error: failed to commit transaction (not enough free disk space)
#5 86.24 Errors occurred, no packages were upgraded.
#5 ERROR: executor failed running [/bin/sh -c pacman -Suy --noconfirm --noprogressbar]: runc did not terminate sucessfully
------
> [2/2] RUN pacman -Suy --noconfirm --noprogressbar:
------
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c pacman -Suy --noconfirm --noprogressbar]: runc did not terminate sucessfully
This fails, I don't understand why.
Same command in a fresh container:
$ docker run --rm archlinux/base pacman -Suy --noconfirm --noprogressbar
:: Synchronizing package databases...
downloading core.db...
downloading extra.db...
downloading community.db...
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...
Packages (26) archlinux-keyring-20200820-1 bash-5.0.018-1 ca-certificates-mozilla-3.56-1 curl-7.72.0-2 file-5.39-1 filesystem-2020.08.21-1 gcc-libs-10.2.0-1 glib2-2.64.5-1 glibc-2.32-3 hwids-20200813.1-1 iana-etc-20200812-1 kbd-2.3.0-2 libcap-2.42-1 libgpg-error-1.39-1 libp11-kit-0.23.21-1 libutil-linux-2.36-2 libxcrypt-4.4.17-1 linux-api-headers-5.7-1 p11-kit-0.23.21-1 pacman-mirrorlist-20200801-1 pam-1.4.0-3 pambase-20200721.1-2 sqlite-3.33.0-2 systemd-246.3-1 systemd-libs-246.3-1 util-linux-2.36-2
Total Download Size: 63.83 MiB
Total Installed Size: 297.78 MiB
Net Upgrade Size: 7.41 MiB
:: Proceed with installation? [Y/n]
:: Retrieving packages...
downloading archlinux-keyring-20200820-1-any.pkg.tar.zst...
downloading linux-api-headers-5.7-1-any.pkg.tar.zst...
downloading iana-etc-20200812-1-any.pkg.tar.zst...
downloading filesystem-2020.08.21-1-x86_64.pkg.tar.zst...
downloading glibc-2.32-3-x86_64.pkg.tar.zst...
downloading gcc-libs-10.2.0-1-x86_64.pkg.tar.zst...
downloading bash-5.0.018-1-x86_64.pkg.tar.zst...
downloading libp11-kit-0.23.21-1-x86_64.pkg.tar.zst...
downloading libcap-2.42-1-x86_64.pkg.tar.zst...
downloading libgpg-error-1.39-1-x86_64.pkg.tar.zst...
downloading systemd-libs-246.3-1-x86_64.pkg.tar.zst...
downloading p11-kit-0.23.21-1-x86_64.pkg.tar.zst...
downloading ca-certificates-mozilla-3.56-1-x86_64.pkg.tar.zst...
downloading libutil-linux-2.36-2-x86_64.pkg.tar.zst...
downloading curl-7.72.0-2-x86_64.pkg.tar.zst...
downloading glib2-2.64.5-1-x86_64.pkg.tar.zst...
downloading hwids-20200813.1-1-any.pkg.tar.zst...
downloading pambase-20200721.1-2-any.pkg.tar.zst...
downloading pam-1.4.0-3-x86_64.pkg.tar.zst...
downloading kbd-2.3.0-2-x86_64.pkg.tar.zst...
downloading pacman-mirrorlist-20200801-1-any.pkg.tar.zst...
downloading sqlite-3.33.0-2-x86_64.pkg.tar.zst...
downloading libxcrypt-4.4.17-1-x86_64.pkg.tar.zst...
downloading file-5.39-1-x86_64.pkg.tar.zst...
downloading util-linux-2.36-2-x86_64.pkg.tar.zst...
downloading systemd-246.3-1-x86_64.pkg.tar.zst...
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
checking available disk space...
:: Processing package changes...
upgrading archlinux-keyring...
==> Appending keys from archlinux.gpg...
==> Locally signing trusted keys in keyring...
-> Locally signing key D8AFDDA07A5B6EDFA7D8CCDAD6D055F927843F1C...
==> ERROR: D8AFDDA07A5B6EDFA7D8CCDAD6D055F927843F1C could not be locally signed.
-> Locally signing key DDB867B92AA789C165EEFA799B729B06A680C281...
==> ERROR: DDB867B92AA789C165EEFA799B729B06A680C281 could not be locally signed.
-> Locally signing key 91FFE0700E80619CEB73235CA88E23E377514E00...
==> ERROR: 91FFE0700E80619CEB73235CA88E23E377514E00 could not be locally signed.
-> Locally signing key 0E8B644079F599DFC1DDC3973348882F6AC6A4C2...
==> ERROR: 0E8B644079F599DFC1DDC3973348882F6AC6A4C2 could not be locally signed.
-> Locally signing key AB19265E5D7D20687D303246BA1DFB64FFF979E7...
==> ERROR: AB19265E5D7D20687D303246BA1DFB64FFF979E7 could not be locally signed.
upgrading linux-api-headers...
upgrading iana-etc...
upgrading filesystem...
upgrading glibc...
warning: /etc/locale.gen installed as /etc/locale.gen.pacnew
Generating locales...
en_US.UTF-8... done
Generation complete.
upgrading gcc-libs...
upgrading bash...
upgrading libp11-kit...
upgrading libcap...
upgrading libgpg-error...
upgrading systemd-libs...
upgrading p11-kit...
upgrading ca-certificates-mozilla...
upgrading libutil-linux...
upgrading curl...
upgrading glib2...
upgrading hwids...
upgrading pambase...
upgrading pam...
upgrading kbd...
upgrading pacman-mirrorlist...
warning: /etc/pacman.d/mirrorlist installed as /etc/pacman.d/mirrorlist.pacnew
upgrading sqlite...
installing libxcrypt...
installing file...
upgrading util-linux...
upgrading systemd...
:: Running post-transaction hooks...
( 1/11) Creating system user accounts...
( 2/11) Updating journal message catalog...
( 3/11) Reloading system manager configuration...
Skipped: Current root is not booted.
( 4/11) Updating udev hardware database...
( 5/11) Applying kernel sysctl settings...
Skipped: Current root is not booted.
( 6/11) Creating temporary files...
/usr/lib/tmpfiles.d/journal-nocow.conf:26: Failed to resolve specifier: uninitialized /etc detected, skipping
All rules containing unresolvable specifiers will be skipped.
( 7/11) Reloading device manager configuration...
Skipped: Device manager is not running.
( 8/11) Arming ConditionNeedsUpdate...
( 9/11) Rebuilding certificate stores...
(10/11) Reloading system bus configuration...
Skipped: Current root is not booted.
(11/11) Cleaning up package cache...
What is the diff between them? And how can I have a Dockerfile that works?
Thanks
PS: this is not a space problem (df -h does not show me a "Use%" close to being full)

This seems related to buildkit, as noticed by larsks. /etc/resolv.conf and /etc/hosts are mounted read-only when using buildkit. pacman seems to try to update these files, resulting in the error you see.
As a workaround, you can set the DOCKER_BUILDKIT environment variable from 1 to 0 to disable it. For example:
DOCKER_BUILDKIT=0 docker build .

Related

Rust Docker custom dependencies

Im using cargo-wharf to build my Rust project.
Cargo.toml:
# syntax = denzp/cargo-wharf-frontend:v0.1.0-alpha.2
[package]
name = "project_name"
version = "0.1.0"
edition = "2018"
[dependencies]
dep1 = {path = "../dep1", version = "0.2.0"}
...
[package.metadata.wharf.builder]
image = "clux/muslrust:nightly-2019-09-28"
target = "x86_64-unknown-linux-musl"
[package.metadata.wharf.output]
image = "scratch"
user = "root"
entrypoint = ["/usr/local/bin/project_name"]
[[package.metadata.wharf.binary]]
name = "project_name"
destination = "/usr/local/bin/project_name"
When I run docker build -f Cargo.toml . -t project_name,
this error occurs:
[+] Building 5.2s (11/11) FINISHED
=> [internal] load build definition from Cargo.toml 0.0s
=> => transferring dockerfile: 1.38kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> resolve image config for docker.io/denzp/cargo-wharf-frontend:v0.1.0-alpha.2 3.3s
=> CACHED docker-image://docker.io/denzp/cargo-wharf-frontend:v0.1.0-alpha.2#sha256:a57861317aa7ae8010927d6e000c9be523d3b78c2b42f3e5c281c8cc3328b1a0 0.0s
=> Using build context 0.0s
=> => transferring dockerfile: 6.41kB 0.0s
=> CACHED docker-image://docker.io/denzp/cargo-container-tools:v0.2.0-alpha.1 0.0s
=> => resolve docker.io/denzp/cargo-container-tools:v0.2.0-alpha.1 0.7s
=> CACHED Collecting configuration metadata 0.0s
=> Resolving builder image 0.5s
=> Using build context 0.0s
=> => transferring context: 6.41kB 0.0s
=> CACHED docker-image://docker.io/clux/muslrust:nightly-2019-09-28#sha256:05cd14b73ae42a978d67a12e099eac8f6fe61daf2a963b7f401817a246ba4948 0.0s
=> ERROR Evaluating the build plan 0.3s
------
> Evaluating the build plan:
#11 0.259 error: failed to load source for a dependency on `dep1`
#11 0.259
#11 0.259 Caused by:
#11 0.259 Unable to update /dep1
#11 0.259
#11 0.259 Caused by:
#11 0.259 failed to read `/dep1/Cargo.toml`
#11 0.259
#11 0.259 Caused by:
#11 0.259 No such file or directory (os error 2)
#11 0.259 error: Child process failed
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = Unable to evaluate the Cargo build plan => caused by: Unable to read Cargo build plan => caused by: Unable to read the file => caused by: grpc-status: Unknown, grpc-message: "executor failed running [/usr/local/bin/cargo-build-plan --manifest-path /context/Cargo.toml --output /output/build-plan.json --target x86_64-unknown-linux-musl --release]: exit code: 1"
dep1 is a custom package that is at the same level as project_name.
So it is C:\Users\me\shared_folder\project_name\Cargo.toml
and C:\Users\me\shared_folder\dep1\Cargo.toml
When running cargo run from C:\Users\me\shared_folder\project_name\Cargo.toml, everything just works fine.
I already tried:
changing edition = "2018" as I read somewhere had no impact
deleted Cargo.lock and target folder, also didn't work for me
Does anyone know how to get my program + custom dependencies running in docker?
I'm somewhat baffled that this is possible, but the solution to your problem is easy:
You'll need to include the entire shared_folder (which contains both lib1 and project_name) as build context, i.e. your build context must be .. not .. Otherwise, the dockerized builder has no way of accessing lib1.
You'll need to specify where to find your Cargo.toml since it's not in the working directory of the builder anymore. You could do that by adding a workspace Cargo.toml to shared_folder, but I think that using --build-arg manifest-path=… is easier.
In summary:
buildx build -f Cargo.toml --build-arg manifest-path=project_name/Cargo.toml ..

Kotlin/JS fails to build inside of Docker because of backslashes in package.json

I have a multi-project gradle build that I'm trying to build inside of docker. One of the projects is a Kotlin multiplatform project that builds to JVM and JS. Building the library is fine on my Windows machine, but I get an error when building from Docker.
Here is my Dockerfile (common is the multiplatform project):
FROM amazoncorretto:17-alpine-jdk
COPY . .
RUN apk add --update npm
RUN ./gradlew :common:build --no-daemon
And here is the relevant error snippet:
#10 181.5 > Task :common:jsPackageJson
#10 181.5 Cannot find build/js/packages_imported/Kotlin-DateTime-library-kotlinx-datetime-js-ir\0.4.0, rebuilding
#10 181.5 Cannot find build/js/packages_imported/kotlin\1.7.21, rebuilding
#10 181.5 Cannot find build/js/packages_imported/kotlin-test-js-runner\1.7.21, rebuilding
I can pretty clearly see that the error here is that the environment in docker doesn't recognize the \ as part of the path. I believe it works fine in my machine because Windows is ok with the backslash. I don't have access to a linux or macOS machine, so I can't check if package.json is created with forward or back slashes there. How do I get my project to build in docker?
./gradlew -v:
------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------
Build time: 2022-08-05 21:17:56 UTC
Revision: d1daa0cbf1a0103000b71484e1dbfe096e095918
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.5 (Eclipse Adoptium 17.0.5+8)
OS: Windows 10 10.0 amd64
Full Docker error:
[+] Building 194.7s (11/11) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 341B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/amazoncorretto:17-alpine-jdk 0.5s
=> [auth] library/amazoncorretto:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.7s
=> => transferring context: 729.48kB 0.7s
=> CACHED [1/6] FROM docker.io/library/amazoncorretto:17-alpine-jdk#sha256:55910135e17f0cbde36944c00fa327dc350cdc3f71bc3b150bb0950a116990c3 0.0s
=> [2/6] COPY . . 1.5s
=> [3/6] RUN apk add --update npm 7.1s
=> [4/6] WORKDIR web 0.0s
=> [5/6] RUN npm install 1.7s
=> ERROR [6/6] RUN ../gradlew :common:build --no-daemon 183.1s
------
> [6/6] RUN ../gradlew :common:build --no-daemon:
#10 0.602 Downloading https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
#10 1.360 ...........10%............20%...........30%............40%...........50%............60%...........70%............80%...........90%............100%
#10 9.081
#10 9.081 Welcome to Gradle 7.5.1!
#10 9.081
#10 9.081 Here are the highlights of this release:
#10 9.082 - Support for Java 18
#10 9.082 - Support for building with Groovy 4
#10 9.082 - Much more responsive continuous builds
#10 9.083 - Improved diagnostics for dependency resolution
#10 9.083
#10 9.083 For more details see https://docs.gradle.org/7.5.1/release-notes.html
#10 9.084
#10 9.280 To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.5.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
#10 10.78 Daemon will be stopped at the end of the build
#10 91.19 > Task :buildSrc:generateExternalPluginSpecBuilders
#10 91.19 > Task :buildSrc:extractPrecompiledScriptPluginPlugins
#10 93.58 > Task :buildSrc:compilePluginsBlocks
#10 110.6 > Task :buildSrc:generatePrecompiledScriptPluginAccessors
#10 110.6 > Task :buildSrc:generateScriptPluginAdapters
#10 113.9 > Task :buildSrc:pluginDescriptors
#10 113.9 > Task :buildSrc:processResources
#10 113.9 > Task :buildSrc:processTestResources NO-SOURCE
#10 137.6 > Task :buildSrc:compileKotlin
#10 137.6 > Task :buildSrc:compileJava NO-SOURCE
#10 137.6 > Task :buildSrc:compileGroovy NO-SOURCE
#10 137.6 > Task :buildSrc:classes
#10 137.7 > Task :buildSrc:inspectClassesForKotlinIC
#10 137.8 > Task :buildSrc:jar
#10 137.8 > Task :buildSrc:assemble
#10 137.9 > Task :buildSrc:compileTestKotlin NO-SOURCE
#10 137.9 > Task :buildSrc:pluginUnderTestMetadata
#10 137.9 > Task :buildSrc:compileTestJava NO-SOURCE
#10 137.9 > Task :buildSrc:compileTestGroovy NO-SOURCE
#10 137.9 > Task :buildSrc:testClasses UP-TO-DATE
#10 137.9 > Task :buildSrc:test NO-SOURCE
#10 138.1 > Task :buildSrc:validatePlugins
#10 138.1 > Task :buildSrc:check
#10 138.1 > Task :buildSrc:build
#10 169.0 > Task :common:transformCommonMainDependenciesMetadata
#10 171.5 > Task :common:generateProjectStructureMetadata
#10 181.2 > Task :kotlinNodeJsSetup
#10 181.2 > Task :kotlinNpmCachesSetup
#10 181.2 > Task :kotlinRestoreYarnLock
#10 181.3 > Task :kotlinYarnSetup
#10 181.5
#10 181.5 > Task :common:jsPackageJson
#10 181.5 Cannot find build/js/packages_imported/Kotlin-DateTime-library-kotlinx-datetime-js-ir\0.4.0, rebuilding
#10 181.5 Cannot find build/js/packages_imported/kotlin\1.7.21, rebuilding
#10 181.5 Cannot find build/js/packages_imported/kotlin-test-js-runner\1.7.21, rebuilding
#10 181.6
#10 181.6 > Task :common:jsTestPackageJson
#10 181.6 > Task :packageJsonUmbrella
#10 181.6 > Task :rootPackageJson
#10 181.6 > Task :kotlinNpmInstall FAILED
#10 182.1 > Task :common:compileCommonMainKotlinMetadata
#10 182.1
#10 182.1 FAILURE: Build completed with 2 failures.
#10 182.1
#10 182.1 1: Task failed with an exception.
#10 182.1 -----------
#10 182.1 * What went wrong:
#10 182.1 Execution failed for task ':kotlinNpmInstall'.
#10 182.1 > A problem occurred starting process 'command '/root/.gradle/nodejs/node-v16.13.0-linux-x64/bin/node''
#10 182.1
#10 182.1 * Try:
#10 182.1 > Run with --stacktrace option to get the stack trace.
#10 182.1 > Run with --info or --debug option to get more log output.
#10 182.1 > Run with --scan to get full insights.
#10 182.1 ==============================================================================
#10 182.1
#10 182.1 2: Task failed with an exception.
#10 182.1 -----------
#10 182.1 * What went wrong:
#10 182.1 java.lang.StackOverflowError (no error message)
#10 182.1
#10 182.1 * Try:
#10 182.1 > Run with --stacktrace option to get the stack trace.
#10 182.1 > Run with --info or --debug option to get more log output.
#10 182.1
#10 182.1 Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
#10 182.1
#10 182.1 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
#10 182.1
#10 182.1 See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings> Run with --scan to get full insights.
#10 182.1 ==============================================================================
#10 182.1
#10 182.1 * Get more help at https://help.gradle.org
#10 182.1
#10 182.1
#10 182.1 BUILD FAILED in 3m 1s
#10 182.1 23 actionable tasks: 23 executed
------
executor failed running [/bin/sh -c ../gradlew :common:build --no-daemon]: exit code: 1
Here is build/js/package.json (auto generated by the Kotlin/JS compiler):
{
"name": "my-app",
"version": "0.0.1",
"private": true,
"workspaces": [
"packages\\my-app-common",
"packages\\my-app-common-test",
"packages_imported\\Kotlin-DateTime-library-kotlinx-datetime-js-ir\\0.4.0",
"packages_imported\\kotlin\\1.7.21",
"packages_imported\\kotlin-test-js-runner\\1.7.21"
],
"resolutions": {},
"devDependencies": {},
"dependencies": {},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
The build/ folders were being copied over, so the backslashes in the package.json files built on my local machine were not being overwritten. Just adding **/build/ to my .dockerignore fixed it.
This gave me another problem:
> A problem occurred starting process 'command '/root/.gradle/nodejs/node-v16.13.0-linux-x64/bin/node''
After some troubleshooting turns out I wasn't installing nodejs properly. Here is my final fixed Dockerfile where I install gradle nodejs and corretto properly and use them to build:
FROM node:lts as nodejs
FROM gradle:7.6-jdk17
COPY --from=nodejs . .
COPY . .
RUN gradle clean build
ENTRYPOINT ["gradle", ":server:run"]

docker gradle java windows git build local dependency projects best practise

I have 1 gradle java Project-A that depends on 2 other gradle java Project-B and also Project-C. All 3 projects build locally using build.gradle and Project-A build.gradle contains:
implementation project(':Project-B')
implementation project(':Project-C')
and Project A settings.gradle contains:
include ':Project-B'
project(':Project-B').projectDir = new File(settingsDir, '../Project-B')
include ':Project-C'
project(':Project-C').projectDir = new File(settingsDir, '../Project-C')
All 3 projects have separate private Git repo (because in future other projects depend on B and C).
So that's fine. Now I want to dockerise project-A. Its Dockerfile is:
FROM gradle:jdk11-alpine AS builder
COPY ./ ./
RUN gradle build
FROM adoptopenjdk/openjdk11:jre-11.0.6_10-alpine
COPY --from=builder *.jar Project-A.jar
CMD ["java -jar Project-A.jar"]
The docker build . for Project-A is giving an error:
#11 51.17 FAILURE: Build failed with an exception.
#11 51.17
#11 51.17 * What went wrong:
#11 51.17 Could not determine the dependencies of task ':bootJar'.
#11 51.17 > Could not resolve all task dependencies for configuration ':runtimeClasspath'.
#11 51.17 > Could not resolve project :project-B.
#11 51.17 Required by:
#11 51.17 project :
#11 51.17 > No matching configuration of project :project-B was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
#11 51.17 - None of the consumable configurations have attributes.
#11 51.17 > Could not resolve project :project-C.
#11 51.17 Required by:
#11 51.18 project :
#11 51.18 > No matching configuration of project :project-C was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
#11 51.18 - None of the consumable configurations have attributes.
So, what's best practise to get a Dockerfile to build Project-B and Project-C ? i.e. the respective jar aren't published anywhere else and have to be built along with Project-A
The bootJar task is merely:
bootJar {
archiveBaseName = 'Project-A'
archiveVersion = '0.1.0'
}
Basically, a locally run gradle build can resolve the underlying projects, but a locally run docker build . cannot. What COPY step am I missing?

Puppeteer and Docker for Mac (Apple M1)

Chromium is crashing when opened via puppeteer navigation with the following stack trace on my M1. I'm looking for some help from the community as non m1 based machines don't seem to have an issue with our puppeteer container.
[0613/204124.018517:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
[0613/204124.746267:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
[0613/204124.751355:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
[0613/204124.981155:FATAL:nacl_helper_linux.cc(440)] Check failed: nacl_sandbox->IsSingleThreaded().
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[130:130:0613/204125.140482:FATAL:zygote_main_linux.cc(162)] Check failed: sandbox::ThreadHelpers::IsSingleThreaded().
#0 0x0040072b9339 <unknown>
#1 0x00400722ff23 <unknown>
#2 0x00400722d070 <unknown>
#3 0x00400722dc6e <unknown>
#4 0x004006dae926 <unknown>
#5 0x004006da973e <unknown>
#6 0x004006daa369 <unknown>
#7 0x004006dab0cb <unknown>
#8 0x004006da838e <unknown>
#9 0x004006da8d4e <unknown>
#10 0x0040036e1227 <unknown>
#11 0x00400faba0b3 <unknown>
#12 0x0040036e102a <unknown>
Crash keys:
"switch-7" = "--enable-crashpad"
"switch-6" = "--change-stack-guard-on-fork=enable"
"switch-5" = "--user-data-dir=/tmp/puppeteer_dev_chrome_profile-5BphEe"
"switch-4" = "--enable-crash-reporter=,"
"switch-3" = "--crashpad-handler-pid=117"
"switch-2" = "--enable-crashpad"
"switch-1" = "--no-sandbox"
"num-switches" = "8"
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[112:138:0613/204125.830241:ERROR:file_path_watcher_inotify.cc(329)] inotify_init() failed: Function not implemented (38)
[0613/204125.946536:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Function not implemented (38)
Assertion failed: p_rcu_reader->depth != 0 (/qemu/include/qemu/rcu.h: rcu_read_unlock: 101)
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
Error scraping url: <my - url>:
Error: Unable to launch chrome
I'm launching puppeteer with the following options:
const args = [
'--no-first-run',
'--no-sandbox',
'--disable-setuid-sandbox',
'--single-process',
'--disable-dev-shm-usage',
'--ignore-certificate-errors',
'--ignore-urlfetcher-cert-requests',
'--disable-blink-features=AutomationControlled'
];
And I'm installing chromium into by ubuntu based container via:
# Install Chrome for Ubuntu
RUN apt-get update \
&& apt-get install -y chromium-browser
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium
Spent all day trying to fix it. In the end running docker with colima solved the issue. The thing is that some stuff simply will not work on arm and there is no point in fighting it. Colima allows you to run everything via Rosetta, hence emulating x86 all the way.
First install colima with brew install colima.
Shut down docker desktop if it's running.
Start colima with colima start --arch aarch64 --vm-type=vz (check readme for more info)
Now you have docker running fully via Rossetta. When running images, use "--platform linux/amd64".

Errors installing vue/cliapp under docker

I want to install my #vue/cli 4.0.5 app under docker and using https://medium.com/#jwdobken/vue-with-docker-initialize-develop-and-build-51fad21ad5e6 link :
I modified the command line : modified node source from 11-alpine and renamed project name and installed the project, but running command
yarn serve
I got error that serve was not found :
me#athoe:/mnt/_work_sdb8/wwwroot/lar/VApps/DOCKER_TEST$ mkdir vtaskproject && cd "$_" && docker run --rm -v "${PWD}:/$(basename `pwd`)" -w "/$(basename `pwd`)" -it node:11-alpine sh -c "yarn global add #vue/cli && vue create ."
Unable to find image 'node:11-alpine' locally
11-alpine: Pulling from library/node
e7c96db7181b: Already exists
0119aca44649: Pull complete
40df19605a18: Pull complete
82194b8b4a64: Pull complete
Digest: sha256:8bb56bab197299c8ff820f1a55462890caf08f57ffe3b91f5fa6945a4d505932
Status: Downloaded newer image for node:11-alpine
yarn global v1.15.2
[1/4] Resolving packages...
warning #vue/cli > #vue/cli-ui > vue-cli-plugin-apollo > apollo > git-parse > babel-polyfill > core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
warning #vue/cli > #vue/cli-ui > vue-cli-plugin-apollo > apollo > git-parse > babel-polyfill > babel-runtime > core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
[2/4] Fetching packages...
info fsevents#1.2.11: The platform "linux" is incompatible with this module.
info "fsevents#1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Your current version of Yarn is out of date. The latest version is "1.21.1", while you're on "1.15.2".
info To upgrade, run the following command:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
success Installed "#vue/cli#4.1.1" with binaries:
- vue
Done in 32.17s.
? Your connection to the default yarn registry seems to be slow.
Use https://registry.npm.taobao.org for faster installation? Yes
Vue CLI v4.1.1
? Generate project in current directory? Yes
Vue CLI v4.1.1
? Please pick a preset: default (babel, eslint)
? Pick the package manager to use when installing dependencies: Yarn
Vue CLI v4.1.1
��� Creating project in /vtaskproject.
��� Installing CLI plugins. This might take a while...
yarn install v1.15.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.11: The platform "linux" is incompatible with this module.
info "fsevents#1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
success Saved lockfile.
Done in 77.43s.
���� Invoking generators...
���� Installing additional dependencies...
yarn install v1.15.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.11: The platform "linux" is incompatible with this module.
info "fsevents#1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 24.82s.
��� Running completion hooks...
���� Generating README.md...
���� Successfully created project vtaskproject.
���� Get started with the following commands:
$ yarn serve
me#athoe:/mnt/_work_sdb8/wwwroot/lar/VApps/DOCKER_TEST/vtaskproject$ yarn serve
00h00m00s 0/0: : ERROR: [Errno 2] No such file or directory: 'serve'
serge#athoe:/mnt/_work_sdb8/wwwroot/lar/VApps/DOCKER_TEST/vtaskproject$ yarn --version
0.32
I see that on successfull installation newly created project dir was selected.
Also in the provided article next was :
Dockerfile The Dockerfile is identical to the given example in the
documentation. Only the build-stage is split up into an install-stage
and a build-stage, since we don’t need to build when we are
developing!
But the thin is I do not see any Dockerfile file in the created project : https://imgur.com/a/mKrdFgi as I expected.
Had Dockerfile be there and how move next ?
$ lsb_release -d; uname -r; uname -i
Description: Ubuntu 18.04.3 LTS
4.15.0-72-generic
x86_64
$ docker --version
Docker version 19.03.5, build 633a0ea838

Resources