Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile #12

Open
wants to merge 1 commit into
base: opendingux
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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