From b8ed8759034e11224b019c4fd58ad5d18af56010 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 31 Jul 2023 12:10:22 -0600 Subject: [PATCH 1/2] models.Run: Index the name column Signed-off-by: Zack Cerza --- .../versions/266e6f3efd94_index_run_name.py | 21 +++++++++++++++++++ paddles/models/runs.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 alembic/versions/266e6f3efd94_index_run_name.py diff --git a/alembic/versions/266e6f3efd94_index_run_name.py b/alembic/versions/266e6f3efd94_index_run_name.py new file mode 100644 index 0000000..6eb482e --- /dev/null +++ b/alembic/versions/266e6f3efd94_index_run_name.py @@ -0,0 +1,21 @@ +"""Index Run.name + +Revision ID: 266e6f3efd94 +Revises: 11e2594da07b +Create Date: 2023-07-31 12:01:24.936988 + +""" + +# revision identifiers, used by Alembic. +revision = '266e6f3efd94' +down_revision = '11e2594da07b' + +from alembic import op + + +def upgrade(): + op.create_index('ix_runs_name', 'runs', ['name'], unique=True) + + +def downgrade(): + op.drop_index('ix_runs_name', table_name='runs') diff --git a/paddles/models/runs.py b/paddles/models/runs.py index d90514a..0e2a620 100644 --- a/paddles/models/runs.py +++ b/paddles/models/runs.py @@ -102,7 +102,7 @@ class Run(Base): __tablename__ = 'runs' id = Column(Integer, primary_key=True) - name = Column(String(512), unique=True) + name = Column(String(512), index=True, unique=True) status = Column(String(16), index=True) user = Column(String(32), index=True) scheduled = Column(DateTime, index=True) From d2449bc7cf7441141f76a7fefeaf5c7ce6c52178 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 31 Jul 2023 12:52:44 -0600 Subject: [PATCH 2/2] Dockerfile: Switch base image: python/3.11-alpine psycopg2-binary stopped shipping for 3.6 and 3.7, so using RH's ubi8/ubi-minimal wasn't going to work anymore. ubi8/python-39 seemed promising, but it turns out that the UBI Python images don't allow package installs. Alpine is smaller, faster and more straightforward. Signed-off-by: Zack Cerza --- Dockerfile | 16 +++++----------- container_start.sh | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index bdb0468..80b98d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,8 @@ -FROM registry.access.redhat.com/ubi8/ubi-minimal:latest +FROM python:3.11-alpine EXPOSE 8080 -RUN microdnf update -y && \ - microdnf install -y \ - curl \ - lsof \ - python3 \ - python3-pip \ - python3-setuptools \ - python3-wheel \ - tzdata +ENV TZ="UTC" +RUN apk add curl tzdata && \ + pip install -U pip # Install dependencies: COPY requirements.txt . @@ -21,4 +15,4 @@ COPY config.py.in /paddles/config.py COPY alembic.ini.in /paddles/alembic.ini COPY container_start.sh /paddles/container_start.sh WORKDIR /paddles -CMD bash container_start.sh +CMD sh container_start.sh diff --git a/container_start.sh b/container_start.sh index e201487..55c8843 100644 --- a/container_start.sh +++ b/container_start.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -ex trap exit TERM pecan populate config.py