Tuesday, 25 April 2017

Docker/CI: Get access to nodeJS app, which is created in another stage

In my CI pipeline there is a build and an end2end-testing stage. In the build stage the files of the application will be created. Then I want to copy the generated files to the e2e_testing container to do some tests with this application.

How do I copy the generated files (/opt/project/build/core/bundle) to the image?

My attempt

Copy the generate files to e2e_testing container with docker cp command.

build:
  stage: build
  before_script:
    - meteor build /opt/project/build/core --directory
  script:
    - cd /opt/jaqua/build/core/bundle
    - docker build -t $CI_REGISTRY_IMAGE:latest .
  after_script:
    - docker cp /opt/project/build/core/bundle e2e_testing:/opt/project/build/core/

But this is not working, as the next stage (e2e) will create a container from the e2e:latest image. So in this container there is no bundle folder existing, so this sample script is failing.

e2e:
  image: e2e:latest
  stage: e2e
  before_script:
    - cd /opt/project/build/core/bundle && ls -la
  script:
    # - run nightwatchJS to do some e2e testing with the build bundle

e2e:latest image Dockerfile

FROM java:8-jre

## Node.js setup
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN apt-get install -y nodejs

## Nightwatch
RUN npm install -g nightwatch

A container called e2e_testing is created from this image and it is running all the time. So at the time the CI pipeline is running, the container is already existing.

But at the time, this image is created the application files are not existing, as they are generated at the build stage. So I cannot put those files in the docker image using a Dockerfile.

So how can I get access to the files generated in the build stage in the e2e stage?



via user3142695

No comments:

Post a Comment