How to use a war file from Artifactory on a Dockerfile in a GitHub repository

3.9k Views Asked by At

I need help to build the CI pipeline to build only docker-image and push it to docker hub(all are private repository.

My requirement is: On the GitHub repository, I have a Docker file like the below:

FROM tomcat:alpine
COPY snoop.war /opt/tomcat/tomcat1/webapps/
EXPOSE 8443
CMD /usr/local/tomcat/bin/cataline.bat run

In the above Dockerfile, instead of "snoop.war", I wanted to get the war file from the "jfrog" Artifactory location directly, since I cannot upload the war file into the GitHub repository due to security policies.

The expected Dockerfile should be:

FROM tomcat:alpine
COPY https://internal-jfrog-artifacts/war_file/mw_snapshots/snoop.war 
/opt/tomcat/tomcat1/webapps/
EXPOSE 8443
CMD /usr/local/tomcat/bin/cataline.bat run
1

There are 1 best solutions below

3
On BEST ANSWER

You need to download the file first. Try build with below Dockerfile.

FROM tomcat:alpine
RUN apk add curl --no-cache \
    && mkdir -p /opt/tomcat/tomcat1/webapps \
    && curl -fsSL -o /opt/tomcat/tomcat1/webapps/snoop.war https://internal-jfrog-artifacts/war_file/mw_snapshots/snoop.war
EXPOSE 8443
CMD /usr/local/tomcat/bin/cataline.bat run