Skip to content

Commit

Permalink
Updates Dockerfile to allow version tag customization and refactors i…
Browse files Browse the repository at this point in the history
…mage tagging and pushing in build script

Introduces the ability to customize the version tag in the Dockerfile using an argument
Streamlines the process of tagging and pushing Docker images to multiple registries in the build script
Ensures consistency in versioning across different image registries
  • Loading branch information
cniweb committed Jan 14, 2025
1 parent 77ad65a commit a447c32
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
27 changes: 14 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
FROM debian:stable-slim
ARG VERSION_TAG=v24.8
RUN set -x \
# Runtime dependencies.
&& apt-get update \
&& apt-get upgrade -y \
# Build dependencies.
&& apt-get install -y \
autoconf \
automake \
curl \
g++ \
git \
libcurl4-openssl-dev \
libjansson-dev \
libssl-dev \
libgmp-dev \
libz-dev \
make \
pkg-config \
autoconf \
automake \
curl \
g++ \
git \
libcurl4-openssl-dev \
libgmp-dev \
libjansson-dev \
libssl-dev \
libz-dev \
make \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
RUN set -x \
# Compile from source code.
&& git clone --recursive https://github.com/JayDDee/cpuminer-opt.git /tmp/cpuminer \
&& cd /tmp/cpuminer \
&& git checkout v24.4 \
&& git checkout "$VERSION_TAG" \
&& ./autogen.sh \
&& extracflags="$extracflags -Ofast -flto -fuse-linker-plugin -ftree-loop-if-convert-stores" \
&& CFLAGS="-O3 -march=native -Wall" ./configure --with-curl \
Expand Down
37 changes: 24 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#!/bin/bash
version="24.4"
# Define image name, version and registries
image="cpuminer-opt"
docker build . --tag docker.io/cniweb/$image:$version
docker tag docker.io/cniweb/$image:$version docker.io/cniweb/$image:latest
docker tag docker.io/cniweb/$image:$version ghcr.io/cniweb/$image:$version
docker tag docker.io/cniweb/$image:$version ghcr.io/cniweb/$image:latest
docker tag docker.io/cniweb/$image:$version quay.io/cniweb/$image:$version
docker tag docker.io/cniweb/$image:$version quay.io/cniweb/$image:latest
docker push docker.io/cniweb/$image:$version
docker push docker.io/cniweb/$image:latest
docker push ghcr.io/cniweb/$image:$version
docker push ghcr.io/cniweb/$image:latest
docker push quay.io/cniweb/$image:$version
docker push quay.io/cniweb/$image:latest
version="25.1"
registries=("docker.io" "ghcr.io" "quay.io")

# Build the image
docker build . --build-arg VERSION_TAG=v$version --tag ${registries[0]}/cniweb/$image:$version

# Check if the command was successful
if [ $? -ne 0 ]; then
echo "Docker build failed!"
exit 1
fi

echo "Docker build succeeded!"

# Tag and push the images
for registry in "${registries[@]}"; do
docker tag ${registries[0]}/cniweb/$image:$version $registry/cniweb/$image:$version
docker tag ${registries[0]}/cniweb/$image:$version $registry/cniweb/$image:latest

# Push both versioned and latest tags
docker push $registry/cniweb/$image:$version
docker push $registry/cniweb/$image:latest
done

0 comments on commit a447c32

Please sign in to comment.