forked from xtacocorex/Gadget-OS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-dockerfiles.sh
executable file
·33 lines (22 loc) · 1.22 KB
/
gen-dockerfiles.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BOARDS="chippro chippro4gb"
COMMONFILE="$(ls ${SCRIPT_DIR}/common.Dockerfile)" # error out early if common.Dockerfile isn't here
HASH=$(git rev-parse --short=8 HEAD)
TIMESTAMP=$(date --iso-8601 -d @$(git show -s --format=%ct))
BRANCH=${CI_BUILD_REF_SLUG}
echo "${BRANCH}:${TIMESTAMP}-${HASH}" > .branch
# generating dockerfiles
echo "# generating dockerfiles"
for BOARD in ${BOARDS}; do
cat ${COMMONFILE} > ${SCRIPT_DIR}/${BOARD}.Dockerfile
# build board specific dockerfile, download it's kernel source
echo "RUN cd /opt/gadget-os-proto && no_docker=true make ${BOARD}_defconfig && no_docker=true make linux-source" >> ${SCRIPT_DIR}/${BOARD}.Dockerfile
# tag and upload board specific docker image
docker build -t nextthingco/gadget-build-${BOARD}-${BRANCH}:${TIMESTAMP}-${HASH} -f ${SCRIPT_DIR}/${BOARD}.Dockerfile ${SCRIPT_DIR}
docker tag nextthingco/gadget-build-${BOARD}-${BRANCH}:${TIMESTAMP}-${HASH}\
nextthingco/gadget-build-${BOARD}-${BRANCH}:latest
docker push nextthingco/gadget-build-${BOARD}-${BRANCH}:${TIMESTAMP}-${HASH}
docker push nextthingco/gadget-build-${BOARD}-${BRANCH}:latest
rm ${SCRIPT_DIR}/${BOARD}.Dockerfile
done