Skip to content

Commit

Permalink
Add docker file for testing builds
Browse files Browse the repository at this point in the history
  • Loading branch information
cibomahto committed Nov 17, 2023
1 parent 560f812 commit 71b93a1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
31 changes: 31 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM docker.io/library/debian:11 as base

RUN apt-get -qq update -y

RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
build-essential \
libusb-1.0.0-dev \
git \
sdcc \
ca-certificates

# Cleanup cached apt stuff
RUN rm -rf /var/lib/apt/lists/*

FROM base as toolsbuilder

# Tools that needs to be built from source

RUN git clone https://github.com/ole00/chprog.git /src
WORKDIR /src
RUN ./build_linux.sh
RUN cp ./chprog /usr/local/bin

From base
COPY --from=toolsbuilder /usr/local/ /usr/local

RUN apt-get -qq update -y

# Needed for git --describe to work
RUN git config --global --add safe.directory /build
26 changes: 26 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
all:
@echo "Build targets: "
@echo "build-docker Build an image for building tools with Docker"
@echo "build Build project assets from within Docker container"
@echo "run Run a shell using the above image with Docker"

IMAGE_NAME=ch554_sdcc


COMMON = run \
--rm \
--mount type=bind,source="`pwd`/..",target=/build \
-w /build \

build-docker:
docker build -t ${IMAGE_NAME} -f Dockerfile .

build:
docker ${COMMON} \
-it ${IMAGE_NAME} \
/bin/bash -c "cd examples; make clean; make"

run:
docker ${COMMON} \
-it ${IMAGE_NAME} \
/bin/bash
9 changes: 7 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
SUBDIRS = $(shell ls -d */)

.PHONY: $(SUBDIRS)

.PHONY: $(SUBDIRS) clean

$(SUBDIRS):
$(MAKE) -C $@

.DEFAULT_GOAL := all
all: $(SUBDIRS)

clean:
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean; \
done

print-% : ; @echo $* = $($*)


0 comments on commit 71b93a1

Please sign in to comment.