mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
Add instructions for compiling graphql-engine natively on M1
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2049 GitOrigin-RevId: 9f10c26eef5382fb7b8e750ad272a5797b4cd6d8
This commit is contained in:
parent
020198969f
commit
6dae132fce
@ -19,6 +19,13 @@ MSSQL_CONTAINER_NAME="hasura-dev-mssql-$MSSQL_PORT"
|
||||
MSSQL_CONN_STR="DRIVER={ODBC Driver 17 for SQL Server};SERVER=127.0.0.1,$MSSQL_PORT;Uid=sa;Pwd=$MSSQL_PASSWORD;"
|
||||
MSSQL_DOCKER="docker exec -it $MSSQL_CONTAINER_NAME sqlcmd -S localhost -U sa -P $MSSQL_PASSWORD"
|
||||
|
||||
if [[ `uname -m` == 'arm64' ]]; then
|
||||
MSSQL_PLATFORM=linux/arm64
|
||||
MSSQL_CONTAINER_IMAGE=mcr.microsoft.com/azure-sql-edge
|
||||
else
|
||||
MSSQL_PLATFORM=linux/amd64
|
||||
MSSQL_CONTAINER_IMAGE=hasura/mssql-server-2019-cu10-ubuntu-20.04:latest
|
||||
fi
|
||||
|
||||
######################
|
||||
# Functions #
|
||||
@ -27,7 +34,9 @@ MSSQL_DOCKER="docker exec -it $MSSQL_CONTAINER_NAME sqlcmd -S localhost -U sa -P
|
||||
function mssql_launch_container(){
|
||||
echo_pretty "Launching MSSQL container: $MSSQL_CONTAINER_NAME"
|
||||
docker run --name $MSSQL_CONTAINER_NAME \
|
||||
-p 127.0.0.1:"$MSSQL_PORT":1433 -d hasura/mssql-server-2019-cu10-ubuntu-20.04:latest
|
||||
--platform "$MSSQL_PLATFORM" \
|
||||
-e ACCEPT_EULA=1 \
|
||||
-p 127.0.0.1:"$MSSQL_PORT":1433 -d "$MSSQL_CONTAINER_IMAGE"
|
||||
}
|
||||
|
||||
function mssql_wait {
|
||||
|
@ -19,6 +19,8 @@ MYSQL_PASSWORD=hasuraMySQL1
|
||||
MYSQL_CONTAINER_NAME="hasura-dev-mysql-$MYSQL_PORT"
|
||||
# space deliberately omitted between -u and -p params https://hub.docker.com/_/mysql
|
||||
MYSQL_DOCKER="docker exec -it $MYSQL_CONTAINER_NAME mysql -u$MYSQL_USER -p$MYSQL_PASSWORD"
|
||||
MYSQL_CONTAINER_IMAGE=mysql:8.0
|
||||
MYSQL_PLATFORM=linux/amd64 # for M1 arch we use the rosetta emulation
|
||||
|
||||
######################
|
||||
# Functions #
|
||||
@ -29,8 +31,9 @@ function mysql_launch_container(){
|
||||
docker run --name $MYSQL_CONTAINER_NAME \
|
||||
-e MYSQL_ROOT_PASSWORD=$MYSQL_PASSWORD \
|
||||
-e MYSQL_DATABASE=hasura \
|
||||
--platform "$MYSQL_PLATFORM" \
|
||||
-p 127.0.0.1:$MYSQL_PORT:3306 \
|
||||
-d mysql:8.0 -h "127.0.0.1"
|
||||
-d "$MYSQL_CONTAINER_IMAGE" -h "127.0.0.1"
|
||||
}
|
||||
|
||||
function mysql_wait {
|
||||
|
@ -15,9 +15,15 @@ fi
|
||||
|
||||
PG_PASSWORD=postgres
|
||||
PG_CONTAINER_NAME="hasura-dev-postgres-$PG_PORT"
|
||||
PG_DB_URL="postgres://postgres:$PG_PASSWORD@127.0.0.1:$PG_PORT/postgres"
|
||||
PG_DB_URL="postgresql://postgres:$PG_PASSWORD@127.0.0.1:$PG_PORT/postgres"
|
||||
PG_DOCKER="docker exec -u postgres -it $PG_CONTAINER_NAME psql $PG_DB_URL"
|
||||
|
||||
if [[ `uname -m` == 'arm64' ]]; then
|
||||
PG_CONTAINER_IMAGE=sayitsocial/postgis:raspi
|
||||
else
|
||||
PG_CONTAINER_IMAGE=circleci/postgres:11.5-alpine-postgis
|
||||
fi
|
||||
|
||||
# NOTE FWIW:
|
||||
# Brandon tried these options to speed up integration tests, but to little effect:
|
||||
# fsync=off
|
||||
@ -66,7 +72,7 @@ function pg_launch_container(){
|
||||
-p 127.0.0.1:"$PG_PORT":$PG_PORT \
|
||||
--expose="$PG_PORT" \
|
||||
-e POSTGRES_PASSWORD="$PG_PASSWORD" \
|
||||
-d circleci/postgres:11.5-alpine-postgis \
|
||||
-d "$PG_CONTAINER_IMAGE" \
|
||||
$CONF_FLAGS
|
||||
|
||||
# graphql-engine calls the pg_dump executable. To avoid a version mismatch (and
|
||||
|
@ -202,7 +202,17 @@ function pg_start() {
|
||||
function mssql_start() {
|
||||
mssql_launch_container
|
||||
MSSQL_RUNNING=1
|
||||
mssql_wait
|
||||
if [[ `uname -m` == 'arm64' ]]; then
|
||||
# mssql_wait uses the tool sqlcmd to wait for a database connection which unfortunately
|
||||
# is not available for the azure-sql-edge docker image - which is the only image from microsoft
|
||||
# that runs on M1 computers. So we sleep for 20 seconds, cross fingers and hope for the best
|
||||
# see https://github.com/microsoft/mssql-docker/issues/668
|
||||
|
||||
echo "Sleeping for 20 sec while mssql comes up..."
|
||||
sleep 20
|
||||
else
|
||||
mssql_wait
|
||||
fi
|
||||
}
|
||||
|
||||
function citus_start() {
|
||||
|
101
server/COMPILING-ON-M1.md
Normal file
101
server/COMPILING-ON-M1.md
Normal file
@ -0,0 +1,101 @@
|
||||
# Compile a native arm64 graphql-engine executable on M1 using brew and ghc-8.10.7
|
||||
|
||||
1. Install ghc-8.10.7 and cabal-install via ghcup
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
```sh
|
||||
brew install google-cloud-sdk
|
||||
brew install node@14
|
||||
brew install openssl
|
||||
brew install pcre
|
||||
brew install unixodbc
|
||||
brew install libpq
|
||||
brew install mysql-client@5.7
|
||||
brew install libffi
|
||||
brew install llvm@11
|
||||
```
|
||||
|
||||
And add them to your environment:
|
||||
|
||||
```sh
|
||||
echo 'export PATH="/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:$PATH"' >> ~/.zshrc
|
||||
echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
|
||||
echo 'export PATH="/opt/homebrew/opt/node@14/bin:$PATH"' >> ~/.zshrc
|
||||
echo 'export PATH="/opt/homebrew/opt/mysql-client@5.7/bin:$PATH"' >> ~/.zshrc
|
||||
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
|
||||
echo 'export PATH="/opt/homebrew/opt/llvm@11/bin:$PATH"' >> ~/.zshrc
|
||||
```
|
||||
|
||||
|
||||
3. Install console assets
|
||||
|
||||
```sh
|
||||
cd console
|
||||
npm ci
|
||||
npm run server-build
|
||||
cd ..
|
||||
```
|
||||
|
||||
4. Install python
|
||||
|
||||
```sh
|
||||
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"
|
||||
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
|
||||
|
||||
cd server
|
||||
python3 -m venv .python-venv
|
||||
source .python-venv/bin/activate
|
||||
pip3 install -r tests-py/requirements.txt
|
||||
(cd tests-py/remote_schemas/nodejs && npm ci)
|
||||
```
|
||||
|
||||
5. Add the C dependencies in the `cabal.project.dev-sh.local` and `cabal.project.local` files (according to where the dependencies were installed by homebrew):
|
||||
|
||||
```sh
|
||||
package mysql
|
||||
extra-include-dirs:
|
||||
/opt/homebrew/opt/openssl/include
|
||||
/opt/homebrew/opt/mysql-client@5.7/include
|
||||
extra-lib-dirs:
|
||||
/opt/homebrew/opt/openssl/lib
|
||||
/opt/homebrew/opt/mysql-client@5.7/lib
|
||||
|
||||
package odbc
|
||||
extra-include-dirs: /opt/homebrew/opt/unixodbc/include
|
||||
extra-lib-dirs: /opt/homebrew/opt/unixodbc/lib
|
||||
|
||||
package pcre-light
|
||||
extra-include-dirs: /opt/homebrew/opt/pcre/include
|
||||
extra-lib-dirs: /opt/homebrew/opt/pcre/lib
|
||||
|
||||
package postgresql-libpq
|
||||
extra-include-dirs:
|
||||
/opt/homebrew/opt/libpq/include
|
||||
/opt/homebrew/opt/openssl/include
|
||||
extra-lib-dirs:
|
||||
/opt/homebrew/opt/libpq/lib
|
||||
/opt/homebrew/opt/openssl/lib
|
||||
|
||||
package pg-client
|
||||
extra-include-dirs:
|
||||
/opt/homebrew/opt/libpq/include
|
||||
/opt/homebrew/opt/openssl/include
|
||||
extra-lib-dirs:
|
||||
/opt/homebrew/opt/libpq/lib
|
||||
/opt/homebrew/opt/openssl/lib
|
||||
```
|
||||
|
||||
Note: If you don't have special requirements of a `cabal.project.local` you can just add a symbolic link to `cabal.project.dev-sh.local`:
|
||||
|
||||
```sh
|
||||
ln -s cabal.project.dev-sh.local cabal.project.local
|
||||
```
|
||||
|
||||
|
||||
6. Building the server should now work:
|
||||
|
||||
```sh
|
||||
cabal v2-update
|
||||
cabal v2-build graphql-engine -j4
|
||||
```
|
Loading…
Reference in New Issue
Block a user