Skip to content

Commit

Permalink
Add Docker support for build and test (#6)
Browse files Browse the repository at this point in the history
* Add dockerfile for Fedora rawhide

* Add buildx multiplatform configuration

* Add point for debian

* Add Docker.md guide
  • Loading branch information
blackbearman authored Apr 6, 2023
1 parent 67fa6af commit 1a4ea94
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@
.tools
build
clear.cmd
build_*
56 changes: 56 additions & 0 deletions Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Install Docker
We need Docker with multi-platform image support. Plugin `buildx` is included by default to `docker-desktop`, and available for `docker-ce` and `moby-engine`.

Debian:
```
apt install moby-engine moby-buildx moby-compose moby-cli
```
Ubuntu:
https://docs.docker.com/engine/install/ubuntu/

# Prepare Docker to work with multi-platform images
First time:
```
docker buildx create --name mybuilder
docker buildx use mybuilder
```
Each time:
```
docker run --privileged --rm tonistiigi/binfmt --install all
```

# Update images for build
```
docker buildx bake debian
docker buildx bake fedora
```

# Run build and test on the all available platforms
```
docker buildx bake --progress="plain" bee2d
docker buildx bake --progress="plain" bee2f
```

# Run build and test on a one of available platforms
```
docker buildx build --platform linux/amd64 --progress="plain" -f dockerfiles/bee2d.Dockerfile .
docker buildx build --platform linux/amd64 --progress="plain" -f dockerfiles/bee2f.Dockerfile .
```

# Run terminal on specified platform image
```
docker run --rm -it -v .:/usr/src --platform linux/s390x btls/fedora:cdev bash
```

### Turn on experimental features
If option `platform` is unavailable in Docker, you need turn on experimental Docker CLI features in one of two ways. Either by setting an environment variable
```
$ export DOCKER_CLI_EXPERIMENTAL=enabled
```
or by turning the feature on in the config file $HOME/.docker/config.json:
```
{
"experimental" : "enabled"
}
```
76 changes: 76 additions & 0 deletions docker-bake.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"group": {
"default": {
"targets": [
"fedora",
"debian"
]
}
},
"target": {
"fedora": {
"context": ".",
"dockerfile": "dockerfiles/rawhide.Dockerfile",
"tags": [
"docker.io/btls/fedora:cdev"
],
"platforms": [
"linux/amd64",
"linux/arm64",
"linux/ppc64le",
"linux/s390x"
],
"output": [
"type=registry"
]
},
"debian": {
"context": ".",
"dockerfile": "dockerfiles/debian.Dockerfile",
"tags": [
"docker.io/btls/debian:cdev"
],
"platforms": [
"linux/386",
"linux/amd64",
"linux/arm/v7",
"linux/arm64",
"linux/mips64le",
"linux/ppc64le",
"linux/s390x"
],
"output": [
"type=registry"
]
},
"bee2d": {
"context": ".",
"dockerfile": "dockerfiles/bee2d.Dockerfile",
"tags": [
"bee2:debian"
],
"platforms": [
"linux/386",
"linux/amd64",
"linux/arm/v7",
"linux/arm64",
"linux/mips64le",
"linux/ppc64le",
"linux/s390x"
]
},
"bee2f": {
"context": ".",
"dockerfile": "dockerfiles/bee2f.Dockerfile",
"tags": [
"bee2:fedora"
],
"platforms": [
"linux/amd64",
"linux/arm64",
"linux/ppc64le",
"linux/s390x"
]
}
}
}
23 changes: 23 additions & 0 deletions dockerfiles/bee2d.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM --platform=$TARGETPLATFORM btls/debian:cdev

COPY . /usr/src

RUN gcc --version
RUN clang --version
RUN cat /etc/os-release

WORKDIR /usr/src
RUN rm -rf ./build_gcc; mkdir build_gcc
RUN rm -rf ./build_clang; mkdir build_clang

WORKDIR /usr/src/build_gcc
RUN cmake ..
RUN make
RUN ctest --verbose

WORKDIR /usr/src/build_clang
RUN cmake ..
RUN make
RUN ctest --verbose

WORKDIR /usr/src
23 changes: 23 additions & 0 deletions dockerfiles/bee2f.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM --platform=$TARGETPLATFORM btls/fedora:cdev

COPY . /usr/src

RUN gcc --version
RUN clang --version
RUN cat /etc/os-release

WORKDIR /usr/src
RUN rm -rf ./build_gcc; mkdir build_gcc
RUN rm -rf ./build_clang; mkdir build_clang

WORKDIR /usr/src/build_gcc
RUN cmake ..
RUN make
RUN ctest --verbose

WORKDIR /usr/src/build_clang
RUN cmake ..
RUN make
RUN ctest --verbose

WORKDIR /usr/src
5 changes: 5 additions & 0 deletions dockerfiles/debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM --platform=$TARGETPLATFORM debian:stable

RUN apt-get update && apt-get install -y cmake git gcc doxygen clang

WORKDIR /usr/src
7 changes: 7 additions & 0 deletions dockerfiles/rawhide.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM --platform=$TARGETPLATFORM fedora:rawhide

RUN dnf -y update

RUN dnf install -y gcc clang cmake doxygen

WORKDIR /usr/src

0 comments on commit 1a4ea94

Please sign in to comment.