Skip to content

Commit

Permalink
Automatic selection between podman and docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
benycze committed Sep 19, 2021
1 parent f40f20a commit 34eb124
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ git checkout devel
The image is then built quite easily (the following example is for docker but you can use the same command using the [podman](https://podman.io/) tool):

```bash
docker build -t localhost/bsc-compiler --build-arg BJOBS=4 --build-arg USER=$USER --build-arg UID=`id -u` --build-arg `id -g` --build-arg DOC=1 .
docker build --rm -t localhost/bsc-compiler --build-arg BJOBS=4 --build-arg USER=$USER --build-arg UID=`id -u` --build-arg `id -g` --build-arg DOC=1 .
```

This command builds the image named localhost/bsc-compiler and it also uses 4 jobs to build the tool. You can also adjust the BJOBS if you need to use less or more CPU cores to build the image. Image for docker is built using the `build-image.sh` (you can also run `DOC=1 ./build-image.sh` if you want to enforce documentation build).
This command builds the image named localhost/bsc-compiler and it also uses 4 jobs to build the tool. You can also adjust the BJOBS if you need to use less or more CPU cores to build the image. Image for docker is built using the `build-image.sh` (you can also run `env DOC=1 ./build-image.sh` if you want to enforce documentation build).
Variables UID, USER and GID are used for the creation of local account with admin rights via the `sudo` tool. THe DOC parameters is used for the documentation build - disabled by default because you can build it directly outside the docker image. However, it is possible to turn it on and copy files outside of running docker image (folder /doc) to host.

## How to run the image (just a console)
Expand Down
16 changes: 15 additions & 1 deletion build-image.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
#!/usr/bin/env bash
set -e

# Check if docker/podman is available
CONTAINER_TOOL=""
if command -v docker > /dev/null; then
CONTAINER_TOOL="docker"
elif command -v podman > /dev/null; then
CONTAINER_TOOL="podman"
else
echo "No container tool (podman, docker has been found)!"
exit 1
fi

echo "${CONTAINER_TOOL} tool has been found ..."

# Clean the directory and buld the image
echo "Cleaning the folder ..."
git clean -d -f -f -x .

Expand All @@ -16,7 +30,7 @@ echo "Downloading all folders ..."
cd scripts && bash bootstrap.sh && cd ..

echo "Building the Bluespec docker image ..."
docker build -t localhost/bsc-compiler --build-arg BJOBS=4 --build-arg USER=$USER \
$CONTAINER_TOOL build --rm -t localhost/bsc-compiler --build-arg BJOBS=4 --build-arg USER=$USER \
--build-arg UID=`id -u` --build-arg `id -g` --build-arg DOC=${DOC_BUILD} .

echo "Done!"

0 comments on commit 34eb124

Please sign in to comment.