How can I make environment variables available during Docker build for a Rails 7 app with MRSK?

I'm trying to build and deploy a rails 7 app with MRSK. The docker build process needs different environment variables for bundling gems, installing yarn packages, etc.

My deploy.yml contains following information:

env:
  secret:
    - GITLAB_TOKEN

builder:
  secrets:
    - GITLAB_TOKEN
  args:
    RUBY_VERSION: 3.2.2
  multiarch: false

The .env-file:

GITLAB_TOKEN='test'

In my Dockerfile I've tried following:

RUN echo  "$GITLAB_TOKEN"

RUN --mount=type=secret,id=GITLAB_TOKEN
RUN cat /run/secrets/GITLAB_TOKEN

But the environment is in both cases empty.


I've found a workaround by using args instead of environments in the deploy.yml:

builder:
  args:
    GITLAB_TOKEN: "<%= ENV['GITLAB_TOKEN'] %>"

But args are not masked secret and using erb-text in a yml-file seems very ugly. This also may not work for non rails-applications.



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation