Skip to content

Commit 7bb1b74

Browse files
committed
Updates Dockerfile to support version tagging and registry listing
Allows dynamic versioning and support for multiple registries during image building Improves flexibility and customization of image tagging and pushing Checks and ensures successful Docker image build process
1 parent 081d5e5 commit 7bb1b74

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM alpine:3
22

3+
ARG VERSION_TAG=v6.22.2
34
ENV ALGO="rx"
45
ENV POOL_ADDRESS="stratum+ssl://rx.unmineable.com:443"
56
ENV WALLET_USER="LNec6RpZxX6Q1EJYkKjUPBTohM7Ux6uMUy"
@@ -8,15 +9,15 @@ ENV PASSWORD="x"
89
RUN adduser -S -D -H -h /xmrig miner
910
RUN apk --no-cache upgrade \
1011
&& apk --no-cache add \
11-
git \
12+
build-base \
1213
cmake \
14+
git \
15+
libmicrohttpd-dev \
1316
libuv-dev \
14-
build-base \
1517
openssl-dev \
16-
libmicrohttpd-dev \
1718
&& git clone https://github.com/xmrig/xmrig.git \
1819
&& cd xmrig \
19-
&& git checkout v6.21.3 \
20+
&& git checkout "$VERSION_TAG" \
2021
&& mkdir build \
2122
&& cmake -DWITH_HWLOC=OFF -DCMAKE_BUILD_TYPE=Release . \
2223
&& make -j$(nproc) \

build.sh

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
#!/bin/bash
2-
version="6.21.3"
2+
# Define image name, version and registries
33
image="xmrig"
4-
docker build . --tag docker.io/cniweb/$image:$version
5-
docker tag docker.io/cniweb/$image:$version docker.io/cniweb/$image:latest
6-
docker tag docker.io/cniweb/$image:$version ghcr.io/cniweb/$image:$version
7-
docker tag docker.io/cniweb/$image:$version ghcr.io/cniweb/$image:latest
8-
docker tag docker.io/cniweb/$image:$version quay.io/cniweb/$image:$version
9-
docker tag docker.io/cniweb/$image:$version quay.io/cniweb/$image:latest
10-
docker push docker.io/cniweb/$image:$version
11-
docker push docker.io/cniweb/$image:latest
12-
docker push ghcr.io/cniweb/$image:$version
13-
docker push ghcr.io/cniweb/$image:latest
14-
docker push quay.io/cniweb/$image:$version
15-
docker push quay.io/cniweb/$image:latest
4+
version="6.22.2"
5+
registries=("docker.io" "ghcr.io" "quay.io")
6+
7+
# Build the image
8+
docker build . --build-arg VERSION_TAG=v$version --tag ${registries[0]}/cniweb/$image:$version
9+
10+
# Check if the command was successful
11+
if [ $? -ne 0 ]; then
12+
echo "Docker build failed!"
13+
exit 1
14+
fi
15+
16+
echo "Docker build succeeded!"
17+
18+
# Tag and push the images
19+
for registry in "${registries[@]}"; do
20+
docker tag ${registries[0]}/cniweb/$image:$version $registry/cniweb/$image:$version
21+
docker tag ${registries[0]}/cniweb/$image:$version $registry/cniweb/$image:latest
22+
23+
# Push both versioned and latest tags
24+
docker push $registry/cniweb/$image:$version
25+
docker push $registry/cniweb/$image:latest
26+
done

0 commit comments

Comments
 (0)