STAMP-project / camp

Amplify your Configuration tests!
https://stamp-project.github.io/camp
MIT License
10 stars 8 forks source link

CAMP realize breaks multistage Dockerfile #78

Closed fchauvel closed 5 years ago

fchauvel commented 5 years ago

Characteristics

Description

Folllowing the discussion from Issue #77 about recomposing software stacks, CAMP realize replaces every FROM statements from the Dockerfile, and therefore makes multi-stages build invalid.

Steps to reproduce

For instance, consider the java example from samples/java which we modify so that Tomcat has its own component in the camp.yml below:

 greetings:
    provides_services: [ Greetings ]
    requires_features: [ ServletContainer ]
    implementation:
      docker:
        file: greetings/Dockerfile

  tomcat:
    provides_features: [ ServletContainer ]
    requires_features: [ JRE ]
    variables:
      version:
    values: [ v7, v8, v9 ]
    realization:
         - targets: [ tomcat/Dockerfile ]
           pattern: "TOMCAT_MAJOR=7"
           replacements:
             - TOMCAT_MAJOR=7
             - TOMCAT_MAJOR=8
             - TOMCAT_MAJOR=9
         - targets: [ tomcat/Dockerfile ]
           pattern: "TOMCAT_REVISION=0.96"
           replacements:
             - TOMCAT_REVISION=0.96
             - TOMCAT_REVISION=5.46
             - TOMCAT_REVISION=0.26
    implementation:
      docker:
    file: tomcat/Dockerfile

  jre:
    provides_features: [ JRE ]
    implementation:
      docker:
    file: jre/Dockerfile

When we trigger CAMP realize, we get a wrong Dockerfile for the greetings service, which has two stages. See below, both FROM statements now points towards camp-tomcat_0, whereas only the second one should have been updated.

# Step 1: Build the WAR file                                                                                                                                                                                       
FROM camp-tomcat_0 as builder

LABEL maintainer "franck.chauvel@sintef.no"

RUN apt-get update && \
        apt-get install -y --no-install-recommends  \
        maven=3.3.9-4 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN mkdir greetings
WORKDIR /greetings

COPY . /greetings
RUN mvn clean package
RUN mv target/greetings-1.0-SNAPSHOT.war target/greetings.war

# Step 2: Deploy the WAR file into a Tomcat instance                                                                                                                                                               
FROM camp-tomcat_0

COPY --from=builder /greetings/target/greetings.war /usr/local/tomcat/webapps/greetings.war

CMD ["catalina.sh", "run"]

Other files and URLs

Relationships

Help on issue template

Preview to follow the link or open file .github/ISSUE_DOC.md