Skip to content

Commit

Permalink
Remove need for modifying dockerfiles each release (#504)
Browse files Browse the repository at this point in the history
release 2.7.4
  • Loading branch information
Idrinth authored Mar 26, 2024
1 parent cd152a7 commit ae906da
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 25 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,44 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cd containers/api-bench-gitlab-runner && docker build .
- run: cd containers/api-bench-gitlab-runner && docker build --build-arg="BUILD_VERSION=latest" --build-arg="BUILD_TIME=now" --build-arg="BUILD_HASH=${GITHUB_SHA}" .
build-gitea:
name: Build Gitea
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cd containers/api-bench-gitea-action && docker build .
- run: cd containers/api-bench-gitea-action && docker build --build-arg="BUILD_VERSION=latest" --build-arg="BUILD_TIME=now" --build-arg="BUILD_HASH=${GITHUB_SHA}" .
build-framework:
name: Build Framework
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cd containers/api-bench && docker build .
- run: cd containers/api-bench && docker build --build-arg="BUILD_VERSION=latest" --build-arg="BUILD_TIME=now" --build-arg="BUILD_HASH=${GITHUB_SHA}" .
build-microservice:
name: Build History Microservice
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cd containers/api-bench-history-microservice && docker build .
- run: cd containers/api-bench-history-microservice && docker build --build-arg="BUILD_VERSION=latest" --build-arg="BUILD_TIME=now" --build-arg="BUILD_HASH=${GITHUB_SHA}" .
build-website:
name: Build History Website
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cd containers/api-bench-history-website && docker build .
- run: cd containers/api-bench-history-website && docker build --build-arg="BUILD_VERSION=latest" --build-arg="BUILD_TIME=now" --build-arg="BUILD_HASH=${GITHUB_SHA}" .
build-build:
name: Build Build
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cd containers/api-bench-build && docker build --build-arg="BUILD_VERSION=latest" --build-arg="BUILD_TIME=now" --build-arg="BUILD_HASH=${GITHUB_SHA}" .
39 changes: 39 additions & 0 deletions containers/api-bench-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM node:21.7.1-alpine AS node

ARG BUILD_VERSION
ARG BUILD_TIME
ARG BUILD_HASH

LABEL author="Björn 'Idrinth' Büttner"
LABEL maintainer="[email protected]"
LABEL org.label-schema.name="idrinth/api-bench/build"
LABEL org.label-schema.description="An image building the @idrinth/api-bench packages."
LABEL org.label-schema.url="https://idrinth-api-ben.ch"
LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench"
LABEL org.label-schema.version=$BUILD_VERSION
LABEL org.label-schema.build-date=$BUILD_TIME
LABEL org.label-schema.vcs-ref=$BUILD_HASH
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner"
LABEL org.opencontainers.image.created=$BUILD_TIME
LABEL org.opencontainers.image.authors="[email protected]"
LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch"
LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch"
LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench"
LABEL org.opencontainers.image.version=$BUILD_VERSION
LABEL org.opencontainers.image.revision=$BUILD_HASH
LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.title="idrinth/api-bench/build"
LABEL org.opencontainers.image.description="An image building the @idrinth/api-bench packages."

ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION
ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME

RUN npm install -g --omit=dev "@idrinth/api-bench@${BUILD_VERSION}" \
&& rm /usr/local/lib/node_modules/@idrinth/api-bench/**/*.ts \
&& rm /usr/local/lib/node_modules/@idrinth/api-bench/README.md \
&& rm /usr/local/lib/node_modules/@idrinth/api-bench/index.ts \
&& rm /usr/local/lib/node_modules/@idrinth/api-bench/tsconfig.json \
&& rm -r /usr/local/lib/node_modules/@idrinth/api-bench/typings \
&& (rm -r /usr/local/lib/node_modules/@idrinth/api-bench/integration || true)
12 changes: 12 additions & 0 deletions containers/api-bench-build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @idrinth/api-bench build on alpine

This image builds api-bench on alpine and is mostly for internal usage.

## Tags

There are four groups of tags

- Single number `2` is the latest of that major version
- Single number `2.6` is the latest of that feature version
- Triple number `2.6.1` is the exact version
- `latest` is the latest minor version
9 changes: 6 additions & 3 deletions containers/api-bench-gitea-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
ARG BUILD_VERSION

FROM node:21.7.1-alpine AS node
FROM idrinth/api-bench-build:${BUILD_VERSION} AS build
FROM gitea/act_runner:0.2.6 AS gitea

COPY --from=node /usr/lib /usr/lib
COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin

RUN mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench
COPY --from=build /usr/local/lib/node_modules/@idrinth/api-bench /usr/local/lib/node_modules/@idrinth/api-bench

ARG BUILD_VERSION
ARG BUILD_TIME
ARG BUILD_HASH
Expand Down Expand Up @@ -35,6 +41,3 @@ LABEL org.opencontainers.image.description="A gitea action prepared for api-benc

ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION
ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME

RUN npm install -g --omit=dev "@idrinth/api-bench@${BUILD_VERSION}"
RUN rm /usr/local/lib/node_modules/@idrinth/api-bench/**/*.ts
9 changes: 6 additions & 3 deletions containers/api-bench-gitlab-runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG BUILD_VERSION

FROM idrinth/api-bench-build:${BUILD_VERSION} AS build
FROM node:21.7.1-alpine AS node
FROM gitlab/gitlab-runner:alpine3.19-v16.10.0 AS gitlab

Expand All @@ -6,6 +9,9 @@ COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin

RUN mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench
COPY --from=build /usr/local/lib/node_modules/@idrinth/api-bench /usr/local/lib/node_modules/@idrinth/api-bench

ARG BUILD_VERSION
ARG BUILD_TIME
ARG BUILD_HASH
Expand Down Expand Up @@ -35,6 +41,3 @@ LABEL org.opencontainers.image.description="A gitlab runner prepared for api-ben

ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION
ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME

RUN npm install -g --omit=dev "@idrinth/api-bench@${BUILD_VERSION}"
RUN rm /usr/local/lib/node_modules/@idrinth/api-bench/**/*.ts
12 changes: 7 additions & 5 deletions containers/api-bench/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG BUILD_VERSION

FROM idrinth/api-bench-build:${BUILD_VERSION} AS build
FROM node:21.7.1-alpine AS node

ARG BUILD_VERSION
Expand Down Expand Up @@ -30,11 +33,10 @@ LABEL org.opencontainers.image.description="An image prepared for api-bench usag
ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION
ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME

RUN npm install -g --omit=dev "@idrinth/api-bench@${BUILD_VERSION}"
RUN rm /usr/local/lib/node_modules/@idrinth/api-bench/**/*.ts
RUN mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench
COPY --from=build /usr/local/lib/node_modules/@idrinth/api-bench /usr/local/lib/node_modules/@idrinth/api-bench

RUN mkdir /project
VOLUME /project
WORKDIR /project
VOLUME /project

ENTRYPOINT ["iabr"]
ENTRYPOINT ["npm"]
2 changes: 1 addition & 1 deletion documentation-website/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@idrinth/api-bench/website",
"private": true,
"version": "2.7.3",
"version": "2.7.4",
"license": "MIT",
"homepage": "https://idrinth-api-ben.ch",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions framework/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/tools
/result.html
/.markdownlint.yaml
/integration
4 changes: 2 additions & 2 deletions framework/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@idrinth/api-bench",
"description": "A library to benchmark apis, no matter if rest or soap",
"license": "MIT",
"version": "2.7.3",
"version": "2.7.4",
"homepage": "https://idrinth-api-ben.ch",
"type": "module",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion history-microservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@idrinth/api-bench",
"description": "A library to benchmark apis, no matter if rest or soap",
"license": "MIT",
"version": "2.7.3",
"version": "2.7.4",
"homepage": "https://idrinth-api-ben.ch",
"type": "module",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion history-website/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@idrinth/api-bench/history/ui",
"private": true,
"version": "2.7.3",
"version": "2.7.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idrinth/api-bench/root",
"version": "2.7.3",
"version": "2.7.4",
"description": "",
"license": "MIT",
"homepage": "https://idrinth-api-ben.ch",
Expand All @@ -12,6 +12,7 @@
"lint-md": "markdownlint *.md .github/**/*.md",
"coai": "node tools/checkout-and-install.js",
"publish": "node tools/publish.js",
"docker": "node tools/rebuild-images.js",
"spellcheck": "spellchecker",
"setup": "node tools/setup.js",
"regression": "node tools/regression.js"
Expand Down
1 change: 1 addition & 0 deletions tools/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ rl.question(
`--build-arg="BUILD_HASH=${ exec('git rev-parse --short HEAD',) }"`,
];
for (const image of [
'api-bench-build',
'api-bench',
'api-bench-gitea-action',
'api-bench-gitlab-runner',
Expand Down
55 changes: 55 additions & 0 deletions tools/rebuild-images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
rmSync,
writeFileSync,
} from 'fs';
import exec from './src/exec.js';
import readline from 'readline';
import {
EXIT_SUCCESS,
} from './src/constants.js';

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
},);
rl.question('Versions(space separated): ', (versions,) => {
rl.question('Docker password: ', (password,) => {
writeFileSync('./pw', password,);
exec('cat pw | docker login -u idrinth --password-stdin', true,);
rmSync('./pw',);
for (const image of [
'api-bench-build',
'api-bench',
'api-bench-gitea-action',
'api-bench-gitlab-runner',
]) {
for (const version of versions.split(' ',)) {
if (version && version.match(/^\d+\.\d+\.\d+$/u,)) {
const main = version.replace(/\..+$/u, '',);
const feature = version.replace(/\.[^.]+$/u, '',);
const args = [
`--build-arg="BUILD_VERSION=${ version }"`,
`--build-arg="BUILD_TIME=${ new Date().toISOString() }"`,
`--build-arg="BUILD_HASH=${ exec('git rev-parse --short HEAD',) }"`,
];
const tags = [
`-t idrinth/${ image }:latest`,
`-t idrinth/${ image }:${ version }`,
`-t idrinth/${ image }:${ feature }`,
`-t idrinth/${ image }:${ main }`,
];
const params = [
...args,
...tags,
];
exec(
`cd containers/${ image } && docker build ${ params.join(' ',) } .`,
true,
);
}
}
exec(`docker push -a idrinth/${ image }`, true,);
}
process.emit(EXIT_SUCCESS,);
},);
},);

0 comments on commit ae906da

Please sign in to comment.