Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENV directive ignored when converting Dockerfile to Singularity def #223

Open
d3v-null opened this issue Aug 21, 2024 · 1 comment
Open

Comments

@d3v-null
Copy link

Expected Behavior

A Dockerfile converted to a Singularity def should respect the ENV directives.

Actual Behavior

Steps to Reproduce

I have a Dockerfile that uses an ENV directive.

FROM ubuntu:20.04 as base

ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && \
    apt-get install -y tzdata
> docker build -f Dockerfile .

#5 14.16 Setting up tzdata (2024a-0ubuntu0.20.04.1) ...
#5 14.19 
#5 14.19 Current default time zone: 'Etc/UTC'
#5 14.19 Local time is now:      Wed Aug 21 01:48:43 UTC 2024.
#5 14.19 Universal Time is now:  Wed Aug 21 01:48:43 UTC 2024.

When I convert that to a singularity def, it looks like this.

> spython recipe Dockerfile | tee Singularity.def

Bootstrap: docker
From: ubuntu:20.04 
Stage: base

%post

DEBIAN_FRONTEND="noninteractive"
apt-get update && apt-get install -y tzdata
%environment
export DEBIAN_FRONTEND="noninteractive"
%runscript
exec /bin/bash "$@"
%startscript
exec /bin/bash "$@"

Separate issue but I find that I need to manually update Bootstrap to get it working.

sed -i'' 's!Bootstrap: docker!Bootstrap: library!' Singularity.def

Anyway when I build that def, DEBIAN_FRONTEND is not seen by apt-get because it's not exported.

Setting up tzdata (2024a-0ubuntu0.20.04.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 

export DEBIAN_FRONTEND="noninteractive" fixes this.

Why doesn't the conversion tool export ENV directives in the singularity def?

Context

[provide more detailed introduction to the issue itself . This is for make a reproducible issue.]

  • Operating System: macOS Sonoma 14.5 (M2)
  • singularity version: N/A
  • spython version: 0.3.13
  • python version: 3.12.4

Failure Logs

N/A

Possible Fix

export variables defined as ENV

@vsoch
Copy link
Member

vsoch commented Aug 21, 2024

An ENV is converted to the environment section, which we see:

%environment
export DEBIAN_FRONTEND="noninteractive"

If you want the envar to appear in the run command, you could put it there. Do you have a suggestion for how to disambiguate between build and runtime envars? The above is the default because there is no distinction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants