Skip to content

Commit 0dde1c4

Browse files
committed
checkpoint
1 parent d3c35d9 commit 0dde1c4

File tree

41 files changed

+2504
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2504
-0
lines changed

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-ast
7+
- id: check-builtin-literals
8+
- id: check-docstring-first
9+
- id: check-executables-have-shebangs
10+
- id: check-json
11+
- id: check-merge-conflict
12+
- id: check-symlinks
13+
- id: check-yaml
14+
args:
15+
- --allow-multiple-documents
16+
- id: destroyed-symlinks
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
args:
20+
- --fix=lf
21+
- id: detect-private-key
22+
- id: check-toml
23+
- id: pretty-format-json
24+
args:
25+
- --autofix
26+
- id: trailing-whitespace
27+
28+
- repo: https://github.com/pre-commit/mirrors-prettier
29+
rev: v4.0.0-alpha.8
30+
hooks:
31+
- id: prettier

podman-kube/Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.PHONY: help up down build status logs clean release dev local
2+
3+
SCRIPT = ./copr-podman-kube
4+
5+
help:
6+
@echo "COPR Podman Kube Play"
7+
@echo ""
8+
@echo "Usage: make <target>"
9+
@echo ""
10+
@echo "Targets:"
11+
@echo " up - Start all services (dev mode)"
12+
@echo " down - Stop all services"
13+
@echo " build - Build all container images"
14+
@echo " status - Show status of running pods"
15+
@echo " logs - Show frontend logs (use SERVICE=<name> for others)"
16+
@echo " clean - Stop services and remove images"
17+
@echo ""
18+
@echo " release - Start with released packages"
19+
@echo " dev - Start with dev packages (default)"
20+
@echo " local - Start in local development mode"
21+
@echo ""
22+
@echo "Examples:"
23+
@echo " make up"
24+
@echo " make logs SERVICE=backend"
25+
@echo " make release"
26+
27+
up:
28+
$(SCRIPT) up
29+
30+
down:
31+
$(SCRIPT) down
32+
33+
build:
34+
$(SCRIPT) build
35+
36+
status:
37+
$(SCRIPT) status
38+
39+
logs:
40+
$(SCRIPT) logs $(or $(SERVICE),frontend)
41+
42+
clean: down
43+
@echo "Removing COPR images..."
44+
-podman rmi $$(podman images --filter "reference=copr-*" -q) 2>/dev/null || true
45+
@echo "Clean complete"
46+
47+
# Mode shortcuts
48+
release:
49+
$(SCRIPT) -m release up
50+
51+
dev:
52+
$(SCRIPT) -m dev up
53+
54+
local:
55+
$(SCRIPT) -m local up

