2024-08-28 12:51:25 +00:00
|
|
|
# Stage 1: Build stage with necessary build dependencies
|
2024-12-20 17:30:23 +00:00
|
|
|
FROM quay.io/fedora/python-312:20240814 AS prebuild
|
2024-08-28 12:51:25 +00:00
|
|
|
LABEL \
|
|
|
|
name="python-312-with-rust" \
|
|
|
|
vendor="Fedora Infrastructure" \
|
|
|
|
license="MIT"
|
|
|
|
|
|
|
|
USER root
|
|
|
|
# Add RPM-only modules and build dependencies
|
|
|
|
RUN dnf install -y \
|
|
|
|
python3-pyrpmmd \
|
|
|
|
python3-poetry \
|
|
|
|
poetry \
|
|
|
|
cargo \
|
|
|
|
logrotate \
|
|
|
|
git \
|
|
|
|
gcc \
|
|
|
|
gcc-c++ \
|
|
|
|
libffi-devel \
|
|
|
|
openssl-devel
|
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
|
|
|
|
# Stage 2: Build mirrormanager2 python code
|
|
|
|
FROM prebuild AS mirrormanager2-build
|
|
|
|
|
2024-08-28 12:51:25 +00:00
|
|
|
# Clone MirrorManager2 source code from the Git repo
|
|
|
|
RUN mkdir -p /opt/mirrormanager2
|
|
|
|
WORKDIR /opt/mirrormanager2
|
|
|
|
RUN git clone https://github.com/fedora-infra/mirrormanager2.git .
|
|
|
|
|
2024-08-30 19:34:13 +00:00
|
|
|
RUN sed -e 's/signed_fpca/signed_rosca/' -i mirrormanager2/perms.py mirrormanager2/auth.py
|
2024-08-28 12:51:25 +00:00
|
|
|
RUN pip install --prefix=/install .
|
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
RUN pip install --prefix=/install flask_session psycopg2
|
|
|
|
|
|
|
|
# Stage 3: Build generate-mirrorlist-cache and mirrorlist-server
|
|
|
|
FROM prebuild AS mirrorlist-build
|
|
|
|
|
|
|
|
RUN mkdir -p /opt/mirrorlist-server
|
|
|
|
WORKDIR /opt/mirrorlist-server
|
|
|
|
RUN git clone https://github.com/adrianreber/mirrorlist-server.git .
|
|
|
|
RUN echo -e '[profile.release-with-debug]\ninherits = "release"\ndebug = true\n' >> Cargo.toml
|
|
|
|
|
|
|
|
# NOTE(neil): 20241217 #![deny(warnings)] causes deprecated/removed lints to be errors...
|
|
|
|
RUN sed -i 's,#!\[deny(warnings)\],\#!\[allow(renamed_and_removed_lints)\],' src/bin/mirrorlist-server.rs src/bin/generate-mirrorlist-cache.rs
|
2024-08-30 19:40:10 +00:00
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
RUN cargo build --profile=release-with-debug
|
|
|
|
|
|
|
|
# Stage 4: Build scan-primary-mirror
|
|
|
|
FROM prebuild AS scan-primary-mirror-build
|
|
|
|
|
|
|
|
RUN mkdir -p /opt/scan-primary-mirror
|
|
|
|
WORKDIR /opt/scan-primary-mirror
|
|
|
|
RUN git clone https://github.com/adrianreber/scan-primary-mirror.git .
|
|
|
|
RUN RUSTFLAGS=-g cargo build --release
|
|
|
|
|
|
|
|
# Stage 5: Final stage with runtime dependencies
|
|
|
|
FROM quay.io/fedora/python-312:20240814 AS runtime
|
2024-08-28 12:51:25 +00:00
|
|
|
LABEL \
|
|
|
|
name="python-312-with-rust" \
|
|
|
|
vendor="Fedora Infrastructure" \
|
|
|
|
license="MIT"
|
|
|
|
|
|
|
|
USER root
|
2024-12-20 17:30:23 +00:00
|
|
|
|
2024-08-28 12:51:25 +00:00
|
|
|
# Add only runtime dependencies
|
|
|
|
RUN dnf install -y \
|
|
|
|
python3-pyrpmmd \
|
|
|
|
uwsgi \
|
|
|
|
uwsgi-plugin-python3 \
|
|
|
|
logrotate
|
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
# Copy installation of mirrormanager from it's build stage
|
|
|
|
COPY --from=mirrormanager2-build /install /opt/app-root/
|
2024-08-28 12:51:25 +00:00
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
# Copy mirrorlist-server and generate-mirrorlist-cache from mirrorlist-server build
|
|
|
|
COPY --from=mirrorlist-build /opt/mirrorlist-server/target/release-with-debug/generate-mirrorlist-cache /usr/local/bin/
|
|
|
|
COPY --from=mirrorlist-build /opt/mirrorlist-server/target/release-with-debug/mirrorlist-server /usr/local/bin/
|
2024-08-28 12:51:25 +00:00
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
# Copy scan-primary-mirror from its build step
|
|
|
|
COPY --from=scan-primary-mirror-build /opt/scan-primary-mirror/target/release/scan-primary-mirror /usr/local/bin/
|
|
|
|
|
|
|
|
# Copy in the wsgi entry point
|
|
|
|
ADD run.py /opt/mirrormanager2/
|
2024-08-29 23:13:29 +00:00
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
# Stage 6: flatten :)
|
2024-08-29 23:13:29 +00:00
|
|
|
FROM runtime as final
|
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
LABEL \
|
|
|
|
name="python-312-with-rust-mirrormanager" \
|
|
|
|
vendor="Rocky Linux Infrastructure" \
|
|
|
|
license="MIT"
|
|
|
|
|
2024-08-28 12:51:25 +00:00
|
|
|
WORKDIR /opt/mirrormanager2
|
|
|
|
|
|
|
|
EXPOSE 5000
|
2024-12-20 17:30:23 +00:00
|
|
|
|
|
|
|
# @TODO(neil): probably this shouldn't be here? maybe SSM -> parse out in mm2.cfg?
|
2024-08-29 23:13:29 +00:00
|
|
|
COPY client_secrets.json /etc/mirrormanager/
|
|
|
|
COPY mirrormanager2.cfg /etc/mirrormanager/
|
2024-12-20 17:30:23 +00:00
|
|
|
COPY static/rocky /opt/app-root/lib/python3.12/site-packages/mirrormanager2/static/rocky
|
|
|
|
COPY templates/rocky /opt/app-root/lib/python3.12/site-packages/mirrormanager2/templates/rocky
|
|
|
|
|
2024-08-29 23:13:29 +00:00
|
|
|
ENV MM2_CONFIG=/etc/mirrormanager/mirrormanager2.cfg
|
|
|
|
|
2024-12-20 17:30:23 +00:00
|
|
|
ENV SETUP_DB=false
|
|
|
|
RUN test "$SETUP_DB" || python -m flask -A mirrormanager2.app db sync
|
2024-08-28 12:51:25 +00:00
|
|
|
|
|
|
|
# Define entrypoint script to start the application
|
2024-08-29 23:13:29 +00:00
|
|
|
CMD [ "uwsgi", "--socket", "0.0.0.0:5000", \
|
2024-08-28 12:51:25 +00:00
|
|
|
"--uid", "uwsgi", \
|
|
|
|
"--plugins", "python3", \
|
2024-08-29 23:13:29 +00:00
|
|
|
"--protocol", "http", \
|
2024-08-28 12:51:25 +00:00
|
|
|
"--enable-threads", \
|
|
|
|
"--master", \
|
|
|
|
"-b", "65535", \
|
2024-12-20 17:30:23 +00:00
|
|
|
"-H", "/opt/app-root/", \
|
2024-08-28 12:51:25 +00:00
|
|
|
"--wsgi-file", "/opt/mirrormanager2/run.py" ]
|
|
|
|
|