From 7edc269d53d283936273f21dd2c9d15660a61d48 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Jun 15 2024 10:52:29 +0000 Subject: [PATCH 1/2] feat(containerfiles): First version of definitions and entrypoints Contains containerfiles for base, server, worker, docs and env container. Including entrypoint scripts per type. Worker accepts parameters to use the same image for different tasks and/or celery queues. --- diff --git a/files/containerfiles/alembic.ini b/files/containerfiles/alembic.ini new file mode 100644 index 0000000..ca75e5e --- /dev/null +++ b/files/containerfiles/alembic.ini @@ -0,0 +1,37 @@ +[alembic] +script_location = /pagure/alembic +sqlalchemy.url = postgresql://pagure:pagure@postgresql/pagure + +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/files/containerfiles/entrypoint-pagure-docs.sh b/files/containerfiles/entrypoint-pagure-docs.sh new file mode 100644 index 0000000..f31df70 --- /dev/null +++ b/files/containerfiles/entrypoint-pagure-docs.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source /venv/bin/activate + +exec gunicorn "pagure.docs_server:APP" --bind 0.0.0.0 --access-logfile - --error-logfile - $@ diff --git a/files/containerfiles/entrypoint-pagure-ev.sh b/files/containerfiles/entrypoint-pagure-ev.sh new file mode 100644 index 0000000..4dc6888 --- /dev/null +++ b/files/containerfiles/entrypoint-pagure-ev.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source /venv/bin/activate + +exec python /pagure/pagure-ev/pagure_stream_server.py diff --git a/files/containerfiles/entrypoint-pagure-server.sh b/files/containerfiles/entrypoint-pagure-server.sh new file mode 100644 index 0000000..bf113dc --- /dev/null +++ b/files/containerfiles/entrypoint-pagure-server.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +source /venv/bin/activate + +if [ ! -f /attachments/inited ]; +then + python /pagure/createdb.py + && touch /attachments/inited +else + alembic upgrade head +fi + +exec gunicorn "pagure.flask_app:create_app()" --bind 0.0.0.0 --access-logfile - --error-logfile - $@ diff --git a/files/containerfiles/entrypoint-pagure-worker.sh b/files/containerfiles/entrypoint-pagure-worker.sh new file mode 100644 index 0000000..e3a8f33 --- /dev/null +++ b/files/containerfiles/entrypoint-pagure-worker.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +source /venv/bin/activate + +# for logcom pass as ARGS/CMD: +# --tasks "pagure.lib.tasks_services" --queue "pagure_logcom" +exec python /pagure/runworker.py $@ diff --git a/files/containerfiles/pagure-base b/files/containerfiles/pagure-base new file mode 100644 index 0000000..bc2e46e --- /dev/null +++ b/files/containerfiles/pagure-base @@ -0,0 +1,45 @@ +FROM quay.io/almalinuxorg/9-base + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG repo=https://pagure.io/pagure.git +ARG branch=master + +ENV REPO=$repo +ENV BRANCH=$branch +ENV ALEMBIC_CONFIG=/alembic.ini +ENV PAGURE_CONFIG=/pagure.cfg + +RUN dnf -y install \ + python3 \ + git \ + python3-devel \ + gcc \ + zlib-devel \ + libjpeg-devel \ + && git clone $REPO -b $BRANCH \ + && python3 -m venv /venv \ + && source /venv/bin/activate \ + && python -m pip install --upgrade pip build \ + && python -m pip install -r /pagure/requirements.txt \ + -r /pagure/requirements-ci.txt \ + -r /pagure/requirements-optional.txt \ + -r /pagure/requirements-testing.txt \ + gunicorn \ + && cd /pagure \ + && python setup.py build \ + && python setup.py install \ + && rm -rf build/ \ + && python -m pip cache purge \ + && dnf -y remove \ + python3-devel \ + gcc \ + zlib-devel \ + libjpeg-devel \ + && dnf clean all + +COPY alembic.ini /alembic.ini +COPY pagure.cfg /pagure.cfg diff --git a/files/containerfiles/pagure-docs b/files/containerfiles/pagure-docs new file mode 100644 index 0000000..f4a386d --- /dev/null +++ b/files/containerfiles/pagure-docs @@ -0,0 +1,12 @@ +FROM pagure-base:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +VOLUME ["/data"] + +COPY entrypoint-pagure-docs.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/files/containerfiles/pagure-ev b/files/containerfiles/pagure-ev new file mode 100644 index 0000000..b99cf03 --- /dev/null +++ b/files/containerfiles/pagure-ev @@ -0,0 +1,12 @@ +FROM pagure-base:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +VOLUME ["/data"] + +COPY entrypoint-pagure-ev.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/files/containerfiles/pagure-server b/files/containerfiles/pagure-server new file mode 100644 index 0000000..c6d27fc --- /dev/null +++ b/files/containerfiles/pagure-server @@ -0,0 +1,12 @@ +FROM pagure-base:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +VOLUME ["/data"] + +COPY entrypoint-pagure-server.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/files/containerfiles/pagure-worker b/files/containerfiles/pagure-worker new file mode 100644 index 0000000..6bee2b1 --- /dev/null +++ b/files/containerfiles/pagure-worker @@ -0,0 +1,15 @@ +FROM pagure-base:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +VOLUME ["/data"] + +COPY entrypoint-pagure-worker.sh /entrypoint.sh + +# Run celery as root, required to access /repos +ENV C_FORCE_ROOT=true + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/files/containerfiles/pagure.cfg b/files/containerfiles/pagure.cfg new file mode 100644 index 0000000..c4abe98 --- /dev/null +++ b/files/containerfiles/pagure.cfg @@ -0,0 +1,10 @@ +ENABLE_DOCS = True +SECRET_KEY = 'ReplaceMeWithASecretPassphrase' +DB_URL = 'postgresql://pagure:pagure@postgresql/pagure' +APP_URL = 'http://pagure:8000/' +REDIS_HOST = 'redis' +GIT_FOLDER = '/data/repos' +REMOTE_GIT_FOLDER = '/data/remote' +ATTACHMENTS_FOLDER = '/data/attachments' +EVENTSOURCE_SOURCE = 'http://pagure-ev:8080' +PAGURE_CI_SERVICES = ['jenkins'] \ No newline at end of file From f00b337cb4cba35543242f199597f7f16d2e53c0 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Jun 15 2024 11:58:18 +0000 Subject: [PATCH 2/2] chore: allow alembic.ini outside root project folder. --- diff --git a/.gitignore b/.gitignore index 576ddff..7ad5e9d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,7 @@ clones/ tests/*.git # Don't track alembic.ini -alembic.ini +/alembic.ini # Don't track the virtualenv we tell developers to use pagure_env/