Skip to content

Commit ca97c9c

Browse files
add docker build script for multi-arch
1 parent 231fce4 commit ca97c9c

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

docker-build-push.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# Multi-architecture Docker build and push script for mkcertWeb
4+
# Builds for linux/amd64 (Intel/AMD) and linux/arm64 (ARM64)
5+
6+
set -e
7+
8+
# Configuration
9+
IMAGE_NAME="jeffcaldwellca/mkcertweb"
10+
VERSION="3.1.1"
11+
12+
# Colors for output
13+
GREEN='\033[0;32m'
14+
BLUE='\033[0;34m'
15+
RED='\033[0;31m'
16+
NC='\033[0m' # No Color
17+
18+
echo -e "${BLUE}Starting multi-architecture build for ${IMAGE_NAME}:${VERSION}${NC}"
19+
20+
# Check if logged into Docker Hub
21+
#echo -e "${BLUE}Checking Docker Hub login...${NC}"
22+
#if ! docker info | grep -q "Username"; then
23+
# echo -e "${RED}Not logged into Docker Hub. Please run: docker login${NC}"
24+
# exit 1
25+
#fi
26+
27+
# Create and use buildx builder if not exists
28+
echo -e "${BLUE}Setting up buildx builder...${NC}"
29+
if ! docker buildx ls | grep -q "multiarch"; then
30+
docker buildx create --name multiarch --use
31+
else
32+
docker buildx use multiarch
33+
fi
34+
35+
# Bootstrap the builder
36+
docker buildx inspect --bootstrap
37+
38+
# Build and push multi-architecture image
39+
echo -e "${BLUE}Building and pushing multi-arch images...${NC}"
40+
echo -e "${BLUE}Platforms: linux/amd64, linux/arm64${NC}"
41+
42+
docker buildx build \
43+
--platform linux/amd64,linux/arm64 \
44+
--tag ${IMAGE_NAME}:${VERSION} \
45+
--tag ${IMAGE_NAME}:latest \
46+
--push \
47+
.
48+
49+
echo -e "${GREEN}✓ Successfully built and pushed multi-architecture images!${NC}"
50+
echo -e "${GREEN}✓ Available platforms: linux/amd64, linux/arm64${NC}"
51+
echo -e "${GREEN}✓ Tags: ${IMAGE_NAME}:${VERSION}, ${IMAGE_NAME}:latest${NC}"
52+
echo ""
53+
echo -e "${BLUE}To verify the image manifest:${NC}"
54+
echo " docker buildx imagetools inspect ${IMAGE_NAME}:${VERSION}"
55+
echo ""
56+
echo -e "${BLUE}To pull and run:${NC}"
57+
echo " docker pull ${IMAGE_NAME}:${VERSION}"
58+
echo " docker-compose up -d"

0 commit comments

Comments
 (0)