podman-kube/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Run Copr infra with podman kube play
2+
3+
Run the complete COPR infrastructure locally using `podman kube play` with Kubernetes-style manifests.
4+
5+
## Overview
6+
7+
This directory contains everything needed to run COPR in containers using Podman's Kubernetes compatibility layer. It supports three deployment modes:
8+
9+
| Mode | Description | Use Case |
10+
| --------- | ------------------------------------ | ----------------------------------- |
11+
| `release` | Uses packages from Fedora repos only | Testing with released versions |
12+
| `dev` | Uses packages from `@copr/copr-dev` | Testing main branch / pre-release |
13+
| `local` | Same as dev, for local development | Development with local code changes |
14+
15+
## Quick Start
16+
17+
```bash
18+
# Start COPR with development packages (default)
19+
./copr-podman-kube up
20+
21+
# Start COPR with released packages
22+
./copr-podman-kube -m release up
23+
24+
# Stop COPR
25+
./copr-podman-kube down
26+
```
27+
28+
## Usage
29+
30+
### See the man page of the script:
31+
32+
```bash
33+
./copr-podman-kube --help
34+
```
35+
36+
## Access Points
37+
38+
After starting, the following services are available:
39+
40+
| Service | URL |
41+
| --------------- | --------------------- |
42+
| Frontend | http://localhost:5000 |
43+
| DistGit | http://localhost:5001 |
44+
| Backend Results | http://localhost:5002 |
45+
| Resalloc WebUI | http://localhost:5005 |
46+
| Database | localhost:5009 |
47+
48+
### Setup Host Entries (Recommended)
49+
50+
To make all URLs in the web interface work directly in your browser, add this entries to `/etc/hosts` so your browser can resolve internal hostnames like `backend-httpd` to `127.0.0.1`:
51+
52+
```bash
53+
sudo tee -a /etc/hosts << 'EOF'
54+
# COPR local development
55+
127.0.0.1 frontend
56+
127.0.0.1 backend-httpd
57+
127.0.0.1 distgit
58+
127.0.0.1 keygen
59+
127.0.0.1 resalloc
60+
EOF
61+
```
62+
63+
After this, URLs like `http://backend-httpd:5002/results/...` will work directly in your browser!
64+
65+
## Deployment Modes
66+
67+
### Release Mode (`-m release`)
68+
69+
Uses only packages from Fedora repositories. This is useful for testing with the latest released COPR version.
70+
71+
```bash
72+
./copr-podman-kube -m release up
73+
```
74+
75+
### Dev Mode (`-m dev`) - Default
76+
77+
Uses packages from the `@copr/copr-dev` COPR repository, which contains packages built from the main branch.
78+
79+
```bash
80+
./copr-podman-kube up
81+
# or explicitly:
82+
./copr-podman-kube -m dev up
83+
```
84+
85+
### Local Mode (`-m local`)
86+
87+
Same as dev mode but intended for local development. Mounts the local source code into containers for live development.
88+
89+
```bash
90+
./copr-podman-kube -m local up
91+
```
92+
93+
## Future Improvements
94+
95+
- [ ] Live source code mounting in local mode
96+
- [ ] Kustomize support for environment overlays
97+
- [ ] Health checks and readiness probes
98+
- [ ] Resource limits tuning
99+
- [ ] Ready with openshift
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM registry.fedoraproject.org/fedora:43
2+
LABEL maintainer="[email protected]"
3+
LABEL description="COPR Backend HTTPD - serves build results"
4+
5+
RUN dnf install -y nginx && dnf clean all
6+
7+
COPY files/nginx.conf /etc/nginx/conf.d/default.conf
8+
9+
RUN mkdir -p /var/lib/copr/public_html/results && \
10+
chown -R nginx:nginx /var/lib/copr
11+
12+
EXPOSE 5002
13+
14+
CMD ["nginx", "-g", "daemon off;"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 5002;
3+
listen [::]:5002;
4+
server_tokens off;
5+
access_log /dev/stdout;
6+
error_log /dev/stdout;
7+
8+
server_name localhost;
9+
charset utf-8;
10+
11+
root /var/lib/copr/public_html/;
12+
default_type text/plain;
13+
14+
location / {
15+
port_in_redirect off;
16+
autoindex on;
17+
}
18+
19+
location ~* .*\.gz$ {
20+
add_header Content-Encoding gzip;
21+
}
22+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
FROM registry.fedoraproject.org/fedora:43
2+
LABEL maintainer="[email protected]"
3+
LABEL description="COPR Backend services"
4+
5+
ARG ADDITIONAL_COPR_REPOSITORIES="@copr/copr-dev"
6+
7+
ENV LANG=en_US.UTF-8
8+
ENV PYTHONPATH="/usr/share/copr/"
9+
ENV TERM=linux
10+
11+
RUN set -ex ; \
12+
test -z "${ADDITIONAL_COPR_REPOSITORIES}" \
13+
|| dnf -y install dnf-plugins-core \
14+
&& for repo in $ADDITIONAL_COPR_REPOSITORIES ; do dnf -y copr enable $repo; done ; \
15+
dnf -y update && \
16+
dnf -y install htop \
17+
make \
18+
wget \
19+
net-tools \
20+
iputils \
21+
vim \
22+
git \
23+
sudo \
24+
openssh-server \
25+
resalloc \
26+
psmisc \
27+
nginx \
28+
findutils \
29+
tini \
30+
pulp-cli \
31+
rng-tools \
32+
expect \
33+
&& dnf -y install copr-backend \
34+
&& dnf clean all
35+
36+
RUN setcap cap_net_raw,cap_net_admin+p /usr/bin/ping
37+
38+
RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -q
39+
40+
RUN echo 'root:passwd' | chpasswd && chmod 700 /root /root/.ssh
41+
42+
RUN set -x ; \
43+
echo 'copr:passwd' | chpasswd && \
44+
echo 'copr ALL=(ALL:ALL) NOPASSWD:ALL' >> /etc/sudoers && \
45+
mkdir -p /home/copr/.ssh && chmod 700 /home/copr /home/copr/.ssh && \
46+
ssh-keygen -f /home/copr/.ssh/id_rsa -N '' -q -C copr@localhost && \
47+
touch /home/copr/.ssh/authorized_keys && chmod 600 /home/copr/.ssh/authorized_keys && \
48+
cat /home/copr/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \
49+
cat /home/copr/.ssh/id_rsa.pub >> /home/copr/.ssh/authorized_keys && \
50+
chown copr:copr -R /home/copr
51+
52+
RUN usermod -a -G mock copr
53+
54+
COPY files/ /
55+
56+
RUN chmod 700 /root && \
57+
chmod 700 /home/copr && \
58+
chmod 400 /home/copr/.ssh/id_rsa && \
59+
chmod 600 /home/copr/.ssh/id_rsa.pub && \
60+
chown -R copr:copr /home/copr
61+
62+
RUN chmod 0755 /usr/bin/sign
63+
64+
RUN chown copr:root /etc/sign.conf && \
65+
chmod 0660 /etc/sign.conf
66+
67+
RUN mkdir -p /var/lock/copr-backend && \
68+
chown copr:copr /var/lock/copr-backend
69+
70+
# Entropy for GPG key generation
71+
RUN rngd -r /dev/urandom || true
72+
73+
USER copr
74+
75+
ENTRYPOINT ["/usr/bin/tini", "--"]
76+
CMD ["/run-backend"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[backend]
2+
3+
build_user=root
4+
5+
# URL where results are visible
6+
results_baseurl=http://backend-httpd:5002/results/
7+
8+
# Frontend URL
9+
frontend_base_url=http://frontend:5000
10+
11+
# Backend authentication (must match frontend config)
12+
frontend_auth=1234
13+
14+
# DistGit URL
15+
dist_git_url=http://distgit:5001/cgit
16+
17+
# Results directory
18+
destdir=/var/lib/copr/public_html/results
19+
20+
# Queue polling interval (seconds)
21+
sleeptime=30
22+
23+
# Resalloc connection
24+
resalloc_connection=http://resalloc:49100
25+
26+
# Package signing
27+
do_sign=true
28+
keygen_host=keygen:5003
29+
30+
# Build pruning
31+
prune_days=14
32+
33+
# Redis
34+
redis_host=redis
35+
redis_port=6379
36+
37+
# Pulp (optional)
38+
# pulp_content_url=http://pulp:80/pulp/content
39+
40+
[builder]
41+
timeout=3600
42+
builder_perl=True
43+
44+
[ssh]
45+
builder_config=/home/copr/.ssh/builder_config
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SSH config for connecting to builders
2+
Host *
3+
StrictHostKeyChecking no
4+
UserKnownHostsFile /dev/null
5+
IdentityFile /home/copr/.ssh/id_rsa
6+
User root
7+
ConnectTimeout 30
8+
9+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Parse arguments for sign host configuration
5+
option_variable() {
6+
opt=$1
7+
opt=${1##--}
8+
opt=${opt##-}
9+
opt=${opt//-/_}
10+
option_variable_result=opt_$opt
11+
}
12+
13+
opt_sign_user=$(id -u)
14+
opt_sign_host=keygen-signd
15+
16+
ARGS=$(getopt -o "" -l "sign-user:,sign-host:" -n "getopt" -- "$@") || exit 1
17+
eval set -- "$ARGS"
18+
19+
while true; do
20+
case $1 in
21+
--sign-host|--sign-user)
22+
option_variable "$1"
23+
eval "$option_variable_result=\$2"
24+
shift 2
25+
;;
26+
--) shift; break;;
27+
*) echo "programmer mistake ($1)" >&2; exit 1;;
28+
esac
29+
done
30+
31+
# Configure sign client
32+
cat >/etc/sign.conf <<EOF
33+
server: $opt_sign_host
34+
allowuser: $opt_sign_user
35+
allow-unprivileged-ports: true
36+
EOF
37+
38+
# Execute the command
39+
exec "$@"

0 commit comments

Comments
 (0)