Skip to content

Commit

Permalink
ci: use golang bci instead of manual download
Browse files Browse the repository at this point in the history
Signed-off-by: davidko <dko@suse.com>
  • Loading branch information
innobead committed Jun 17, 2024
1 parent c1370eb commit 6afd6d9
Showing 1 changed file with 17 additions and 61 deletions.
78 changes: 17 additions & 61 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
FROM registry.suse.com/bci/bci-base:15.6
FROM registry.suse.com/bci/golang:1.22

ARG DAPPER_HOST_ARCH
ARG http_proxy
ARG https_proxy

ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH}
ENV PROTOBUF_VER=24.3
ENV PROTOBUF_VER_PY=4.24.3

# Setup environment
ENV PATH /go/bin:$PATH
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_ENV TAG REPO DRONE_REPO DRONE_PULL_REQUEST DRONE_COMMIT_REF SKIP_TASKS
ENV DAPPER_OUTPUT bin coverage.out
Expand All @@ -17,12 +14,14 @@ ENV DAPPER_OUTPUT bin coverage.out
# and mount filesystems to /tmp to simulate this without bind mounting everything.
ENV DAPPER_RUN_ARGS --privileged --tmpfs /go/src/github.com/longhorn/longhorn-engine/integration/.venv:exec --tmpfs /go/src/github.com/longhorn/longhorn-engine/integration/.tox:exec -v /dev:/host/dev -v /proc:/host/proc --mount type=bind,source=/tmp,destination=/host/tmp,bind-propagation=rslave
ENV DAPPER_SOURCE /go/src/github.com/longhorn/longhorn-engine

WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/SLE_15/system:snappy.repo && \
zypper --gpg-auto-import-keys ref

# Install packages
RUN if [ ${ARCH} == "amd64" ]; then \
zypper -n install autoconf libtool libunwind-devel; \
fi
Expand All @@ -36,57 +35,27 @@ RUN zypper -n install cmake wget curl git less file gcc python311 python311-pip
rpm-build rdma-core-devel gcc-c++ docker open-iscsi && \
rm -rf /var/cache/zypp/*

# needed for ${!var} substitution
RUN rm -f /bin/sh && ln -s /bin/bash /bin/sh

RUN if [ ${ARCH} == "s390x" ]; then \
ln -s /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc;\
fi

# Install Go & tools
ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm64=arm64 GOLANG_ARCH_s390x=s390x GOLANG_ARCH=GOLANG_ARCH_${ARCH} \
GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash
RUN wget -O - https://storage.googleapis.com/golang/go1.22.2.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local
# Install golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2

# Minio
ENV MINIO_URL_amd64=https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2021-12-20T22-07-16Z \
MINIO_URL_arm64=https://dl.min.io/server/minio/release/linux-arm64/archive/minio.RELEASE.2021-12-20T22-07-16Z \
MINIO_URL_s390x=https://dl.min.io/server/minio/release/linux-s390x/archive/minio.RELEASE.2021-12-20T22-07-16Z \
# Install Minio
ENV MINIO_URL_amd64=https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2024-06-13T22-53-53Z \
MINIO_URL_arm64=https://dl.min.io/server/minio/release/linux-arm64/archive/minio.RELEASE.2024-06-13T22-53-53Z \
MINIO_URL=MINIO_URL_${ARCH}

RUN wget ${!MINIO_URL} -O /usr/bin/minio && chmod +x /usr/bin/minio
RUN curl -sSfL ${!MINIO_URL} -o /usr/bin/minio && chmod +x /usr/bin/minio

# Install libqcow
RUN wget -O - https://s3-us-west-1.amazonaws.com/rancher-longhorn/libqcow-alpha-20181117.tar.gz | tar xvzf - -C /usr/src
RUN cd /usr/src/libqcow-20181117 && \
./configure
RUN cd /usr/src/libqcow-20181117 && \
RUN curl -sSfL https://s3-us-west-1.amazonaws.com/rancher-longhorn/libqcow-alpha-20181117.tar.gz | tar xvzf - -C /usr/src && \
cd /usr/src/libqcow-20181117 && \
./configure && \
make -j$(nproc) && \
make install
RUN ldconfig

# GRPC dependencies
# GRPC health probe
ENV GRPC_HEALTH_PROBE_amd64=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.2/grpc_health_probe-linux-amd64 \
GRPC_HEALTH_PROBE_arm64=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.2/grpc_health_probe-linux-arm64 \
GRPC_HEALTH_PROBE_s390x=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.2/grpc_health_probe-linux-s390x \
GRPC_HEALTH_PROBE=GRPC_HEALTH_PROBE_${ARCH}

RUN wget ${!GRPC_HEALTH_PROBE} -O /usr/local/bin/grpc_health_probe && \
chmod +x /usr/local/bin/grpc_health_probe
make install && \
ldconfig

# TODO: use default python3 if SLE upgrade system python version to python3.11
RUN ln -sf /usr/bin/python3.11 /usr/bin/python3 & \
ln -sf /usr/bin/pip3.11 /usr/bin/pip3

# python grpc-tools
RUN if [ "${ARCH}" == "s390x" ]; then \
zypper -n in libopenssl-devel && \
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True pip3 install grpcio==1.58.0 grpcio_tools==1.58.0 protobuf==${PROTOBUF_VER_PY}; \
else \
pip3 install grpcio==1.58.0 grpcio_tools==1.58.0 protobuf==${PROTOBUF_VER_PY}; \
fi
ln -sf /usr/bin/pip3.11 /usr/bin/pip3 && \
pip3 install grpcio==1.58.0 grpcio_tools==1.58.0 protobuf==${PROTOBUF_VER_PY}

# Build liblonghorn
RUN cd /usr/src && \
Expand All @@ -107,23 +76,10 @@ RUN cd /usr/src && \
# Build cache for tox
RUN mkdir integration/
COPY integration/setup.py integration/tox.ini integration/requirements.txt integration/flake8-requirements.txt integration/
RUN cd integration && \
if [ "${ARCH}" == "s390x" ]; then \
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True pip3 install tox==4.11.3; \
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True tox --notest;\
else \
pip3 install tox==4.11.3; \
tox --notest; \
fi

# Build longhorn-instance-manager for integration testing
RUN cd /go/src/github.com/longhorn && \
git clone https://github.com/longhorn/longhorn-instance-manager.git && \
cd longhorn-instance-manager && \
go build -o ./longhorn-instance-manager -tags netgo -ldflags "-linkmode external -extldflags -static" && \
install longhorn-instance-manager /usr/local/bin

VOLUME /tmp
ENV TMPDIR /tmp
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]

0 comments on commit 6afd6d9

Please sign in to comment.