Skip to content

Commit

Permalink
Dockerfile and Makefile improvements for multi-platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
fqjony committed Oct 2, 2024
1 parent f01dcc6 commit 1c98c8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install yq
RUN curl -sL https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64.tar.gz | tar xz && \
mv yq_linux_amd64 /usr/bin/yq && \
# Install yq (architecture-aware)
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64"; fi && \
curl -sL https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_${ARCH}.tar.gz | tar xz && \
mv yq_linux_${ARCH} /usr/bin/yq && \
rm -rf /tmp/*

# Install Google Cloud SDK
Expand All @@ -51,15 +53,16 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install AWS CLI
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
# Install AWS CLI (architecture-aware)
RUN ARCH=$(uname -m) && \
curl "https://awscli.amazonaws.com/awscli-exe-linux-${ARCH}.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip aws /tmp/* /var/tmp/*

# Install Azure CLI
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/azure-cli.list && \
# Install Azure CLI (architecture-aware)
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/azure-cli.list && \
apt-get update && \
apt-get install -y --no-install-recommends azure-cli=2.63.0-1~noble && \
apt-get clean && \
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ stringify-creds:
done

# Build the Docker image
MULTIPLATFORM ?= false

build:
@echo "Building Docker image..."
@docker build -t $(DOCKER_IMAGE) .
@if [ "$(MULTIPLATFORM)" = "true" ]; then \
echo "Building Docker image for multiple platforms..."; \
docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_IMAGE) --push .; \
else \
echo "Building Docker image for the local platform..."; \
docker build -t $(DOCKER_IMAGE) .; \
fi
@echo "Docker image build completed."

# Run Docker container (supports interactive mode)
Expand Down

0 comments on commit 1c98c8c

Please sign in to comment.