Skip to content

Commit 237485c

Browse files
committed
build labels
1 parent 9f57c80 commit 237485c

7 files changed

+26
-2
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
openwrt.conf
2+
.env
3+
*.img.gz
4+
*.img
5+
etc/config/*
6+
!etc/config/*.tpl

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
openwrt.conf
22
.env
33
*.tar.gz
4+
*.img
5+
*.img.gz
46
etc/config/*
57
!etc/config/*.tpl

.gitlab-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ build:
4040
- cp openwrt.conf.example openwrt.conf
4141
- sed -i -E "s@(BUILD_TAG=).+@\1$CI_IMAGE@" openwrt.conf
4242
- wget -qO- $SRC_IMAGE | gzip -d > image.img
43-
- source openwrt.conf
44-
- export ROOT_PW; export BUILD_TAG; export LOOP_ARGS="=/tmp/dev/loop0"; ./build-rpi.sh
43+
- LOOP_ARGS="=/tmp/dev/loop0" ./build-rpi.sh
4544
- docker tag $CI_IMAGE $CI_IMAGE:$TAG
4645
- docker push $CI_IMAGE:$TAG
4746

@@ -61,6 +60,7 @@ build-rpi4:
6160
extends: .build-rpi
6261
variables:
6362
SRC_IMAGE: https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz
63+
VERSION: snapshot
6464
TAG: rpi4
6565

6666
build-rpi-zero:

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ RUN opkg remove dnsmasq && \
1818
RUN opkg list-upgradable | awk '{print $1}' | xargs opkg upgrade
1919
RUN echo "iptables -A POSTROUTING -t mangle -p udp --dport 68 -j CHECKSUM --checksum-fill" >> /etc/firewall.user
2020

21+
ARG ts
22+
ARG version
23+
LABEL org.opencontainers.image.created=$ts
24+
LABEL org.opencontainers.image.version=$version
25+
LABEL org.opencontainers.image.source=https://github.com/oofnikj/docker-openwrt
26+
2127
CMD [ "/sbin/init" ]

Dockerfile.rpi

+5
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ RUN opkg update && \
88
iperf3 \
99
ip-full
1010
RUN opkg list-upgradable | awk '{print $1}' | xargs opkg upgrade || true
11+
ARG ts
12+
ARG version
13+
LABEL org.opencontainers.image.created=$ts
14+
LABEL org.opencontainers.image.version=$version
15+
LABEL org.opencontainers.image.source=https://github.com/oofnikj/docker-openwrt
1116

1217
CMD [ "/sbin/init" ]

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ build:
88
docker build \
99
--build-arg ROOT_PW \
1010
--build-arg OPENWRT_SOURCE_VER \
11+
--build-arg ts="$(shell date)" \
12+
--build-arg version="${OPENWRT_SOURCE_VER}" \
1113
-t ${BUILD_TAG} .
1214
rm openwrt-${OPENWRT_SOURCE_VER}-x86-64-generic-rootfs.tar.gz
1315

build-rpi.sh

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
set -e
1212

1313
IMG=${1:-'image.img'}
14+
. ./openwrt.conf
1415

1516
check_uid() {
1617
if [[ $(id -u) -ne 0 ]]; then
@@ -31,6 +32,8 @@ docker_build() {
3132
echo "* building Docker image"
3233
docker build \
3334
--build-arg ROOT_PW="${ROOT_PW}" \
35+
--build-arg ts="$(date)" \
36+
--build-arg version="${VERSION:-$OPENWRT_SOURCE_VER}" \
3437
-t ${BUILD_TAG} -f Dockerfile.rpi ${tmpdir}
3538
}
3639

0 commit comments

Comments
 (0)