-
Notifications
You must be signed in to change notification settings - Fork 645
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
Make --config
from buildx command string generation optional
#1673
Conversation
ok, let me fix also the tests |
Codecov Report
@@ Coverage Diff @@
## master #1673 +/- ##
============================================
+ Coverage 64.29% 64.34% +0.04%
- Complexity 2223 2225 +2
============================================
Files 172 172
Lines 10053 10059 +6
Branches 1381 1382 +1
============================================
+ Hits 6464 6472 +8
+ Misses 3051 3050 -1
+ Partials 538 537 -1
|
Kudos, SonarCloud Quality Gate passed! |
@chonton : polite ping, Could you please review this PR whenever you get some time? |
With this change, you are no longer isolated from the build environment. The docker configs for the current user are being used and changed. The problems that this code change fixes could also probably be fixed by updating your docker and docker buildx to more recent version. |
hi @chonton, i think i'm on the latest DockerDesktop version (Docker version 24.0.2, build cb74dfc) and therefor on buildX Version github.com/docker/buildx v0.10.5 86bdced7766639d56baa4c7c449a4f6468490f87. i would very much appreciate the PR-merge, this would be a great improvement to my build pipeline when providing multiarch images with no extra effort. thanks in advance. |
@arauchberger : Did you get some time to test this PR out? I think instead of dropping config straight away maybe we should do it conditionally (either only apply it if it's present or enable it via some flag) |
@@ -63,7 +63,7 @@ protected <C> void useBuilder(ProjectPaths projectPaths, ImageConfiguration imag | |||
BuildDirs buildDirs = new BuildDirs(projectPaths, imageConfig.getName()); | |||
|
|||
Path configPath = getDockerStateDir(imageConfig.getBuildConfiguration(), buildDirs); | |||
List<String> buildX = Arrays.asList("docker", "--config", configPath.toString(), "buildx"); | |||
List<String> buildX = Arrays.asList("docker", "buildx"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robfrank : Sorry for the late reply, what was the value of configPath
when you were debugging this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me it was : --config <path_to_my_git_repo>/product-pitdata/target/docker/index.docker.io/pineit/at.pineit.pitdata/latest/docker
for @robfrank i think it was: --config /<long path>/docker-maven-plugin/samples/multi-architecture/target/docker/hello/multiarch/0.43-SNAPSHOT/docker
I did test locally and it works fine. |
Hey folks, I'm not sure if this plugin related bug created the issue in docker/for-mac#6928 project. |
@rohanKanojia @chonton I haven't followed the issue closely, but it looks like folks have problems by being forced to provide a configuration. It looks like that authentication information is still looked up in the private config directory managed via |
Will prioritize this for next release. |
remove --config from command string generation add --node option to buildx command Signed-off-by: Roberto.Franchini <ro.franchini@gmail.com>
cdb7adf
to
8fa1ee2
Compare
…empty Signed-off-by: Rohan Kumar <rohaan@redhat.com>
8fa1ee2
to
0e7fd07
Compare
Kudos, SonarCloud Quality Gate passed! |
--config
from buildx command string generation optional
Folks i think we mixed here several issues one related to docker desktop for |
@amizurov : Are you using v0.43.2 in your production pipeline? I just released it this morning. I think the change should not be breaking. It would only add |
No, we use previous versions 0.43.0 and 0.43.1. I'll checked new version as well.I also hope that this not break our builds, but i'm wondering some changes look strange (e.g. "--node", builderName + "0" what happens if docker team changes the naming of nodes, why we need set this name ?) |
@amizurov : You're right.Rather than hardcoding it, it should be picked up from a field in BuildXConfiguration |
@rohanKanojia Thanks a lot, looks like everything works properly in our case (with 0.43.3). |
hi, many thanks |
folks I do have error for our private registry when using buildx @arauchberger what should I do in the configuration of the plugin in pom.xml to make that plugin not add --config ? List buildX = new ArrayList<>(Arrays.asList(DOCKER, "--config", configPath.toString(), "buildx")); |
Hi @oktayderman, i'm currently using this version of the plugin <plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.45.1</version>
</plugin> and this setup <plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<images>
<image>
<name>${docker.image.name}:%l</name>
<alias>${docker.image.alias}</alias>
<build>
<tags>
<tag>${docker.image.tag}</tag>
<tag>${docker.image.tag2}</tag>
</tags>
<contextDir>${project.basedir}</contextDir>
<dockerFile>${docker.dockerfile}</dockerFile>
<args>
<!-- used as Labels in dockerfile -->
<buildAppDesc>${project.description}</buildAppDesc>
<buildAppName>${project.artifactId}</buildAppName>
<buildBranch>${git.branch}</buildBranch>
<buildCommitId>${git.commit.id.abbrev}</buildCommitId>
<buildDate>${maven.build.timestamp}</buildDate>
<buildHost>${git.build.host}</buildHost>
<buildLic>${license.name}, ${license.url}</buildLic>
<buildOrg>${project.organization.name}, ${project.organization.url}</buildOrg>
<buildOrgDev>${organization.developer}</buildOrgDev>
</args>
<buildx>
<platforms>
<!-- linux/amd64,linux/arm64 -->
<platform>${docker.platforms}</platform>
</platforms>
</buildx>
</build>
</image>
</images>
<retries>3</retries>
</configuration>
<executions>
<execution>
<id>docker-build</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>docker-push</id>
<phase>deploy</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin> everything is working as expected now. |
Hi arauchberger [INFO] DOCKER> docker --config /myData/dev/projects/fizz-source/AOM/aom-parent/aomif/target/docker/aomif2/docker buildx build --progress=plain --builder maven --platform linux/amd64 --tag aomif2:latest --tag aomif2:latest --tag aomif2:20.0-SNAPSHOT --build-arg buildAppDesc=aomif --build-arg buildAppName=aomif --build-arg buildDate=06.12.2024_09:53:30 --build-arg buildOrg=${project.organization.name}, ${project.organization.url} --file=/myData/dev/projects/fizz-source/AOM/aom-parent/aomif/target/docker/aomif2/tmp/docker-build/Dockerfile /myData/dev/projects/fizz-source/AOM/aom-parent/aomif/target/docker/aomif2/tmp/docker-build --load |
here is my Dockerfile. the storage thing is that i do not/no longer see the line with the docker command (as you just posted) in my output, even though i have set verbose=true for the plugin 🤷♂️ #####################################
# first stage
#
# package a minimal JRE
#####################################
FROM alpine AS packager
# install openjdk
RUN apk --no-cache add openjdk11-jdk openjdk11-jmods
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
# echo jdk version
RUN { \
echo "OpenJDK Version: $($JAVA_HOME/bin/java --version)" ; \
}
ENV JAVA_MINIMAL=/opt/jre
# build modules distribution
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules \
jdk.management.agent,java.base,java.net.http,java.sql,java.naming,java.desktop,java.xml,jdk.crypto.cryptoki,jdk.unsupported,java.management,java.security.jgss \
--compress 2 \
--strip-debug \
--no-header-files \
--no-man-pages \
--output "$JAVA_MINIMAL"
#####################################
# Second stage
#
# adding the minimal "JRE" distr from the first stage
# setup pineIT-Env and copy the application to the image
#####################################
FROM alpine
# Buildtime arguments to be overwritten while building with 'docker build --build-arg ARG=VAL '
ARG port=8904
# Buildtime arguments provided by maven bpl3 build routine
ARG buildAppName
ARG buildAppDesc
ARG buildBranch
ARG buildCommitId
ARG buildDate
ARG buildHost
ARG buildLic
ARG buildOrg
ARG buildOrgDev
ARG buildOS
ARG buildScmUrl
ARG buildTag
# Labels pineit
LABEL at.pineit.bpl3.build.branch=${buildBranch}
LABEL at.pineit.bpl3.build.host=${buildHost}
LABEL at.pineit.bpl3.build.os=${buildOS}
LABEL at.pineit.bpl3.build.tag=${buildTag}
# Lables OCI
LABEL org.opencontainers.image.authors=${buildOrgDev}
LABEL org.opencontainers.image.created=${buildDate}
LABEL org.opencontainers.image.description=${buildAppDesc}
LABEL org.opencontainers.image.licenses=${buildLic}
LABEL org.opencontainers.image.revision=${buildCommitId}
LABEL org.opencontainers.image.source=${buildScmUrl}
LABEL org.opencontainers.image.title=${buildAppName}
LABEL org.opencontainers.image.url=${buildScmUrl}
LABEL org.opencontainers.image.vendor=${buildOrg}
# Runtime environment for JRE
ENV JAVA_MINIMAL=/opt/jre
ENV PATH="$PATH:$JAVA_MINIMAL/bin"
# Runtime environment for pineIT
ENV PINEIT_HOME=/opt/pineit
ENV PINEIT_LIB_DIR=${PINEIT_HOME}/lib
ENV PINEIT_APP_MAIN="at.pineit.product.main.PineApp"
# Runtime environment for healthcheck
ENV HC_URL=http://localhost:${port}/pineit/${buildAppName}/healthz/ready
# Runtime environment to be overwritten via docker compose and k8s
ENV PCC_LOGBACKFILE=${PINEIT_HOME}/conf/${buildAppName}/logback.xml
ENV PCC_JAVA_OPTS="-Xms128M -Xmx128M"
# install some utils
RUN apk --no-cache add curl iputils
# Copy the minimal-java to image
COPY --from=packager "$JAVA_MINIMAL" "$JAVA_MINIMAL"
# create app directories
RUN mkdir -p ${PINEIT_LIB_DIR} && chgrp -R 0 ${PINEIT_HOME} && chmod -R g=u ${PINEIT_HOME}
# Copy all dependencies to the image
COPY /target/dependency/* ${PINEIT_LIB_DIR}/
# Expose some ports to the "outer rim"
EXPOSE ${port}
# Set working directory
WORKDIR ${PINEIT_HOME}
# Execute Java Main
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["java $PCC_JAVA_OPTS -cp \"${PINEIT_LIB_DIR}/*\" -Dlogback.configurationFile=${PCC_LOGBACKFILE} ${PINEIT_APP_MAIN} $PCC_MAIN_ARGS"] |
thx for the dockerfile you don't use a private registry so there will be no problem I opened an issue for this. |
I have resolved the problem by the reference of this issue: docker/buildx#2239
|
As per this comment:
#1583 (comment)
removing the "--config" let the sample project "multi-architecture" to build fine