Open vfedotovs opened 1 week ago
Proposed solution perform infra architecture pre-check in Makefile
Example of one architecture file docker-compose.amd64.yml:
version: '3'
services:
web:
image: yourdockerhubusername/yourapp:latest-amd64
ports:
- "80:8501"
start.sh script example
#!/bin/bash
# Function to detect the architecture
detect_architecture() {
local arch
if [[ "$(uname)" == "Darwin" ]]; then
# Check if running under Rosetta
if [[ "$(sysctl -n sysctl.proc_translated)" == "1" ]]; then
arch="arm64" # Assume M1 if running under Rosetta
else
arch=$(uname -m)
fi
else
arch=$(uname -m)
fi
echo $arch
}
# Detect the architecture
ARCH=$(detect_architecture)
# Set the appropriate Docker Compose file based on the architecture
if [ "$ARCH" == "x86_64" ]; then
COMPOSE_FILE="docker-compose.amd64.yml"
elif [[ "$ARCH" == "armv7l" || "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
COMPOSE_FILE="docker-compose.arm.yml"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
# Pull and start the appropriate containers
docker-compose -f $COMPOSE_FILE pull
docker-compose -f $COMPOSE_FILE up -d
Here is Makefile example
# Detect the architecture
detect_architecture := $(shell uname -m)
os_type := $(shell uname)
ifeq ($(os_type), Darwin)
is_rosetta := $(shell sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)
ifeq ($(is_rosetta), 1)
detect_architecture := arm64
endif
endif
# Set the appropriate Docker Compose file based on the architecture
ifeq ($(detect_architecture), x86_64)
COMPOSE_FILE := docker-compose.amd64.yml
else ifeq ($(detect_architecture), arm64)
COMPOSE_FILE := docker-compose.arm.yml
else ifeq ($(detect_architecture), aarch64)
COMPOSE_FILE := docker-compose.arm.yml
else ifeq ($(detect_architecture), armv7l)
COMPOSE_FILE := docker-compose.arm.yml
else
$(error Unsupported architecture: $(detect_architecture))
endif
# Define targets
.PHONY: all pull up
all: pull up
pull:
@echo "Pulling images for $(detect_architecture) using $(COMPOSE_FILE)"
docker-compose -f $(COMPOSE_FILE) pull
up:
@echo "Starting containers for $(detect_architecture) using $(COMPOSE_FILE)"
docker-compose -f $(COMPOSE_FILE) up -d
Web Scraper version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of Web Scraper.
Reproducible Example
Issue Description
When repository is cloned to x86 or amd64 architecture deploy of web service works as expected but repository is cloned to arm64 architecture deploy of web service deploys amd64 web service
Expected Behavior
It Makefile should do pre-check of architecture and deploy matching architecture docker images