Access file variable from dockerfile

ISSUE

I have a service which works with docker, where I previously created a file type variable with scope of the environment, so in my docker file I am able to access my variable that returns the path but when I want to copy the file in my dockerfile it throws me a mistake. “/tmp/parameters.yml”: not found

HOW TO REPRODUCE

  1. Create file type variable with the key “APP_PARAMETERS_FILE”, the path “/tmp/parameters.yml” and the value
hello=world
world=hello
  1. In the dockerfile the following:
FROM php:5.6-apache as base
ARG APP_PARAMETERS_FILE
RUN echo ${APP_PARAMETERS_FILE}
COPY ${APP_PARAMETERS_FILE} ./app_parameters.yml
RUN cat ./app_parameters.yml

Hi @SalvatoreH , do you have the web console link of your app? I want to double-check how you set the environment variable.

Hi @SalvatoreH,

The build is failing because the file /tmp/parameters.yml doesn’t exist in your repository: the path of your file environment variable is injected, but not its content.

File Environment variables are usually used to use a config file for your applications (e.g grafana requires a path to override the default config)

If you want to use a file environment variable for your application, it’s your application that would need to point to the /path of your variable.

By curiosity, what was the case you wanted to achieve ?

Hello,
We have a legacy project with symfony in which it needs a yaml file where the parameters and secrets are stored per environment.

I am looking for workarounds to be able to move forward while I understand this since we are trying to migrate our service to qovery as soon as possible, even so I created the variable again and retried the deployment to share with you, hoping you can guide me.

Here is the link of my enviroment/service/deployment.

yep, here is the link of my enviroment/service/deployment.

File variables are not visible when your dockerfile is building, only the path is injected, i.e in your current deployment /tmp/parameters.yml.
Under the hood, the file variable is a secret on kubernetes side accessible through its path.

What you need to achieve is to indicate the path of your file variable to your application at runtime. This means you need to provide the path of your file variable to your underlying application at startup: you can simply remove your COPY instruction from your Dockerfile as the file will be accessible at runtime.

Ok, now I understand, so I’ll look into changing the way the application is built to remove that dependency file.

Thanks for the support!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.