1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-23 22:30:56 +01:00

fix(dev): Improve deps docker build process, mount local folder as volume

This removes the need to copy all the data into the docker container
and outputs from the build process out of the container. In
hindsight, this was a poor design decision as it created docker
images that were very large with data, that you don't have to
keep stored once the build finished, e.g. the build output.

Therefore, mount the local folder, keep the checkouts also local
which is good for debugging and also re-using them to build without
the docker container (no second checkout required).

Build output is also written directly to the build/ output folder

Overall, the docker container is more lightweight and actually
a "build environment" only not tainted with specific versions
of the dependencies to build.
This commit is contained in:
icex2 2023-03-21 23:31:23 +01:00 committed by icex2
parent b2e0d9f3d6
commit 6a140699ec
2 changed files with 23 additions and 27 deletions

View File

@ -1,4 +1,4 @@
FROM fedora:31
FROM --platform=amd64 fedora:31@sha256:cbe53d28f54c0f0b1d79a1817089235680b104c23619772473f449f20edd37dd
LABEL description="Build environment for bemanitools"
@ -8,25 +8,13 @@ RUN yum -y install \
zip \
clang \
mingw64-gcc.x86_64 \
mingw32-gcc.x86_64 \
wine.x86_64
mingw32-gcc.x86_64
RUN mkdir /bemanitools
WORKDIR /bemanitools
# Order optimized for docker layer caching
COPY run-tests-wine.sh run-tests-wine.sh
COPY CHANGELOG.md CHANGELOG.md
COPY CONTRIBUTING.md CONTRIBUTING.md
COPY LICENSE LICENSE
COPY GNUmakefile GNUmakefile
COPY Module.mk Module.mk
COPY README.md README.md
COPY doc doc
COPY dist dist
COPY src src
# .git folder required or building fails when version is generated
COPY .git .git
# Building
RUN make
ENTRYPOINT [ \
"/bin/bash", \
"-c" , \
"cd /bemanitools && \
make" ]

View File

@ -14,7 +14,7 @@ BUILDDIR ?= build
builddir_docker := $(BUILDDIR)/docker
docker_container_name := "bemanitools-build"
docker_image_name := "bemanitools:build"
docker_image_name := "bemanitools-build:latest"
depdir := $(BUILDDIR)/dep
objdir := $(BUILDDIR)/obj
@ -81,13 +81,21 @@ version:
build-docker:
$(V)docker rm -f $(docker_container_name) 2> /dev/null || true
$(V)docker build -t $(docker_image_name) -f Dockerfile .
$(V)docker create --name $(docker_container_name) $(docker_image_name)
$(V)rm -rf $(builddir_docker)
$(V)mkdir -p $(builddir_docker)
$(V)docker cp $(docker_container_name):/bemanitools/build $(builddir_docker)
$(V)mv $(builddir_docker)/build/* $(builddir_docker)
$(V)rm -r $(builddir_docker)/build
$(V)docker \
build \
-t $(docker_image_name) \
-f Dockerfile \
.
$(V)docker \
run \
--volume $(shell pwd):/bemanitools \
--name $(docker_container_name) \
$(docker_image_name)
clean-docker:
$(V)docker rm -f $(docker_container_name) || true
$(V)docker image rm -f $(docker_image_name) || true
$(V)rm -rf $(BUILDDIR)
#
# Pull in module definitions