# Copyright 2024 PingCAP, Inc.
#
# 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.

FROM minio/minio AS image-minio

FROM rockylinux:9
WORKDIR /root/

# Install tiup
RUN curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

# Necessary dependencies to run or build the tests.
RUN yum install -y mysql golang python3-pip
RUN yum install -y procps-ng

COPY --from=image-minio /bin/minio /root/minio

# For caching later.
RUN mkdir -p /root/.tiup/components

# The followings are resources that we would like to keep in the base image, avoid downloading repeatedly.
RUN go install github.com/pingcap/mysql-tester/src@314107b26aa8fce86beb0dd48e75827fb269b365
RUN mv /root/go/bin/src /root/mysql-tester

COPY ./requirements.txt /root/requirements.txt
RUN pip3 install -r requirements.txt

COPY ./datasets /root/datasets