Docker Community Forums

Share and learn in the Docker community.

Using Docker image being built in docker-compose.test.yml

ci
testing
dockercloud

(Pkr2) #1

I am trying to use the image being built to add the required test setup in order to run my tests.

But no matter what I try, using IMAGE_NAME or CACHE_TAG doesn’t result in a correct build.
It is definitely working on my localhost

docker build . -t local:local
IMAGE_NAME=local:local CACHE_TAG=3d860f364c40 docker-compose -f docker-compose.test.yml  run  --rm sut

Is this setup even possible on docker cloud?

Here is my docker-compose.test.yml file

version: '3.2'
services:
  sut:
    build:
      context: .
      cache_from: ${CACHE_TAG}
      dockerfile: Dockerfile.test
      args:
        IMAGE_NAME: ${IMAGE_NAME}

And here is my Dockerfile.test

ARG IMAGE_NAME
FROM $IMAGE_NAME
ENV NODE_ENV test
RUN cd /app && npm install --dev
COPY ./test /app/test
CMD ["npm", "test"]

(Think) #2

how about docker-compose build? and probably also describe your sut environment within an docker-compose-testing.yml?


#3

CACHE_TAG appears to be empty here using a simple auto-build configured on Docker Hub.