mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-19 10:52:04 +00:00
75 lines
2.5 KiB
Docker
75 lines
2.5 KiB
Docker
FROM ubuntu:24.04
|
|
|
|
# Avoid prompts
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install make and iproute2 (for multi-node IP management)
|
|
RUN apt-get update && apt-get install -y make sudo iproute2 && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set up working directory for Makefile targets
|
|
WORKDIR /tmp/hive-setup
|
|
|
|
# Copy only the Makefile for dependency installation
|
|
COPY hive/Makefile .
|
|
|
|
# Install system dependencies in separate layers for better caching
|
|
RUN make install-system
|
|
RUN make install-go
|
|
RUN make install-aws
|
|
|
|
# Ensure Go is in the PATH
|
|
ENV PATH="/usr/local/go/bin:/root/go/bin:${PATH}"
|
|
|
|
# Set up working directory structure to match development layout
|
|
WORKDIR /root/Development/mulga
|
|
|
|
# Pre-download Ubuntu cloud image for e2e tests (cached in Docker layer)
|
|
# Placed before dependency copy so go.mod changes don't invalidate this layer
|
|
RUN mkdir -p /root/images && \
|
|
ARCH=$(dpkg --print-architecture) && \
|
|
if [ "$ARCH" = "amd64" ]; then \
|
|
curl -L -o /root/images/ubuntu-24.04.img \
|
|
https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img; \
|
|
elif [ "$ARCH" = "arm64" ]; then \
|
|
curl -L -o /root/images/ubuntu-24.04.img \
|
|
https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img; \
|
|
fi
|
|
|
|
# 1. Pre-copy dependency manifests for cache layer
|
|
COPY hive/go.mod hive/go.sum ./hive/
|
|
COPY viperblock/go.mod viperblock/go.sum ./viperblock/
|
|
COPY viperblock/nbd/go.mod viperblock/nbd/go.sum ./viperblock/nbd/
|
|
COPY viperblock/nbd/libguestfs.org/nbdkit/go.mod ./viperblock/nbd/libguestfs.org/nbdkit/
|
|
COPY predastore/go.mod predastore/go.sum ./predastore/
|
|
|
|
# 2. Download dependencies (using cache mount)
|
|
RUN --mount=type=cache,target=/root/go/pkg/mod \
|
|
(cd hive && go mod download) && \
|
|
(cd viperblock && go mod download) && \
|
|
(cd viperblock/nbd && go mod download) && \
|
|
(cd viperblock/nbd/libguestfs.org/nbdkit && go mod download) && \
|
|
(cd predastore && go mod download)
|
|
|
|
# 3. Copy the rest of the source code
|
|
COPY hive/ ./hive/
|
|
COPY viperblock/ ./viperblock/
|
|
COPY predastore/ ./predastore/
|
|
|
|
# Set working directory to hive
|
|
WORKDIR /root/Development/mulga/hive
|
|
|
|
# Ensure scripts are executable
|
|
RUN chmod +x ./scripts/*.sh ./tests/e2e/*.sh ./tests/e2e/lib/*.sh
|
|
|
|
# 4. Build everything (using cache mounts)
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
--mount=type=cache,target=/root/go/pkg/mod \
|
|
./scripts/dev-setup.sh
|
|
|
|
# Set environment variables for runtime
|
|
ENV PATH="/root/Development/mulga/hive/bin:${PATH}"
|
|
ENV HOME="/root"
|
|
|
|
# Run the E2E test runner
|
|
CMD ["./tests/e2e/run-e2e.sh"]
|