fix: dedicated scheduler Dockerfile with psql for migrations, remove Python splitter
This commit is contained in:
+1
-2
@@ -58,9 +58,8 @@ steps:
|
|||||||
tags:
|
tags:
|
||||||
- ${CI_COMMIT_SHA}
|
- ${CI_COMMIT_SHA}
|
||||||
- latest
|
- latest
|
||||||
dockerfile: docker/Dockerfile
|
dockerfile: docker/Dockerfile.scheduler
|
||||||
context: .
|
context: .
|
||||||
build_args: "SERVICE_CMD=python -m services.scheduler.app"
|
|
||||||
when:
|
when:
|
||||||
event: push
|
event: push
|
||||||
branch: main
|
branch: main
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
COPY services/ /app/services/
|
COPY services/ /app/services/
|
||||||
COPY tests/ /app/tests/
|
COPY tests/ /app/tests/
|
||||||
COPY conftest.py /app/conftest.py
|
COPY conftest.py /app/conftest.py
|
||||||
COPY infra/migrations/ /app/infra/migrations/
|
|
||||||
|
|
||||||
RUN useradd -m -u 1000 stonks && \
|
RUN useradd -m -u 1000 stonks && \
|
||||||
chown -R stonks:stonks /app
|
chown -R stonks:stonks /app
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Scheduler image — adds postgresql-client for running migrations via psql.
|
||||||
|
# Built separately from the base service image. Only the scheduler uses this.
|
||||||
|
FROM registry.celestium.life/dockerhub-cache/library/python:3.12-slim
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV PYTHONPATH=/app
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
libpq-dev \
|
||||||
|
curl \
|
||||||
|
postgresql-client \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY services/ /app/services/
|
||||||
|
COPY tests/ /app/tests/
|
||||||
|
COPY conftest.py /app/conftest.py
|
||||||
|
COPY infra/migrations/ /app/infra/migrations/
|
||||||
|
|
||||||
|
RUN useradd -m -u 1000 stonks && \
|
||||||
|
chown -R stonks:stonks /app
|
||||||
|
|
||||||
|
USER stonks
|
||||||
|
|
||||||
|
CMD ["python", "-m", "services.scheduler.app"]
|
||||||
@@ -33,7 +33,17 @@ spec:
|
|||||||
- name: run-migrations
|
- name: run-migrations
|
||||||
image: {{ $root.Values.image.registry }}/{{ $svc.image }}:{{ $root.Values.image.tag }}
|
image: {{ $root.Values.image.registry }}/{{ $svc.image }}:{{ $root.Values.image.tag }}
|
||||||
imagePullPolicy: {{ $root.Values.image.pullPolicy }}
|
imagePullPolicy: {{ $root.Values.image.pullPolicy }}
|
||||||
command: ["python", "-m", "services.shared.migrate"]
|
command: ["sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
for f in $(ls /app/infra/migrations/*.sql 2>/dev/null | sort); do
|
||||||
|
echo "Applying $(basename $f)..."
|
||||||
|
PGPASSWORD="$POSTGRES_PASSWORD" psql \
|
||||||
|
-h "$POSTGRES_HOST" -p "$POSTGRES_PORT" \
|
||||||
|
-U "$POSTGRES_USER" -d "$POSTGRES_DB" \
|
||||||
|
-f "$f" -v ON_ERROR_STOP=0 > /dev/null 2>&1 || true
|
||||||
|
done
|
||||||
|
echo "Migrations complete."
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- include "stonks.containerSecurityContext" $root | nindent 12 }}
|
{{- include "stonks.containerSecurityContext" $root | nindent 12 }}
|
||||||
envFrom:
|
envFrom:
|
||||||
|
|||||||
Reference in New Issue
Block a user