Skip to content

Prevent newline when on continued lines - conversion issue (RUN) #77

@kmanalo

Description

@kmanalo

Expected Behavior

Dockerfile (based on an existing one from biocontainers):

# Base image
FROM ubuntu:16.04

# add apt mirror
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bkp && \
    bash -c 'echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse\n \
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse\n\
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiverse\n\
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse\n\n" > /etc/apt/sources.list' && \
    cat /etc/apt/sources.list.bkp >> /etc/apt/sources.list && \
    cat /etc/apt/sources.list

Singularity recipe I want to generate from the above is

Bootstrap: docker
From: ubuntu:16.04
%post
# Base image

# add apt mirror
mv /etc/apt/sources.list /etc/apt/sources.list.bkp && \
bash -c 'echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse\n \
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse\n\
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiverse\n\
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse\n\n" > /etc/apt/sources.list' && \
cat /etc/apt/sources.list.bkp >> /etc/apt/sources.list && \
cat /etc/apt/sources.list
%runscript
exec /bin/bash "$@"

Actual Behavior

Dockerfile generated is

Bootstrap: docker
From: ubuntu:16.04
%post
# Base image

# add apt mirror
mv /etc/apt/sources.list /etc/apt/sources.list.bkp && \
bash -c 'echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse\n \
deb
mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse\n\
deb
mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiverse\n\
deb
mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse\n\n" > /etc/apt/sources.list' && \
cat /etc/apt/sources.list.bkp >> /etc/apt/sources.list && \
cat /etc/apt/sources.list
%runscript
exec /bin/bash "$@"

Steps to Reproduce

spython recipe Dockerfile # above file

Context

  • spython version: 0.0.48
  • python version: 3.6.4

Possible Fix

I tried a few ways, but this is the simplest one based on the existing split lines method.

In docker.py :

def _setup(self, action, line):
    ''' replace the command name from the group, alert the user of content,
        and clean up empty spaces
    '''
    bot.debug('[in]  %s' % line)

    # Replace ACTION at beginning
    line = re.sub('^%s' %action, '', line)

    # Handle continuation lines not having ACTION by padding with leading space
    line = " " + line

    # Split into components
    return [x for x in self._split_line(line) if x not in ['', None]]

Also, _split_lines could be completely taken out of docker.py (since it's already in the parent class) unless there's a design reason for that. I would be happy to contribute a PR back or some guidance if you have a better idea for a solution.

BTW, I like the bug report template, thanks!

Kevin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions