Skip to content

Commit

Permalink
od: docker: Dockerize toolchain
Browse files Browse the repository at this point in the history
Signed-off-by: Sergiy Kukunin <[email protected]>
  • Loading branch information
Kukunin committed May 13, 2021
1 parent 3849f13 commit 41cb410
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.config
output/
Dockerfile
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Build base image
FROM debian:buster AS base

RUN apt-get update && apt-get install -y \
build-essential \
g++-multilib \
cmake \
git \
file \
bc \
rsync \
bison \
flex \
gettext \
texinfo \
wget \
cpio \
python \
unzip \
mercurial \
subversion \
libncurses5-dev \
libc6-dev-i386 \
bzr \
squashfs-tools \
u-boot-tools \
vim \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --user-group --system --create-home --no-log-init buildroot

## Build buildroot
FROM base AS builder
ARG CONFIG

RUN mkdir /opt/buildroot && chown buildroot /opt/buildroot
WORKDIR /opt/buildroot

USER buildroot

COPY --chown=buildroot:buildroot . /opt/buildroot

RUN make od_${CONFIG}_defconfig BR2_EXTERNAL=board/opendingux
RUN make source
RUN CONFIG=${CONFIG} ./rebuild.sh
RUN tar xf output/${CONFIG}/images/opendingux-${CONFIG}-toolchain.*.tar.xz

## Copy assets to the final image
FROM base
ARG CONFIG

COPY --from=builder /opt/buildroot/${CONFIG}-toolchain /opt/${CONFIG}-toolchain

WORKDIR /opt/${CONFIG}-toolchain
ENV PATH ${PATH}:/opt/${CONFIG}-toolchain/bin

RUN ./relocate-sdk.sh

USER buildroot
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1235,3 +1235,6 @@ include docs/manual/manual.mk
.PHONY: $(noconfig_targets)

endif #umask / $(CURDIR) / $(O)

# Include docker-related stuff
include support/misc/docker.mk
36 changes: 36 additions & 0 deletions support/misc/docker.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
DOCKER_TAG_REVISION := $(or $(DOCKER_TAG_REVISION),$(shell git rev-parse HEAD 2> /dev/null || true))
DOCKER_TAG_DATE := $(or \
$(DOCKER_TAG_DATE), \
$(shell (git log -1 --format="%at" 2> /dev/null || true) | xargs -I{} date -d @{} +%Y%m%d))

CONFIGS=gcw0 rs90
CONFIG_IMAGES=$(addsuffix -docker-image, $(CONFIGS))

.PHONY: publish-docker-images $(CONFIG_IMAGES) $(addprefix push-, $(CONFIG_IMAGES)) $(addprefix publish-, $(CONFIG_IMAGES)) docker-image push-docker-image

publish-docker-images: $(addprefix publish-, $(CONFIG_IMAGES))

$(CONFIG_IMAGES): %-docker-image:
make docker-image DOCKER_CONFIG=$*

$(addprefix push-, $(CONFIG_IMAGES)): push-%-docker-image:
make push-docker-image DOCKER_CONFIG=$*

$(addprefix publish-, $(CONFIG_IMAGES)): publish-%-docker-image:
$(MAKE) $*-docker-image push-$*-docker-image

docker-image:
test -n "$(DOCKER_CONFIG)" # $$DOCKER_CONFIG
test -n "$(DOCKER_IMAGE)" # $$DOCKER_IMAGE
docker build \
-t ${DOCKER_IMAGE}:${DOCKER_CONFIG}-${DOCKER_TAG_REVISION} \
-t ${DOCKER_IMAGE}:${DOCKER_CONFIG}-${DOCKER_TAG_DATE} \
-t ${DOCKER_IMAGE}:${DOCKER_CONFIG}-latest \
--build-arg CONFIG=${DOCKER_CONFIG} .

push-docker-image:
test -n "$(DOCKER_CONFIG)" # $$DOCKER_CONFIG
test -n "$(DOCKER_IMAGE)" # $$DOCKER_IMAGE
docker push ${DOCKER_IMAGE}:${DOCKER_CONFIG}-${DOCKER_TAG_REVISION}
docker push ${DOCKER_IMAGE}:${DOCKER_CONFIG}-${DOCKER_TAG_DATE}
docker push ${DOCKER_IMAGE}:${DOCKER_CONFIG}-latest

0 comments on commit 41cb410

Please sign in to comment.