summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.env.example1
-rw-r--r--Dockerfile29
-rw-r--r--Jenkinsfile29
-rw-r--r--README.md6
-rw-r--r--scripts/build_packages.sh13
5 files changed, 65 insertions, 13 deletions
diff --git a/.env.example b/.env.example
index d0327f1..3c98b21 100644
--- a/.env.example
+++ b/.env.example
@@ -1,3 +1,4 @@
BUCKET_NAME=your-bucket-name
AWS_PROFILE=vyos-apt
REPO_URL=https://github.com/vyos-contrib/vyos-apt.git
+PACKAGE_LIST=keepalived,ethtool \ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..5815a66
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,29 @@
+# Use the official Debian image as a base
+FROM debian:12
+
+# Install necessary packages
+RUN apt-get update && apt-get install -y \
+ build-essential \
+ devscripts \
+ git \
+ reprepro \
+ awscli \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set the working directory
+WORKDIR /workspace
+
+# Copy the build scripts into the container
+COPY scripts/ /workspace/scripts/
+
+# Copy the configuration files into the container
+COPY conf/ /workspace/conf/
+
+# Copy the .env file into the container
+COPY .env /workspace/
+
+# Make the build scripts executable
+RUN chmod +x /workspace/scripts/*.sh
+
+# Define the entrypoint script
+ENTRYPOINT ["/workspace/scripts/build_packages.sh"]
diff --git a/Jenkinsfile b/Jenkinsfile
index 7dd07b7..dfc07ed 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,31 +1,46 @@
pipeline {
agent any
triggers {
- cron('0 18 * * *') // run daily on 18:00
+ cron('0 18 * * *') // run daily at 18:00
}
environment {
REPO_URL = credentials('repo-url')
- }
+ AWS_PROFILE = credentials('aws-profile')
+ }
stages {
stage('Checkout') {
steps {
- git "${REPO_URL}"
+ script {
+ git "${REPO_URL}"
+ }
}
}
stage('Build Packages') {
steps {
- sh 'scripts/build_packages.sh'
+ script {
+ docker.build('vyos-apt-builder').inside {
+ sh 'scripts/build_packages.sh'
+ }
+ }
}
}
stage('Update APT Repo') {
steps {
- sh 'scripts/update_repo.sh'
+ script {
+ docker.build('vyos-apt-builder').inside {
+ sh 'scripts/update_repo.sh'
+ }
+ }
}
}
stage('Upload to R2') {
steps {
- withCredentials([string(credentialsId: 'aws-profile', variable: 'AWS_PROFILE')]) {
- sh 'scripts/upload_repo.sh'
+ script {
+ docker.build('vyos-apt-builder').inside {
+ withCredentials([string(credentialsId: 'aws-profile', variable: 'AWS_PROFILE')]) {
+ sh 'scripts/upload_repo.sh'
+ }
+ }
}
}
}
diff --git a/README.md b/README.md
index 1016d3c..e5b8044 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
# vyos-apt
-This repository contains the configuration and scripts necessary to build VyOS packages and update an APT repository automatically using Jenkins. It also includes steps to upload the repository to Cloudflare R2.
+This repository contains the configuration and scripts necessary to build VyOS packages and update an APT repository automatically using Jenkins and Docker. It also includes steps to upload the repository to Cloudflare R2.
## Directory Structure
- `Jenkinsfile`: Jenkins pipeline configuration.
+- `Dockerfile`: Docker image configuration for building packages.
- `scripts/build_packages.sh`: Script to build VyOS packages.
- `scripts/update_repo.sh`: Script to update the APT repository.
- `scripts/upload_repo.sh`: Script to upload the repository to Cloudflare R2.
@@ -26,7 +27,7 @@ This repository contains the configuration and scripts necessary to build VyOS p
4. **Create a `.env` File:**
- Create a `.env` file in the root of this repository based on the `.env.example` file.
- - Fill in the necessary details such as `BUCKET_NAME`, `AWS_PROFILE`, and `REPO_URL`.
+ - Fill in the necessary details such as `BUCKET_NAME`, `AWS_PROFILE`, `REPO_URL`, and `PACKAGE_LIST`.
5. **Run the Pipeline:**
- The pipeline will automatically build the VyOS packages daily, update the APT repository, and upload the repository to Cloudflare R2.
@@ -34,6 +35,7 @@ This repository contains the configuration and scripts necessary to build VyOS p
## Dependencies
- Jenkins
+- Docker
- reprepro
- debuild
- AWS CLI
diff --git a/scripts/build_packages.sh b/scripts/build_packages.sh
index 3141a32..915957f 100644
--- a/scripts/build_packages.sh
+++ b/scripts/build_packages.sh
@@ -2,22 +2,27 @@
set -e
-# packages to build
-packages=("keepalived" "ethtool")
+# Load environment variables from .env file
+source .env
+# Define the working directory
WORKDIR=$(pwd)
+# Clone the VyOS repository
git clone https://github.com/vyos/vyos-build.git
cd vyos-build/packages
+# Convert the comma-separated package list into an array
+IFS=',' read -r -a packages <<< "$PACKAGE_LIST"
-# build each package
+# Build each package
for pkg in "${packages[@]}"; do
cd "$pkg"
+ # Build the package using debuild
debuild -b -us -uc
cd ..
done
-# copy the packages to the output directory
+# Copy built packages to the output directory
mkdir -p "$WORKDIR/output"
cp ../*.deb "$WORKDIR/output"