Skip to content

Commit cb5ba30

Browse files
committed
feat: add local and ci build scripts
1 parent 4b0ddb5 commit cb5ba30

13 files changed

+728
-7
lines changed

.build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include:
2+
remote: "https://github.com/git-developer/docker-support/raw/v3.1.0/gitlab-ci/docker-template.yml"
3+
4+
variables:
5+
IMAGE_NAME: "${CI_PROJECT_NAMESPACE}/usbip-${SERVICE}"
6+
IMAGE_VERSION: "${DISTRO}"
7+
IMAGE_PLATFORMS: 'linux/amd64,linux/i386,linux/arm64,linux/arm'
8+
BUILD_ARGS: "SERVICE=${SERVICE}"
9+
DEFAULT_DISTRO: "alpine"
10+
11+
read_application_tags:
12+
stage: post_checkout
13+
image: busybox
14+
artifacts:
15+
paths:
16+
- tags
17+
script:
18+
- set -euo pipefail
19+
- mkdir -p tags
20+
- build_date="$(date --utc -I)"
21+
- echo >tags/build-date "${IMAGE_NAME}:${build_date}-${DISTRO}"
22+
- |
23+
if test "${DISTRO}" = "${DEFAULT_DISTRO}"; then
24+
echo >tags/default-build-date "${IMAGE_NAME}:${build_date}"
25+
echo >tags/default-latest "${IMAGE_NAME}:latest"
26+
fi
27+
28+
prepare_dockerfile:
29+
stage: pre_build
30+
dependencies: []
31+
image: busybox
32+
artifacts:
33+
paths:
34+
- "${BUILD_CONTEXT}/Dockerfile"
35+
script:
36+
- test -e "${BUILD_CONTEXT}/Dockerfile.${DISTRO}" && ln -s "Dockerfile.${DISTRO}" "${BUILD_CONTEXT}/Dockerfile"
37+
38+
build_image:
39+
dependencies:
40+
- prepare_build_arguments
41+
- prepare_dockerfile

.gitlab-ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
build-services:
2+
trigger:
3+
include: .build.yml
4+
parallel:
5+
matrix:
6+
- SERVICE: [server, client]
7+
DISTRO: [alpine, buster, bullseye]

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

build

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/sh
22
set -eu
3-
distros="${1:-*}"
4-
dir="$(dirname "${0}")"
5-
find "${dir}" -maxdepth 1 -name "Dockerfile.${distros}" -printf '%f\n' \
3+
distros="${1:-.*}"
4+
build_context="$(dirname "${0}")/image"
5+
find "${build_context}" -maxdepth 1 -regex "${build_context}/Dockerfile\.${distros}" -printf '%f\n' \
66
| while read file; do
77
distro="${file##Dockerfile.}"
8-
find "${dir}" -maxdepth 1 -type d ! -iname ".*" -printf '%f\n' \
8+
find "${build_context}" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' \
99
| while read service; do
1010
docker build \
1111
-t "ckware/usbip-${service}:${distro}" \
12-
-f "${dir}/Dockerfile.${distro}" \
12+
-f "${build_context}/Dockerfile.${distro}" \
1313
--build-arg "SERVICE=${service}" \
14-
"${dir}"
14+
"${build_context}"
1515
done
1616
done
File renamed without changes.
File renamed without changes.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.dockerignore
22
Dockerfile.*
3-
*/docker-compose.yml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)