spring-bootdockergitlabwildflyeclipse-temurin

Unable to add WAR-File from CURL to Wildfly Docker image


My goal was to build the WAR of my Spring Boot Application via CI, push the artifact, and retrieve that artifact in a Dockerfile to deploy it using a Wildfly Application Server docker image.

I assume that I can successfully download my artifact, but I can't work with it.

If I try to add my desired *.war to the needed location, I'm getting the following error message:

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 6ca667ce-973a-43e8-ace1-7726e3ff5494::5prlk6x1gkvbg6ouee6nwxq24: "/artifacts.zip/build/libs/ccbackend.war": not found

This is the Dockerfile I wrote to deploy the artifact.

FROM quay.io/wildfly/wildfly
ARG STANDALONE=standalone.xml
COPY ${STANDALONE} /opt/jboss/wildfly/standalone/configuration/
WORKDIR /opt/jboss/wildfly/standalone/deployments/
RUN curl -L -o artifacts.zip https://gitlab.com/api/v4/projects/MYPROJECTID/jobs/artifacts/main/download?job=build
ARG WAR_FILE=artifacts.zip/build/libs/ccbackend.war
ADD ${WAR_FILE} .

I thought I was maybe making a mistake by setting the WAR_FILE to artifacts.zip, so I tried replacing it with:

artifacts/build/libs/ccbackend.war

Unfortunately without success. Lastly I thought unzipping my artifact could help me out. Therefore I tried unsuccessfully to install unzip via microdnf, which is not available in the eclipse-temurin image which Wildfly is using.

No I'm clueless what I really should do or what I maybe did wrong.


Solution

  • the problem is that the default user jboss doesnt have sufficient rights.

    Change Dockerfile as follows:

    FROM quay.io/wildfly/wildfly
    ARG STANDALONE=standalone.xml
    COPY ${STANDALONE} /opt/jboss/wildfly/standalone/configuration/
    WORKDIR /opt/jboss/wildfly/standalone/deployments/
    RUN curl -L -o artifacts.zip https://gitlab.com/api/v4/projects/MYPROJECTID/jobs/artifacts/main/download?job=build
    
    # change the user to root
    USER root 
    RUN microdnf install unzip -y
    # change the user back to jboss
    USER jboss
    
    RUN unzip artifacts.zip
    ARG WAR_FILE=artifacts/build/libs/ccbackend.war
    ADD ${WAR_FILE} .