Commit f9950a20 authored by Grant, Josh's avatar Grant, Josh
Browse files

docker bake the things

parent e69bd464
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
FROM --platform=linux/amd64 python:3.11-slim

RUN apt-get -yqq update && apt-get -yqq upgrade && \
      apt-get -yqq install vim && apt-get -yqq install postgresql-client

COPY src/ tmp/src


RUN set -eux && pip install --upgrade pip && \
      cd /tmp/src/ && pip install -e .[all] && \
      pip install pytest pytest-cov 
      
CMD ["tail", "-f", "/dev/null"]
ARG PYTHON_VERSION=3.11
ARG PYGARDEN_INSTALL_TOKEN
FROM --platform=${BUILDARCH} python:${PYTHON_VERSION}-slim AS builder
RUN apt-get update && apt-get install -yqq libpq-dev gcc
WORKDIR /app
COPY requirements.txt.tpl .
RUN sed \
    -e "s|\${PYGARDEN_EXTRAS}|${PYGARDEN_EXTRAS}|" \
    requirements.txt.tpl > requirements.txt && \
    pip install --no-cache-dir --break-system-packages -r requirements.txt && rm requirements.txt requirements.txt.tpl
RUN apt remove -y gcc

docker-bake.hcl

0 → 100644
+72 −0
Original line number Diff line number Diff line

variable "PYGARDEN_INSTALL_TOKEN" {
  description = "Token for installing PyGarden"
  default     = ""
}

target "pygarden-base" {
  context    = "."
  dockerfile = "Dockerfile"
  args = {
    PYGARDEN_INSTALL_TOKEN = "${PYGARDEN_INSTALL_TOKEN}"
  }
  platforms = ["linux/amd64", "linux/arm64"]
}

target "pgmatrix" {
  matrix = {
    PYTHON_VERSION = ["3.9", "3.10", "3.11", "3.12", "3.13"]
    PYGARDEN_EXTRAS = ["", "postgres", "all", "db-pandas,postgres,mssql,influx", "db-pandas,postgres", "scrapers"]
  }

  name = replace(replace("pygarden-${PYTHON_VERSION}-${PYGARDEN_EXTRAS}", ".", "_"), ",", "_")

  inherits = ["pygarden-base"]

  args = {
    PYTHON_VERSION         = "${PYTHON_VERSION}"
    PYGARDEN_INSTALL_TOKEN = "${PYGARDEN_INSTALL_TOKEN}"
    PYGARDEN_EXTRAS        = "${PYGARDEN_EXTRAS}"
  }

  tags = [
    replace(replace("savannah.ornl.gov/common/pygarden:${PYTHON_VERSION}-${PYGARDEN_EXTRAS}-latest", "--", "-"), ",", "-")
  ]

  output = ["type=image"]
}

group "default" {
  targets = ["pgmatrix", "pg-gdal-matrix"]
}

target "pg-gdal-base" {
  dockerfile = "gdal.Dockerfile"
  context = "."
  platforms = ["linux/amd64", "linux/arm64"]
}

target "pg-gdal-matrix" {
  matrix = {
    PYTHON_VERSION = ["3.9", "3.10", "3.11", "3.12", "3.13"]
    PYGARDEN_EXTRAS = ["", "postgres", "all", "db-pandas,postgres,mssql,influx", "db-pandas,postgres", "scrapers"]
  }

  name = replace(replace(replace("pygarden-gdal-${PYTHON_VERSION}-${PYGARDEN_EXTRAS}", ".", "_"), ",", "_"), "/", "-")

  inherits = ["pg-gdal-base"]

  args = {
    PYGARDEN_TAG = replace(replace("${PYTHON_VERSION}-${PYGARDEN_EXTRAS}-latest", ",", "-"), "--", "-")
  }

  tags = [
    replace(replace("savannah.ornl.gov/common/pygarden-gdal:${PYTHON_VERSION}-${PYGARDEN_EXTRAS}-latest", "--", "-"), ",", "-")
  ]

  depends_on = [
    replace(replace("pygarden-${PYTHON_VERSION}-${PYGARDEN_EXTRAS}", ".", "_"), ",", "_")
  ]

  output = ["type=image"]
}
+8 −0
Original line number Diff line number Diff line
services:
  test_1:
    image: savannah.ornl.gov/common/pygarden-gdal:3.13-all-latest
    command: "tail -f /dev/null"

  test_2:
    image: savannah.ornl.gov/common/pygarden:3.13-all-latest
    command: "tail -f /dev/null"

gdal.Dockerfile

0 → 100644
+17 −0
Original line number Diff line number Diff line
ARG PYGARDEN_TAG="3.12-postgres-latest"
FROM savannah.ornl.gov/common/pygarden:${PYGARDEN_TAG}
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        gdal-bin \
        libgdal-dev \
        libproj-dev \
        python3-gdal \
        python3-numpy \
        libtiff-dev \
        libgeos-dev \
        libspatialite-dev \
        libsqlite3-dev \
        libcurl4-gnutls-dev && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

old.Dockerfile

0 → 100644
+13 −0
Original line number Diff line number Diff line
FROM --platform=linux/amd64 python:3.11-slim

RUN apt-get -yqq update && apt-get -yqq upgrade && \
      apt-get -yqq install vim && apt-get -yqq install postgresql-client

COPY src/ tmp/src


RUN set -eux && pip install --upgrade pip && \
      cd /tmp/src/ && pip install -e .[all] && \
      pip install pytest pytest-cov 
      
CMD ["tail", "-f", "/dev/null"]