ci: run migrations via init container (#7663)
* chore: split auth/dt/migration start * chore: migrations via init container * chore: no checks before migration * chore: indicate celery start * chore: additional log output
This commit is contained in:
parent
39961374d9
commit
9c95689baf
|
@ -17,6 +17,7 @@ RUN echo "deb http://deb.debian.org/debian bullseye-backports main" > /etc/apt/s
|
|||
COPY . .
|
||||
COPY ./dev/build/start.sh ./start.sh
|
||||
COPY ./dev/build/datatracker-start.sh ./datatracker-start.sh
|
||||
COPY ./dev/build/migration-start.sh ./migration-start.sh
|
||||
COPY ./dev/build/celery-start.sh ./celery-start.sh
|
||||
COPY ./dev/build/gunicorn.conf.py ./gunicorn.conf.py
|
||||
|
||||
|
@ -27,6 +28,7 @@ RUN pip3 --disable-pip-version-check --no-cache-dir install -r requirements.txt
|
|||
|
||||
RUN chmod +x start.sh && \
|
||||
chmod +x datatracker-start.sh && \
|
||||
chmod +x migration-start.sh && \
|
||||
chmod +x celery-start.sh && \
|
||||
chmod +x docker/scripts/app-create-dirs.sh && \
|
||||
sh ./docker/scripts/app-create-dirs.sh
|
||||
|
|
|
@ -8,11 +8,14 @@ echo "Running Datatracker checks..."
|
|||
if ! ietf/manage.py migrate --skip-checks --check ; then
|
||||
echo "Unapplied migrations found, waiting to start..."
|
||||
sleep 5
|
||||
while ! ietf/manage.py migrate --skip-checks --check ; do
|
||||
while ! ietf/manage.py migrate --skip-checks --check ; do
|
||||
echo "... still waiting for migrations..."
|
||||
sleep 5
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Starting Celery..."
|
||||
|
||||
cleanup () {
|
||||
# Cleanly terminate the celery app by sending it a TERM, then waiting for it to exit.
|
||||
if [[ -n "${celery_pid}" ]]; then
|
||||
|
|
|
@ -3,8 +3,14 @@
|
|||
echo "Running Datatracker checks..."
|
||||
./ietf/manage.py check
|
||||
|
||||
echo "Running Datatracker migrations..."
|
||||
./ietf/manage.py migrate --skip-checks --settings=settings_local
|
||||
if ! ietf/manage.py migrate --skip-checks --check ; then
|
||||
echo "Unapplied migrations found, waiting to start..."
|
||||
sleep 5
|
||||
while ! ietf/manage.py migrate --skip-checks --check ; do
|
||||
echo "... still waiting for migrations..."
|
||||
sleep 5
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Starting Datatracker..."
|
||||
|
||||
|
|
6
dev/build/migration-start.sh
Normal file
6
dev/build/migration-start.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Running Datatracker migrations..."
|
||||
./ietf/manage.py migrate --skip-checks --settings=settings_local
|
||||
|
||||
echo "Done!"
|
|
@ -5,14 +5,20 @@
|
|||
# CONTAINER_ROLE - datatracker, celery, or beat (defaults to datatracker)
|
||||
#
|
||||
case "${CONTAINER_ROLE:-datatracker}" in
|
||||
datatracker)
|
||||
auth)
|
||||
exec ./datatracker-start.sh
|
||||
;;
|
||||
beat)
|
||||
exec ./celery-start.sh --app=ietf beat
|
||||
;;
|
||||
celery)
|
||||
exec ./celery-start.sh --app=ietf worker
|
||||
;;
|
||||
beat)
|
||||
exec ./celery-start.sh --app=ietf beat
|
||||
datatracker)
|
||||
exec ./datatracker-start.sh
|
||||
;;
|
||||
migrations)
|
||||
exec ./migration-start.sh
|
||||
;;
|
||||
*)
|
||||
echo "Unknown role '${CONTAINER_ROLE}'"
|
||||
|
|
|
@ -82,6 +82,35 @@ spec:
|
|||
readOnlyRootFilesystem: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
initContainers:
|
||||
- name: migration
|
||||
image: "ghcr.io/ietf-tools/datatracker:$APP_IMAGE_TAG"
|
||||
env:
|
||||
- name: "CONTAINER_ROLE"
|
||||
value: "migrations"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: django-config
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
volumeMounts:
|
||||
- name: dt-vol
|
||||
mountPath: /a
|
||||
- name: dt-tmp
|
||||
mountPath: /tmp
|
||||
- name: dt-home
|
||||
mountPath: /home/datatracker
|
||||
- name: dt-xml2rfc-cache
|
||||
mountPath: /var/cache/xml2rfc
|
||||
- name: dt-cfg
|
||||
mountPath: /workspace/ietf/settings_local.py
|
||||
subPath: settings_local.py
|
||||
volumes:
|
||||
# To be overriden with the actual shared volume
|
||||
- name: dt-vol
|
||||
|
|
Loading…
Reference in a new issue