From a4db560bd46e7162af83240f7aac70e86cfbb676 Mon Sep 17 00:00:00 2001 From: Archit Chopra Date: Wed, 18 Sep 2024 18:16:41 +0530 Subject: [PATCH] feat: Added docker compose to use platform --- Makefile | 26 +++++++++++++++++++++++--- docker-compose.yml | 8 ++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 01f39c8..3193fa7 100644 --- a/Makefile +++ b/Makefile @@ -56,11 +56,31 @@ PWD := $(shell pwd) ## Docker compose down down: - @docker-compose down + @ARCH=$$(uname -m); \ + if [ "$$ARCH" = "x86_64" ]; then \ + PLATFORM="linux/amd64"; \ + elif [ "$$ARCH" = "arm64" ] || [ "$$ARCH" = "aarch64" ]; then \ + PLATFORM="linux/arm64"; \ + else \ + echo "${RED}Unsupported architecture: $$ARCH${RESET}"; \ + exit 1; \ + fi; \ + PLATFORM=$$PLATFORM \ + docker-compose down ## Docker compose up up: - @docker-compose up -d + @ARCH=$$(uname -m); \ + if [ "$$ARCH" = "x86_64" ]; then \ + PLATFORM="linux/amd64"; \ + elif [ "$$ARCH" = "arm64" ] || [ "$$ARCH" = "aarch64" ]; then \ + PLATFORM="linux/arm64"; \ + else \ + echo "${RED}Unsupported architecture: $$ARCH${RESET}"; \ + exit 1; \ + fi; \ + PLATFORM=$$PLATFORM \ + docker-compose up -d ## Docker ssh kill ssh: @@ -86,4 +106,4 @@ help: printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ } \ } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) + { lastLine = $$0 }' $(MAKEFILE_LIST) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0714422..3959537 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ services: devops: container_name: devops - image: clouddrove/devops-machine:v0.0.1 + image: ghcr.io/clouddrove/devops-machine + platform: ${PLATFORM} mem_limit: 3g memswap_limit: 3g cpu_shares: 30 @@ -25,11 +26,6 @@ services: networks: dev_net_devops: ipv4_address: 10.13.0.13 - command: > - sh -c "chown -R ubuntu:ubuntu /home/ubuntu/ && - service ssh start && - su ubuntu -c 'tail -f /dev/null'" - networks: dev_net_devops: driver: bridge