Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support mac M architecture #1302

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ result*
#IDE
.idea/
.vscode/
.aider*
.env
26 changes: 8 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -830,26 +830,16 @@ ARG supautils_release_amd64_deb_checksum

RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Set up a script to download the correct package
RUN echo '#!/bin/sh' > /tmp/download_supautils.sh && \
echo 'set -e' >> /tmp/download_supautils.sh && \
echo 'if [ "$TARGETARCH" = "amd64" ]; then' >> /tmp/download_supautils.sh && \
echo ' CHECKSUM="${supautils_release_amd64_deb_checksum}"' >> /tmp/download_supautils.sh && \
echo ' ARCH="amd64"' >> /tmp/download_supautils.sh && \
echo 'elif [ "$TARGETARCH" = "arm64" ]; then' >> /tmp/download_supautils.sh && \
echo ' CHECKSUM="${supautils_release_arm64_deb_checksum}"' >> /tmp/download_supautils.sh && \
echo ' ARCH="arm64"' >> /tmp/download_supautils.sh && \
echo 'else' >> /tmp/download_supautils.sh && \
echo ' echo "Unsupported architecture: $TARGETARCH" >&2' >> /tmp/download_supautils.sh && \
echo ' exit 1' >> /tmp/download_supautils.sh && \
echo 'fi' >> /tmp/download_supautils.sh && \
echo 'CHECKSUM=$(echo $CHECKSUM | sed "s/^sha256://")' >> /tmp/download_supautils.sh && \
echo 'curl -fsSL -o /tmp/supautils.deb \\' >> /tmp/download_supautils.sh && \
echo ' "https://github.com/supabase/supautils/releases/download/v${supautils_release}/supautils-v${supautils_release}-pg${postgresql_major}-$ARCH-linux-gnu.deb"' >> /tmp/download_supautils.sh && \
echo 'echo "$CHECKSUM /tmp/supautils.deb" | sha256sum -c -' >> /tmp/download_supautils.sh && \
chmod +x /tmp/download_supautils.sh
# Add the external download script
ADD scripts/download_supautils.sh /tmp/download_supautils.sh

# Run the script to download and verify the package
ARG supautils_release_arm64_deb_checksum
ARG supautils_release_amd64_deb_checksum
ENV supautils_release=${supautils_release} \
postgresql_major=${postgresql_major} \
supautils_release_arm64_deb_checksum=${supautils_release_arm64_deb_checksum} \
supautils_release_amd64_deb_checksum=${supautils_release_amd64_deb_checksum}
RUN /tmp/download_supautils.sh && rm /tmp/download_supautils.sh

####################
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ See all installation instructions in the [repo wiki](https://github.com/supabase
| Supabase Postgres: PostgREST Bundle | Coming Soon | Coming Soon | Coming Soon |
| Supabase Postgres: Complete Bundle | Coming Soon | Coming Soon | Coming Soon |

### Quick Build
### Quick Cloud Build

Uses Amazon build cluster.

```bash
$ time packer build -timestamp-ui \
Expand All @@ -88,6 +90,24 @@ $ time packer build -timestamp-ui \
amazon-arm.json
```

### Quick Local Build

Uses docker
```bash
# Setup a docker buildx instance, if not already present.
docker buildx inspect || docker buildx create --use
# Build all architectures
docker buildx build \
$(yq 'to_entries | map(select(.value|type == "!!str")) | map(" --build-arg " + .key + "=" + .value) | join("")' 'ansible/vars.yml') \
--target production \
--tag 'custom_supabase_postgres' \
--platform 'linux/arm64/v8,linux/amd64' \
--load \
.
```

After this you can use the `docker run custom_supabase_postgres` command to start your local instance.

## Motivation

- Make it fast and simple to get started with Postgres.
Expand Down
26 changes: 26 additions & 0 deletions scripts/download_supautils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -e
# Ensure mandatory environment variables are set
: "${supautils_release:?Environment variable supautils_release is required}"
: "${postgresql_major:?Environment variable postgresql_major is required}"
: "${supautils_release_arm64_deb_checksum:?Environment variable supautils_release_arm64_deb_checksum is required}"
: "${supautils_release_amd64_deb_checksum:?Environment variable supautils_release_amd64_deb_checksum is required}"

# Fallback to uname -m if TARGETARCH is not set
TARGETARCH=${TARGETARCH:-$(uname -m)}

if [ "$TARGETARCH" = "x86_64" ] || [ "$TARGETARCH" = "amd64" ]; then
CHECKSUM="${supautils_release_amd64_deb_checksum}"
ARCH="amd64"
elif [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then
CHECKSUM="${supautils_release_arm64_deb_checksum}"
ARCH="arm64"
else
echo "Unsupported architecture: $TARGETARCH" >&2
exit 1
fi
CHECKSUM=$(echo $CHECKSUM | sed "s/^sha256://")
curl -fsSL -o /tmp/supautils.deb \
"https://github.com/supabase/supautils/releases/download/v${supautils_release}/supautils-v${supautils_release}-pg${postgresql_major}-$ARCH-linux-gnu.deb"
CHECKSUM_LINE=$(echo "$CHECKSUM /tmp/supautils.deb")
echo "$CHECKSUM_LINE" | sha256sum -c -