Skip to content

Commit

Permalink
feat: build multi-platform images
Browse files Browse the repository at this point in the history
  • Loading branch information
DonDebonair committed Dec 22, 2023
1 parent 1113f28 commit 85da53c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/on-pr-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
platforms: linux/amd64,linux/arm64
1 change: 1 addition & 0 deletions .github/workflows/on-push-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ RUN apt-get update \
curl \
# unzip \
&& rm -rf /var/lib/apt/lists/*
RUN curl https://oso-local-development-binary.s3.amazonaws.com/oso-local-development-binary-linux-x86_64.tar.gz --output local.tar.gz \
&& tar -xzf local.tar.gz \
&& rm local.tar.gz

ARG TARGETARCH

COPY download-binary.sh /download-binary.sh

RUN chmod +x /download-binary.sh && /download-binary.sh

RUN chmod +x ./standalone
CMD ["./standalone"]
41 changes: 41 additions & 0 deletions download-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Determine the architecture from the TARGETARCH environment variable
ARCH=$TARGETARCH

# Set the download URL based on the architecture
if [ "$ARCH" = "amd64" ]; then
URL="https://oso-local-development-binary.s3.amazonaws.com/oso-local-development-binary-linux-x86_64.tar.gz"
elif [ "$ARCH" = "arm64" ]; then
URL="https://oso-local-development-binary.s3.amazonaws.com/dev/oso-local-development-binary-linux-arm64.tar.gz"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi

# Define the output file name
OUTPUT_FILE="oso-local-development-binary.tar.gz"

# Download the binary
echo "Downloading binary for $ARCH..."
curl -L $URL -o $OUTPUT_FILE

# Check if the download was successful
if [ $? -eq 0 ]; then
echo "Download complete. Decompressing the binary..."

# Decompress the binary
tar -xzf $OUTPUT_FILE

# Check if the decompression was successful
if [ $? -eq 0 ]; then
echo "Binary decompressed successfully."
# Here you might want to move or use the binary.
else
echo "Failed to decompress the binary."
exit 1
fi
else
echo "Failed to download the binary."
exit 1
fi

0 comments on commit 85da53c

Please sign in to comment.