# Copyright 2022 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Dockerfile for building the source code of conformance tests
FROM golang:1.17.6-alpine3.15 as builder

RUN apk update && apk upgrade && \
    apk add --no-cache bash git openssh gcc musl-dev

WORKDIR /go/src/github.com/kubeflow/pipelines
COPY . .

# Compile the test
RUN GO111MODULE=on go test -c -o /test/integration/api-test backend/test/integration/*.go
# Add test resources
ADD backend/test/resources /test/resources

# Add test script.
COPY backend/conformance/run.sh /test/integration
RUN chmod +x /test/integration/run.sh

# Create a tar ball for all the test assets, to be copied into the final image.
RUN tar -czvf /test.tar.gz /test


FROM alpine:3.8

COPY --from=builder /test.tar.gz /
RUN tar -xzvf /test.tar.gz
WORKDIR /test/integration

ENTRYPOINT [ "./run.sh" ]