What happens if my built image needs artifactory permissions to download mvn packages

Im using a private artifactory with all my blobs and when my Dockerimage builds, it fails because it has no permissions to download them with maven.

In the build section of the Okteto Manifest there is an option to add secrets to your built image.

It is called secrets , and you can set there the ENVs that will be used inside the image:

build:
  frontend:
    context: frontend
    dockerfile: Dockerfile
    secrets:
      mysecret: mysecret

This secret will be mount into the image (see Dockerfile sample)

Define the ENVs you are using in the Okteto Admin Panel as Admin vars.

USER
PASSWORD

There are two ways to use them after this:

  1. Mount as secret the full settings.xml file using the ENVs added in the Admin Panel

settings.xml:

<servers>
 <server>
   <username>${USER}</username>
   <password>${PASSWORD}</password>
 </server>
</servers>

Okteto Manifest:

build:
  frontend:
    context: frontend
    dockerfile: Dockerfile
    secrets:
      settings: settings.xml

Dockerfile:

RUN --mount=type=secret,id=settings,target=/etc/secrets/settings.xml (mvn command using this settings)

And then just run your maven command using the file mounted, and it should connect to your server.

  1. Add the instruction itself to the secret file and RUN it in the Dockerfile

secret_file:

mvn deploy -DaltReleaseDeploymentRepository=myrepo::https://$USER:$PASSWORD@server/repo 

Okteto Manifest:

build:
  frontend:
    context: frontend
    dockerfile: Dockerfile
    secrets:
      secret_file: secret_file

Dockerfile:

RUN --mount=type=secret,id=secret_file,target=/etc/secrets/secret_filecat $(cat /etc/secrets/secret_file)

If you need more help with maven configuration: How to pass Maven settings via environment vars - Stack Overflow