Compare commits
10 Commits
a6b850fddd
...
1fea301ecf
Author | SHA1 | Date | |
---|---|---|---|
1fea301ecf | |||
9722c4f992 | |||
96b9d3210c | |||
14f0d494be | |||
7d07873536 | |||
69868d0f7c | |||
e1230b3fde | |||
c83b7535c1 | |||
4a3ce70751 | |||
97440f1352 |
@ -17,8 +17,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
DH_REGISTRY: docker.io
|
DH_REGISTRY: docker.io
|
||||||
GH_REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
REPOSITORY: ${{ github.event.repository.name }}
|
REPOSITORY: ${{ github.event.repository.name }}
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
permissions:
|
permissions:
|
||||||
@ -43,59 +41,23 @@ jobs:
|
|||||||
username: ${{ env.DOCKER_USERNAME }}
|
username: ${{ env.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.GH_REGISTRY }}
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata for release Docker image
|
- name: Extract metadata for release Docker image
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_USERNAME }}/${{ env.REPOSITORY }}
|
${{ env.DOCKER_USERNAME }}/${{ env.REPOSITORY }}
|
||||||
${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest
|
type=raw,value=latest
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
- name: Extract metadata for develop Docker image
|
|
||||||
if: "!startsWith(github.ref, 'refs/tags/v')"
|
|
||||||
id: meta-develop
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
|
|
||||||
- name: Build and push release Docker image
|
- name: Build and push release Docker image
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
target: deploy
|
target: deploy
|
||||||
push: true
|
push: startsWith(github.ref, 'refs/tags/v')
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
cache-from: type=gha,scope=${{ github.workflow }}
|
|
||||||
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
|
||||||
|
|
||||||
- name: Build and push develop Docker image
|
|
||||||
if: "!startsWith(github.ref, 'refs/tags/v')"
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
target: deploy
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta-develop.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-develop.outputs.labels }}
|
|
||||||
platforms: linux/amd64
|
|
||||||
cache-from: type=gha,scope=${{ github.workflow }}
|
|
||||||
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
|
@ -39,22 +39,22 @@ jobs:
|
|||||||
run: echo "DEPLOY=true" >> $GITHUB_ENV
|
run: echo "DEPLOY=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
install: true
|
install: true
|
||||||
|
|
||||||
- name: Log in to the Docker Hub
|
- name: Log in to the Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: https://github.com/docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
uses: docker/build-push-action@v6
|
uses: https://github.com/docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
push: ${{ env.DEPLOY }}
|
push: ${{ env.DEPLOY }}
|
||||||
pull: true
|
pull: true
|
@ -5,13 +5,13 @@ WORKDIR /build
|
|||||||
COPY ./package*json ./
|
COPY ./package*json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN node --experimental-strip-types build.ts && \
|
RUN npm run build && \
|
||||||
npm exec tsc && \
|
npm exec tsc && \
|
||||||
npm ci --only=production --omit=dev
|
npm ci --only=production --omit=dev
|
||||||
|
|
||||||
FROM base as deploy
|
FROM base AS deploy
|
||||||
|
|
||||||
WORKDIR /srv/abt
|
WORKDIR /srv/archery
|
||||||
|
|
||||||
RUN apk add --no-cache docker-cli
|
RUN apk add --no-cache docker-cli
|
||||||
COPY --from=build-env /build .
|
COPY --from=build-env /build .
|
||||||
|
171
build.ts
171
build.ts
@ -1,171 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import child_process from 'child_process';
|
|
||||||
import uglifyjs from "uglify-js";
|
|
||||||
import * as sass from 'sass';
|
|
||||||
import * as csso from 'csso';
|
|
||||||
|
|
||||||
const spawn = child_process.spawn;
|
|
||||||
const fsp = fs.promises;
|
|
||||||
const STYLESDIR = 'styles';
|
|
||||||
const SCRIPTSDIR = 'scripts';
|
|
||||||
const IMAGESDIR = path.join('assets', 'images');
|
|
||||||
const STYLEOUTDIR = process.env.STYLEOUTDIR || path.join(import.meta.dirname, 'assets', 'css');
|
|
||||||
const SCRIPTSOUTDIR = process.env.SCRIPTSOUTDIR || path.join(import.meta.dirname, 'assets', 'js');
|
|
||||||
const IMAGESOUTDIR = process.env.IMAGESOUTDIR || path.join(import.meta.dirname, 'assets', 'webp');
|
|
||||||
const STYLEOUTFILE = process.env.STYLEOUTFILE || 'styles.css';
|
|
||||||
const SQUASH = new RegExp('^[0-9]+-');
|
|
||||||
|
|
||||||
async function emptyDir(dir: string) {
|
|
||||||
await Promise.all((await fsp.readdir(dir, { withFileTypes: true })).map(f => path.join(dir, f.name)).map(p => fsp.rm(p, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function mkdir(dir: string | string[]) {
|
|
||||||
if (typeof dir === 'string') {
|
|
||||||
await fsp.mkdir(dir, { recursive: true });
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await Promise.all(dir.map(mkdir));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process styles
|
|
||||||
async function styles() {
|
|
||||||
await mkdir([STYLEOUTDIR, STYLESDIR]);
|
|
||||||
await emptyDir(STYLEOUTDIR);
|
|
||||||
let styles: string[] = [];
|
|
||||||
let files = await fsp.readdir(STYLESDIR);
|
|
||||||
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
|
||||||
let p = path.join(STYLESDIR, f);
|
|
||||||
console.log(`Processing style ${p}`);
|
|
||||||
let style = sass.compile(p).css;
|
|
||||||
if (f.charAt(0) !== '_') {
|
|
||||||
if (SQUASH.test(f)) {
|
|
||||||
styles.push(style);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let o = path.join(STYLEOUTDIR, f.substring(0, f.lastIndexOf('.')) + '.css');
|
|
||||||
await fsp.writeFile(o, csso.minify(style).css);
|
|
||||||
console.log(`Wrote ${o}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res(0);
|
|
||||||
})));
|
|
||||||
let out = csso.minify(styles.join('\n')).css;
|
|
||||||
let outpath = path.join(STYLEOUTDIR, STYLEOUTFILE);
|
|
||||||
await fsp.writeFile(outpath, out);
|
|
||||||
console.log(`Wrote ${outpath}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process scripts
|
|
||||||
async function scripts() {
|
|
||||||
await mkdir([SCRIPTSOUTDIR, SCRIPTSDIR]);
|
|
||||||
await emptyDir(SCRIPTSOUTDIR);
|
|
||||||
let files = await fsp.readdir(SCRIPTSDIR);
|
|
||||||
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
|
||||||
let p = path.join(SCRIPTSDIR, f);
|
|
||||||
let o = path.join(SCRIPTSOUTDIR, f);
|
|
||||||
console.log(`Processing script ${p}`);
|
|
||||||
try {
|
|
||||||
await fsp.writeFile(o, uglifyjs.minify((await fsp.readFile(p)).toString()).code);
|
|
||||||
console.log(`Wrote ${o}`);
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
console.log(`error writing ${o}: ${ex}`);
|
|
||||||
}
|
|
||||||
res(0);
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process images
|
|
||||||
async function images(dir = '') {
|
|
||||||
let p = path.join(IMAGESDIR, dir);
|
|
||||||
await mkdir(p);
|
|
||||||
if (dir.length === 0) {
|
|
||||||
await mkdir(IMAGESOUTDIR)
|
|
||||||
await emptyDir(IMAGESOUTDIR);
|
|
||||||
}
|
|
||||||
let files = await fsp.readdir(p, {
|
|
||||||
withFileTypes: true
|
|
||||||
});
|
|
||||||
if (files.length) {
|
|
||||||
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
|
||||||
if (f.isFile()) {
|
|
||||||
let outDir = path.join(IMAGESOUTDIR, dir);
|
|
||||||
let infile = path.join(p, f.name);
|
|
||||||
let outfile = path.join(outDir, f.name.substring(0, f.name.lastIndexOf('.')) + '.webp');
|
|
||||||
await mkdir(outDir);
|
|
||||||
console.log(`Processing image ${infile}`)
|
|
||||||
let process = spawn('cwebp', ['-mt', '-q', '50', infile, '-o', outfile]);
|
|
||||||
let timeout = setTimeout(() => {
|
|
||||||
reject('Timed out');
|
|
||||||
process.kill();
|
|
||||||
}, 30000);
|
|
||||||
process.on('exit', async (code) => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
if (code === 0) {
|
|
||||||
console.log(`Wrote ${outfile}`);
|
|
||||||
res(null);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
reject(code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (f.isDirectory()) {
|
|
||||||
images(path.join(dir, f.name)).then(res).catch(reject);
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isAbortError(err: unknown): boolean {
|
|
||||||
return typeof err === 'object' && err !== null && 'name' in err && err.name === 'AbortError';
|
|
||||||
}
|
|
||||||
|
|
||||||
(async function () {
|
|
||||||
await Promise.all([styles(), scripts(), images()]);
|
|
||||||
if (process.argv.indexOf('--watch') >= 0) {
|
|
||||||
console.log('watching for changes...');
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
const watcher = fsp.watch(STYLESDIR);
|
|
||||||
for await (const _ of watcher)
|
|
||||||
await styles();
|
|
||||||
} catch (err) {
|
|
||||||
if (isAbortError(err))
|
|
||||||
return;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
const watcher = fsp.watch(SCRIPTSDIR);
|
|
||||||
for await (const _ of watcher)
|
|
||||||
await scripts();
|
|
||||||
} catch (err) {
|
|
||||||
if (isAbortError(err))
|
|
||||||
return;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
const watcher = fsp.watch(IMAGESDIR, {
|
|
||||||
recursive: true // no Linux ☹️
|
|
||||||
});
|
|
||||||
for await (const _ of watcher)
|
|
||||||
await images();
|
|
||||||
} catch (err) {
|
|
||||||
if (isAbortError(err))
|
|
||||||
return;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
})();
|
|
@ -1 +1,9 @@
|
|||||||
{}
|
{
|
||||||
|
"db": {
|
||||||
|
"host": "postgres",
|
||||||
|
"password": "correcthorse"
|
||||||
|
},
|
||||||
|
"web": {
|
||||||
|
"port": 8080
|
||||||
|
}
|
||||||
|
}
|
@ -7,8 +7,10 @@ services:
|
|||||||
context: ./
|
context: ./
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./config:/srv/abt/config
|
- ./config:/srv/archery/config
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
environment:
|
||||||
|
PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
restart: "no"
|
restart: "no"
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
|
77
package-lock.json
generated
77
package-lock.json
generated
@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "archery",
|
"name": "archery",
|
||||||
"version": "0.0.2",
|
"version": "0.1.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "archery",
|
"name": "archery",
|
||||||
"version": "0.0.2",
|
"version": "0.1.6",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.20.3",
|
"body-parser": "^1.20.3",
|
||||||
"ejs": "3.1.10",
|
"ejs": "3.1.10",
|
||||||
"express": "^4.21.2",
|
"express": "^4.21.2",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"pg": "^8.13.1",
|
"pg": "^8.15.6",
|
||||||
"pg-hstore": "^2.3.4",
|
"pg-hstore": "^2.3.4",
|
||||||
"sequelize": "^6.37.5"
|
"sequelize": "^6.37.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csso": "5.0.4",
|
"@types/csso": "5.0.4",
|
||||||
@ -23,9 +23,7 @@
|
|||||||
"@types/express-ws": "3.0.5",
|
"@types/express-ws": "3.0.5",
|
||||||
"@types/node": "^22.10.5",
|
"@types/node": "^22.10.5",
|
||||||
"@types/uglify-js": "3.17.5",
|
"@types/uglify-js": "3.17.5",
|
||||||
"csso": "5.0.5",
|
"forking-build-shit": "0.0.2"
|
||||||
"sass": "1.83.1",
|
|
||||||
"uglify-js": "3.19.3"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "5.7.3"
|
"typescript": "5.7.3"
|
||||||
@ -1031,6 +1029,21 @@
|
|||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/forking-build-shit": {
|
||||||
|
"version": "0.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/forking-build-shit/-/forking-build-shit-0.0.2.tgz",
|
||||||
|
"integrity": "sha512-1qpXIK3nX8ZPTbwojsqxjTp5qDITX24MkKaX/8p6mMkIAQiVul1nhdYCAFLpnpnLon87Ru1exlJKhkvIKT7b+A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"csso": "5.0.5",
|
||||||
|
"sass": "1.86.0",
|
||||||
|
"uglify-js": "3.19.3"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"build-shit": "bin/build-shit.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/forwarded": {
|
"node_modules/forwarded": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||||
@ -1446,14 +1459,14 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/pg": {
|
"node_modules/pg": {
|
||||||
"version": "8.13.1",
|
"version": "8.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.13.1.tgz",
|
"resolved": "https://registry.npmjs.org/pg/-/pg-8.15.6.tgz",
|
||||||
"integrity": "sha512-OUir1A0rPNZlX//c7ksiu7crsGZTKSOXJPgtNiHGIlC9H0lO+NC6ZDYksSgBYY/thSWhnSRBv8w1lieNNGATNQ==",
|
"integrity": "sha512-yvao7YI3GdmmrslNVsZgx9PfntfWrnXwtR+K/DjI0I/sTKif4Z623um+sjVZ1hk5670B+ODjvHDAckKdjmPTsg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pg-connection-string": "^2.7.0",
|
"pg-connection-string": "^2.8.5",
|
||||||
"pg-pool": "^3.7.0",
|
"pg-pool": "^3.9.6",
|
||||||
"pg-protocol": "^1.7.0",
|
"pg-protocol": "^1.9.5",
|
||||||
"pg-types": "^2.1.0",
|
"pg-types": "^2.1.0",
|
||||||
"pgpass": "1.x"
|
"pgpass": "1.x"
|
||||||
},
|
},
|
||||||
@ -1461,7 +1474,7 @@
|
|||||||
"node": ">= 8.0.0"
|
"node": ">= 8.0.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"pg-cloudflare": "^1.1.1"
|
"pg-cloudflare": "^1.2.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pg-native": ">=3.0.1"
|
"pg-native": ">=3.0.1"
|
||||||
@ -1473,16 +1486,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pg-cloudflare": {
|
"node_modules/pg-cloudflare": {
|
||||||
"version": "1.1.1",
|
"version": "1.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.5.tgz",
|
||||||
"integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==",
|
"integrity": "sha512-OOX22Vt0vOSRrdoUPKJ8Wi2OpE/o/h9T8X1s4qSkCedbNah9ei2W2765be8iMVxQUsvgT7zIAT2eIa9fs5+vtg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"node_modules/pg-connection-string": {
|
"node_modules/pg-connection-string": {
|
||||||
"version": "2.7.0",
|
"version": "2.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.8.5.tgz",
|
||||||
"integrity": "sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA==",
|
"integrity": "sha512-Ni8FuZ8yAF+sWZzojvtLE2b03cqjO5jNULcHFfM9ZZ0/JXrgom5pBREbtnAw7oxsxJqHw9Nz/XWORUEL3/IFow==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/pg-hstore": {
|
"node_modules/pg-hstore": {
|
||||||
@ -1507,18 +1520,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pg-pool": {
|
"node_modules/pg-pool": {
|
||||||
"version": "3.7.0",
|
"version": "3.9.6",
|
||||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.9.6.tgz",
|
||||||
"integrity": "sha512-ZOBQForurqh4zZWjrgSwwAtzJ7QiRX0ovFkZr2klsen3Nm0aoh33Ls0fzfv3imeH/nw/O27cjdz5kzYJfeGp/g==",
|
"integrity": "sha512-rFen0G7adh1YmgvrmE5IPIqbb+IgEzENUm+tzm6MLLDSlPRoZVhzU1WdML9PV2W5GOdRA9qBKURlbt1OsXOsPw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pg": ">=8.0"
|
"pg": ">=8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pg-protocol": {
|
"node_modules/pg-protocol": {
|
||||||
"version": "1.7.0",
|
"version": "1.9.5",
|
||||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.9.5.tgz",
|
||||||
"integrity": "sha512-hTK/mE36i8fDDhgDFjy6xNOG+LCorxLG3WO17tku+ij6sVHXh1jQUJ8hYAnRhNla4QVD2H8er/FOjc/+EgC6yQ==",
|
"integrity": "sha512-DYTWtWpfd5FOro3UnAfwvhD8jh59r2ig8bPtc9H8Ds7MscE/9NYruUQWFAOuraRl29jwcT2kyMFQ3MxeaVjUhg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/pg-types": {
|
"node_modules/pg-types": {
|
||||||
@ -1698,9 +1711,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/sass": {
|
"node_modules/sass": {
|
||||||
"version": "1.83.1",
|
"version": "1.86.0",
|
||||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.83.1.tgz",
|
"resolved": "https://registry.npmjs.org/sass/-/sass-1.86.0.tgz",
|
||||||
"integrity": "sha512-EVJbDaEs4Rr3F0glJzFSOvtg2/oy2V/YrGFPqPY24UqcLDWcI9ZY5sN+qyO3c/QCZwzgfirvhXvINiJCE/OLcA==",
|
"integrity": "sha512-zV8vGUld/+mP4KbMLJMX7TyGCuUp7hnkOScgCMsWuHtns8CWBoz+vmEhoGMXsaJrbUP8gj+F1dLvVe79sK8UdA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -1770,9 +1783,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/sequelize": {
|
"node_modules/sequelize": {
|
||||||
"version": "6.37.5",
|
"version": "6.37.7",
|
||||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.5.tgz",
|
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.7.tgz",
|
||||||
"integrity": "sha512-10WA4poUb3XWnUROThqL2Apq9C2NhyV1xHPMZuybNMCucDsbbFuKg51jhmyvvAUyUqCiimwTZamc3AHhMoBr2Q==",
|
"integrity": "sha512-mCnh83zuz7kQxxJirtFD7q6Huy6liPanI67BSlbzSYgVNl5eXVdE2CN1FuAeZwG1SNpGsNRCV+bJAVVnykZAFA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "archery",
|
"name": "archery",
|
||||||
"version": "0.0.2",
|
"version": "0.1.6",
|
||||||
"description": "Build Arch packages through a web interface",
|
"description": "Build Arch packages through a web interface",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"docker",
|
"docker",
|
||||||
@ -24,9 +24,9 @@
|
|||||||
"ejs": "3.1.10",
|
"ejs": "3.1.10",
|
||||||
"express": "^4.21.2",
|
"express": "^4.21.2",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"pg": "^8.13.1",
|
"pg": "^8.15.6",
|
||||||
"pg-hstore": "^2.3.4",
|
"pg-hstore": "^2.3.4",
|
||||||
"sequelize": "^6.37.5"
|
"sequelize": "^6.37.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csso": "5.0.4",
|
"@types/csso": "5.0.4",
|
||||||
@ -34,11 +34,13 @@
|
|||||||
"@types/express-ws": "3.0.5",
|
"@types/express-ws": "3.0.5",
|
||||||
"@types/node": "^22.10.5",
|
"@types/node": "^22.10.5",
|
||||||
"@types/uglify-js": "3.17.5",
|
"@types/uglify-js": "3.17.5",
|
||||||
"csso": "5.0.5",
|
"forking-build-shit": "0.0.2"
|
||||||
"sass": "1.83.1",
|
|
||||||
"uglify-js": "3.19.3"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "5.7.3"
|
"typescript": "5.7.3"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "npx build-shit",
|
||||||
|
"watch": "npx build-shit --watch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
readme.md
Normal file
6
readme.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Archery
|
||||||
|
## Build system for pacman
|
||||||
|
|
||||||
|
Quickly trigger build jobs on a remote system (perhaps one with more RAM?) for debugging packaging issues. Switch between Artix and Arch to compare builds. Enable testing or staging repos in a single click.
|
||||||
|
|
||||||
|
Consult [docker-compose.yml](docker-compose.yml) and [config.example.json](config/config.example.json) to get an understanding of how to deploy Archery.
|
@ -13,12 +13,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add log line to the DOM
|
* Add log line to the DOM
|
||||||
* @param {string} str
|
* @param {string[]} str
|
||||||
*/
|
*/
|
||||||
function appendLine(str, e = false) {
|
function appendLines(str, e = false) {
|
||||||
const p = document.createElement('p');
|
str.forEach(line => {
|
||||||
p.appendChild(document.createTextNode(str));
|
const p = document.createElement('p');
|
||||||
logContainer.appendChild(p);
|
p.appendChild(document.createTextNode(line));
|
||||||
|
logContainer.appendChild(p);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +32,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split string by newline char
|
||||||
|
* @param {string} str
|
||||||
|
*/
|
||||||
|
function splitLines(str) {
|
||||||
|
return str.split('\n').map(line => line.substring(line.lastIndexOf('\r') + 1));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establish websocket connection
|
* Establish websocket connection
|
||||||
*/
|
*/
|
||||||
@ -41,7 +51,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
var ws = new WebSocket(new_uri);
|
var ws = new WebSocket(new_uri);
|
||||||
|
|
||||||
ws.onmessage = function (message) {
|
ws.onmessage = function (message) {
|
||||||
console.log('Got message: ', message);
|
|
||||||
const buildEvent = JSON.parse(message.data);
|
const buildEvent = JSON.parse(message.data);
|
||||||
|
|
||||||
if (buildEvent.type === 'finish') {
|
if (buildEvent.type === 'finish') {
|
||||||
@ -49,7 +58,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
buildStatusTxt.replaceChild(document.createTextNode(buildEvent.message), buildStatusTxt.firstChild);
|
buildStatusTxt.replaceChild(document.createTextNode(buildEvent.message), buildStatusTxt.firstChild);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
appendLine(buildEvent.message, buildEvent.type === 'err');
|
appendLines(splitLines(buildEvent.message), buildEvent.type === 'err');
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class DB {
|
|||||||
private sequelize: Sequelize;
|
private sequelize: Sequelize;
|
||||||
|
|
||||||
constructor(config: DBConfig = {}) {
|
constructor(config: DBConfig = {}) {
|
||||||
this.sequelize = new Sequelize(config.db || 'archery', config.user || 'archery', config.password || '', {
|
this.sequelize = new Sequelize(config.db || 'archery', config.user || 'archery', process.env.PASSWORD || config.password || '', {
|
||||||
host: config.host || 'localhost',
|
host: config.host || 'localhost',
|
||||||
port: config.port || 5432,
|
port: config.port || 5432,
|
||||||
dialect: 'postgres'
|
dialect: 'postgres'
|
||||||
@ -269,4 +269,4 @@ class DB {
|
|||||||
|
|
||||||
export default DB;
|
export default DB;
|
||||||
export { DB };
|
export { DB };
|
||||||
export type { DBConfig, Status, Build };
|
export type { DBConfig, Status, Build, LogChunk };
|
||||||
|
@ -4,7 +4,7 @@ import type { Express } from "express";
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import expressWs from "express-ws";
|
import expressWs from "express-ws";
|
||||||
import bodyParser from "body-parser";
|
import bodyParser from "body-parser";
|
||||||
import type { DB } from "./DB.ts";
|
import type { DB, LogChunk } from "./DB.ts";
|
||||||
import type { BuildController, BuildEvent } from "./BuildController.ts";
|
import type { BuildController, BuildEvent } from "./BuildController.ts";
|
||||||
|
|
||||||
interface WebConfig {
|
interface WebConfig {
|
||||||
@ -29,6 +29,10 @@ function timeElapsed(date1: Date, date2: Date) {
|
|||||||
return `${hours}:${minutes}:${seconds}`;
|
return `${hours}:${minutes}:${seconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function splitLines(lines: LogChunk[]) {
|
||||||
|
return lines.map(logChunk => logChunk.chunk.split('\n')).flat().map(line => line.substring(line.lastIndexOf('\r') + 1));
|
||||||
|
}
|
||||||
|
|
||||||
class Web {
|
class Web {
|
||||||
private _webserver: http.Server | null = null;
|
private _webserver: http.Server | null = null;
|
||||||
private db: DB;
|
private db: DB;
|
||||||
@ -106,7 +110,7 @@ class Web {
|
|||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const log = (await this.db.getLog(build.id)).map(logChunk => logChunk.chunk.split('\n')).flat();
|
const log = splitLines(await this.db.getLog(build.id));
|
||||||
|
|
||||||
res.render('build', {
|
res.render('build', {
|
||||||
page: {
|
page: {
|
||||||
|
@ -11,7 +11,7 @@ interface compositeConfig {
|
|||||||
db?: DBConfig
|
db?: DBConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
const config: compositeConfig = JSON.parse(await fs.promises.readFile(process.env.config || path.join('config', 'config.json'), 'utf-8'));
|
const config: compositeConfig = JSON.parse(await fs.promises.readFile(process.env.config || process.env.CONFIG || path.join('config', 'config.json'), 'utf-8'));
|
||||||
|
|
||||||
const web = new Web(config.web);
|
const web = new Web(config.web);
|
||||||
const buildController = new BuildController();
|
const buildController = new BuildController();
|
||||||
|
@ -54,6 +54,7 @@ table {
|
|||||||
background-color: #2a2a2a;
|
background-color: #2a2a2a;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-width: 42em;
|
||||||
}
|
}
|
||||||
|
|
||||||
td,
|
td,
|
||||||
@ -120,7 +121,7 @@ input[type="submit"] {
|
|||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
background: var(--primary);
|
background: var(--primary);
|
||||||
width: 16em;
|
width: 13rem;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -183,7 +184,7 @@ input[type="submit"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
margin-left: 16em;
|
margin-left: 13rem;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
|
||||||
&.no-padding {
|
&.no-padding {
|
||||||
@ -200,6 +201,8 @@ input[type="submit"] {
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: auto 1fr;
|
||||||
gap: .65em;
|
gap: .65em;
|
||||||
|
word-break: keep-all;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
.span-2 {
|
.span-2 {
|
||||||
grid-column: span 2;
|
grid-column: span 2;
|
||||||
@ -207,12 +210,13 @@ input[type="submit"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.logs {
|
.logs {
|
||||||
|
width: fit-content;
|
||||||
|
min-width: 100%;
|
||||||
font-family: 'Courier New', monospace;
|
font-family: 'Courier New', monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
border-left: #d96a14 .2em solid;
|
border-left: #d96a14 .2em solid;
|
||||||
background: #2a2a2a;
|
background: #2a2a2a;
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
overflow-x: auto;
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
|
|
||||||
p {
|
p {
|
||||||
padding: .1em .5em;
|
padding: .1em .5em;
|
||||||
@ -253,7 +257,7 @@ input[type="submit"] {
|
|||||||
right: 1.3em;
|
right: 1.3em;
|
||||||
bottom: 1.6em;
|
bottom: 1.6em;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
background-color: rgba(15,15,15,.8);
|
background-color: rgba(15, 15, 15, .8);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
|
@ -15,4 +15,32 @@
|
|||||||
.content {
|
.content {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.logs {
|
||||||
|
font-size: 0.75em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width:28rem) {
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-size: 13pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-2col {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
|
||||||
|
.span-2 {
|
||||||
|
grid-column: initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
&> :nth-last-child(n+2):nth-child(odd) {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1em;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: ":";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,13 +10,15 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>Build #<%= build.id %></h1>
|
<h1>Build #<%= build.id %></h1>
|
||||||
<h2 id="buildStatus"><%= build.status %></h2>
|
<h2 id="buildStatus"><%= build.status %></h2>
|
||||||
<div class="grid-2col">
|
<div class="overflow-x">
|
||||||
<label>Repo</label> <span><%= build.repo %></span>
|
<div class="grid-2col">
|
||||||
<label>Commit</label> <span><% if (build.commit) { %><%= build.commit %><% } else { %>latest<% } %></span>
|
<label>Repo</label> <span><%= build.repo %></span>
|
||||||
<label>Patch</label> <span><% if (build.patch) { %><a href="/build/<%= build.id %>/patch">patch file</a><% } else { %>none<% } %></span>
|
<label>Commit</label> <span><% if (build.commit) { %><%= build.commit %><% } else { %>latest<% } %></span>
|
||||||
<label>Distro</label> <span><%= build.distro %></span>
|
<label>Patch</label> <span><% if (build.patch) { %><a href="/build/<%= build.id %>/patch">patch file</a><% } else { %>none<% } %></span>
|
||||||
<label>Dependencies</label> <span><%= build.dependencies %></span>
|
<label>Distro</label> <span><%= build.distro %></span>
|
||||||
<label>Start time</label> <span class="to-local-time"><%= build.startTime %></span>
|
<label>Dependencies</label> <span><%= build.dependencies %></span>
|
||||||
|
<label>Start time</label> <span class="to-local-time"><%= build.startTime %></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if (!ended) { %>
|
<% if (!ended) { %>
|
||||||
<div>
|
<div>
|
||||||
@ -24,11 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<p><a href="/build/<%= build.id %>/logs">Full logs</a></p>
|
<p><a href="/build/<%= build.id %>/logs">Full logs</a></p>
|
||||||
<div class="logs" id="logs">
|
<pre class="overflow-x"><div class="logs" id="logs"><% (log || []).forEach(line => { %><p><%= line %></p><% }) %></div></pre>
|
||||||
<% (log || []).forEach(line => { %>
|
|
||||||
<p><%= line %></p>
|
|
||||||
<% }) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% if (!ended) { %>
|
<% if (!ended) { %>
|
||||||
<label id="followCheckmarkContainer" title="Follow logs">
|
<label id="followCheckmarkContainer" title="Follow logs">
|
||||||
@ -39,7 +37,7 @@
|
|||||||
<%- include("footer", locals) %>
|
<%- include("footer", locals) %>
|
||||||
<script src="/assets/js/timezone.js?v1" nonce="<%= cspNonce %>"></script>
|
<script src="/assets/js/timezone.js?v1" nonce="<%= cspNonce %>"></script>
|
||||||
<% if (!ended) { %>
|
<% if (!ended) { %>
|
||||||
<script src="/assets/js/build.js?v1" nonce="<%= cspNonce %>"></script>
|
<script src="/assets/js/build.js?v2" nonce="<%= cspNonce %>"></script>
|
||||||
<% } %>
|
<% } %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<div class="content footer">
|
<div class="content footer">
|
||||||
<footer>
|
<footer>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href="/">Home</a></li>
|
||||||
<li>Developed by Cory Sanin</li>
|
<li>Developed by Cory Sanin</li>
|
||||||
<li><a href="https://github.com/CorySanin/archery">Source</a></li>
|
<li><a href="https://git.sanin.dev/corysanin/archery">Source</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
@ -14,7 +14,7 @@
|
|||||||
<link rel="canonical" href="<%= page.canonical%>"/>
|
<link rel="canonical" href="<%= page.canonical%>"/>
|
||||||
<% } %>
|
<% } %>
|
||||||
<link rel="shortcut icon" href="/assets/svg/favicon.svg">
|
<link rel="shortcut icon" href="/assets/svg/favicon.svg">
|
||||||
<link rel="stylesheet" href="/assets/css/styles.css?v1">
|
<link rel="stylesheet" href="/assets/css/styles.css?v3">
|
||||||
<script nonce="<%= cspNonce %>">
|
<script nonce="<%= cspNonce %>">
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
document.body.classList.remove('preload');
|
document.body.classList.remove('preload');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user