|
| 1 | + |
| 2 | + |
| 3 | +# Stage 2: Final image |
| 4 | +FROM python:3.12-slim |
| 5 | + |
| 6 | +ARG AWS_ACCESS_KEY_ID |
| 7 | +ARG AWS_SECRET_ACCESS_KEY |
| 8 | + |
| 9 | +ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID |
| 10 | +ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY |
| 11 | + |
| 12 | +WORKDIR /app |
| 13 | + |
| 14 | +# Install system dependencies |
| 15 | +RUN apt-get update && apt-get install -y \ |
| 16 | + curl \ |
| 17 | + unzip \ |
| 18 | + procps \ |
| 19 | + && rm -rf /var/lib/apt/lists/* |
| 20 | + |
| 21 | +# Install AWS CLI based on architecture |
| 22 | +RUN ARCH=$(uname -m) && \ |
| 23 | + if [ "$ARCH" = "x86_64" ]; then \ |
| 24 | + URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \ |
| 25 | + elif [ "$ARCH" = "aarch64" ]; then \ |
| 26 | + URL="https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \ |
| 27 | + else \ |
| 28 | + echo "Unsupported architecture: $ARCH" && exit 1; \ |
| 29 | + fi && \ |
| 30 | + curl "$URL" -o "awscliv2.zip" && \ |
| 31 | + unzip awscliv2.zip && \ |
| 32 | + ./aws/install && \ |
| 33 | + rm -rf awscliv2.zip aws |
| 34 | + |
| 35 | +# Install Python dependencies |
| 36 | +RUN pip install --no-cache-dir \ |
| 37 | + boto3 \ |
| 38 | + pandas \ |
| 39 | + numpy \ |
| 40 | + pyyaml \ |
| 41 | + ortools \ |
| 42 | + requests |
| 43 | + |
| 44 | +# Download and install spotinfo based on architecture |
| 45 | +# Download and install spotinfo based on architecture |
| 46 | +RUN ARCH=$(uname -m) && \ |
| 47 | + if [ "$ARCH" = "x86_64" ]; then \ |
| 48 | + URL="https://github.com/alexei-led/spotinfo/releases/download/2.2.0/spotinfo_linux_amd64"; \ |
| 49 | + elif [ "$ARCH" = "aarch64" ]; then \ |
| 50 | + URL="https://github.com/alexei-led/spotinfo/releases/download/2.2.0/spotinfo_linux_arm64"; \ |
| 51 | + else \ |
| 52 | + echo "Unsupported architecture: $ARCH" && exit 1; \ |
| 53 | + fi && \ |
| 54 | + curl -L $URL -o /usr/local/bin/spotinfo && \ |
| 55 | + chmod +x /usr/local/bin/spotinfo |
| 56 | + |
| 57 | +# Copy application code |
| 58 | +# Assuming build context is the project root (spotlake/) |
| 59 | +COPY collector/spot-dataset/aws/batch-test /app/collector/spot-dataset/aws/batch-test |
| 60 | +# COPY const_config.py /app/ |
| 61 | +COPY utility /app/utility |
| 62 | +RUN chmod +x /app/collector/spot-dataset/aws/batch-test/scripts/run_collection.sh |
| 63 | + |
| 64 | +# Set PYTHONPATH to include /app so imports work |
| 65 | +ENV PYTHONPATH=/app |
| 66 | + |
| 67 | +# Default entrypoint (can be overridden) |
| 68 | +CMD ["python3", "--version"] |
0 commit comments