define custom mirror at runtime
All checks were successful
All checks were successful
This commit is contained in:
@@ -3,12 +3,14 @@ FROM archlinux/archlinux:base-devel
|
||||
COPY scripts/entrypoint.sh /scripts/entrypoint.sh
|
||||
COPY scripts/pacman.conf.arch/pacman.conf.pl /scripts/pacman.conf.pl
|
||||
|
||||
ARG MIRROR=https://mirror.sanin.dev/arch-linux/\$repo/os/\$arch
|
||||
ARG BUILDMIRROR=https://mirror.sanin.dev/arch-linux/\$repo/os/\$arch
|
||||
|
||||
RUN sed -i "1iServer = $MIRROR" /etc/pacman.d/mirrorlist && \
|
||||
RUN cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak && \
|
||||
sed -i "1iServer = $BUILDMIRROR" /etc/pacman.d/mirrorlist && \
|
||||
pacman -Syu --noconfirm git clang sudo devtools vim bash-completion && \
|
||||
pacman -Scc --noconfirm && \
|
||||
rm -rf /var/lib/pacman/sync /var/cache/pacman/pkg && \
|
||||
mv /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist && \
|
||||
git config --global init.defaultBranch "master" && \
|
||||
chmod +x /scripts/* && \
|
||||
useradd -m user && \
|
||||
|
||||
@@ -3,12 +3,14 @@ FROM artixlinux/artixlinux:base-devel
|
||||
COPY scripts/entrypoint.sh /scripts/entrypoint.sh
|
||||
COPY scripts/pacman.conf.artix/pacman.conf.pl /scripts/pacman.conf.pl
|
||||
|
||||
ARG MIRROR=https://mirror.sanin.dev/artix-linux/\$repo/os/\$arch
|
||||
ARG BUILDMIRROR=https://mirror.sanin.dev/artix-linux/\$repo/os/\$arch
|
||||
|
||||
RUN sed -i "1iServer = $MIRROR" /etc/pacman.d/mirrorlist && \
|
||||
RUN cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak && \
|
||||
sed -i "1iServer = $BUILDMIRROR" /etc/pacman.d/mirrorlist && \
|
||||
pacman -Syu --noconfirm git clang sudo vim glibc openssh bash-completion && \
|
||||
pacman -Scc --noconfirm && \
|
||||
rm -rf /var/lib/pacman/sync /var/cache/pacman/pkg && \
|
||||
mv /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist && \
|
||||
git config --global init.defaultBranch "master" && \
|
||||
chmod +x /scripts/* && \
|
||||
useradd -m user && \
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
/scripts/pacman.conf.pl | sudo tee "/etc/pacman.conf" > /dev/null
|
||||
|
||||
if [ -n "$MIRROR" ]
|
||||
then
|
||||
sudo sed -i "1iServer = $MIRROR" /etc/pacman.d/mirrorlist
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$REPO" ]
|
||||
then
|
||||
/bin/bash
|
||||
|
||||
@@ -15,6 +15,11 @@ interface BuildEvent {
|
||||
message: any;
|
||||
}
|
||||
|
||||
interface ControllerConfig {
|
||||
"arch-mirror"?: string;
|
||||
"artix-mirror"?: string;
|
||||
}
|
||||
|
||||
function getContainerName(id: number) {
|
||||
return `archery-build-${id}`;
|
||||
}
|
||||
@@ -24,9 +29,11 @@ class BuildController extends EventEmitter {
|
||||
private running: boolean = false;
|
||||
private interval: NodeJS.Timeout;
|
||||
private cancelled: boolean = false;
|
||||
private config: ControllerConfig;
|
||||
|
||||
constructor(config = {}) {
|
||||
constructor(config: ControllerConfig = {}) {
|
||||
super();
|
||||
this.config = config;
|
||||
// this.interval = setInterval(this.triggerBuild, 60000);
|
||||
}
|
||||
|
||||
@@ -129,6 +136,7 @@ class BuildController extends EventEmitter {
|
||||
}
|
||||
|
||||
private createBuildParams = (build: Build) => {
|
||||
const customMirror = this.config?.[`${build.distro}-mirror`];
|
||||
const params = ['run', '--rm', '-e', `REPO=${build.repo}`];
|
||||
if (build.dependencies) {
|
||||
params.push('-e', `DEP=${build.dependencies}`);
|
||||
@@ -139,6 +147,9 @@ class BuildController extends EventEmitter {
|
||||
if (build.patch) {
|
||||
params.push('-e', `PATCH=${build.patch}`);
|
||||
}
|
||||
if (customMirror && typeof customMirror === 'string' && customMirror.length > 0) {
|
||||
params.push('-e', `MIRROR=${customMirror}`);
|
||||
}
|
||||
params.push('--name', getContainerName(build.id));
|
||||
params.push(docker_images[build.distro]);
|
||||
return params;
|
||||
@@ -188,4 +199,4 @@ class BuildController extends EventEmitter {
|
||||
|
||||
export default BuildController;
|
||||
export { BuildController };
|
||||
export type { BuildEvent, LogType };
|
||||
export type { BuildEvent, LogType, ControllerConfig };
|
||||
@@ -5,16 +5,18 @@ import { DB } from './DB.ts';
|
||||
import { BuildController } from './BuildController.ts';
|
||||
import type { WebConfig } from './Web.ts';
|
||||
import type { DBConfig } from './DB.ts';
|
||||
import type { ControllerConfig } from './BuildController.ts';
|
||||
|
||||
interface compositeConfig {
|
||||
web?: WebConfig,
|
||||
db?: DBConfig
|
||||
db?: DBConfig,
|
||||
controller?: ControllerConfig,
|
||||
}
|
||||
|
||||
const config: compositeConfig = JSON.parse(await fs.promises.readFile(process.env.config || process.env.CONFIG || path.join(process.cwd(), 'config', 'config.json'), 'utf-8'));
|
||||
|
||||
const web = new Web(config.web);
|
||||
const buildController = new BuildController();
|
||||
const buildController = new BuildController(config.controller);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
const db = new DB(config.db);
|
||||
web.setDB(db);
|
||||
|
||||
Reference in New Issue
Block a user