t-rex icon indicating copy to clipboard operation
t-rex copied to clipboard

Docker image for Apple M1

Open musicformellons opened this issue 4 years ago • 9 comments

When trying to use the docker version I get:

 ~  docker run sourcepole/t-rex --version                                              20.4s  Wed Jun  2 18:38:01 2021

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
t_rex 0.13.0 (GDAL version 3.0.4)

 ~  docker run -p 6767:6767 sourcepole/t-rex serve --bind=0.0.0.0 --openbrowser=false --config=myconfig.toml

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
2021-06-02 18:38:57.501 INFO Reading configuration from 'myconfig.toml'
Error reading configuration - Could not find config file!

Would it be possible to have an image for ARM64 ?

musicformellons avatar Jun 02 '21 19:06 musicformellons

I tried to make it. After installing latest (12.5.1) xcode, I ran:

SDKROOT=$(xcrun -sdk macosx --show-sdk-path) \
MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version) \
cargo build --release --target=aarch64-apple-darwin --verbose

It compiles without errors. When I try to run it (doubleclick on the created t_rex file) I get:

Last login: Tue Jun 29 22:31:42 on ttys006
/Users/usr/Downloads/t-rex-0.13.0/target/aarch64-apple-darwin/release/t_rex ; exit;
Darwin MacBook-Pro.local 20.5.0 x86_64
22:39  up 11 days,  1:36, 3 users, load averages: 1.79 3.04 3.58
 ~  /Users/usr/Downloads/t-rex-0.13.0/target/aarch64-apple-darwin/release/t_rex ; exit;
dyld: lazy symbol binding failed: Symbol not found: _GDALVersionInfo
  Referenced from: /Users/usr/Downloads/t-rex-0.13.0/target/aarch64-apple-darwin/release/t_rex
  Expected in: flat namespace

dyld: Symbol not found: _GDALVersionInfo
  Referenced from: /Users/usr/Downloads/t-rex-0.13.0/target/aarch64-apple-darwin/release/t_rex
  Expected in: flat namespace

fish: '/Users/usr/Downloads/t-rex-0.13.…' terminated by signal SIGABRT (Abort)

[Process completed]

Any suggestions how to proceed as I am kind of stuck now?

musicformellons avatar Jun 29 '21 20:06 musicformellons

I updated rust (from 1.51.0 to 1.53.0) and when compiling t-rex-core it gives:

error: custom inner attributes are unstable
 --> t-rex-core/src/mvt/vector_tile.rs:9:4
  |
9 | #![rustfmt::skip]
  |    ^^^^^^^^^^^^^
  |
  = note: `#[deny(soft_unstable)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>

error: aborting due to previous error

error: could not compile `t-rex-core`

when I comment line 9 out it compiles, but the symbol error returns.

musicformellons avatar Jul 01 '21 06:07 musicformellons

The build error with [rustfmt::skip] is fixed in current master (#244). But this probably doesn't solve the build problem.

pka avatar Jul 06 '21 20:07 pka

Retried with the master branch:

error: failed to run custom build command for `gdal-sys v0.3.1`

Caused by:
  process didn't exit successfully: `/Users/pq/Projects/t-rex/target/release/build/gdal-sys-5f325f970b7f9ed2/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=GDAL_STATIC
  cargo:rerun-if-env-changed=GDAL_DYNAMIC
  cargo:rerun-if-env-changed=GDAL_INCLUDE_DIR
  cargo:rerun-if-env-changed=GDAL_LIB_DIR
  cargo:rerun-if-env-changed=GDAL_HOME
  cargo:rerun-if-env-changed=GDAL_VERSION
  cargo:rerun-if-env-changed=GDAL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rustc-link-search=native=/usr/local/Cellar/gdal/3.3.1/lib
  cargo:rustc-link-lib=gdal
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rustc-cfg=gdal_sys_3_3_1

  --- stderr
  thread 'main' panicked at 'No pre-built bindings available for GDAL version 3.3. Use `--features bindgen` to generate your own bindings.', /Users/pq/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-sys-0.3.1/build.rs:219:17
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

I installed gdal with brew.

zouterover avatar Jul 07 '21 13:07 zouterover

I could not easily figure out how to leave out the optional gdal, so I commented out the features and gdal dependency lines in the main cargo.toml. It compiles and when I run the t_rex build it gives:

Last login: Wed Jul  7 16:11:11 on ttys000
/Users/pq/Projects/t-rex/target/aarch64-apple-darwin/release/t_rex ; exit;
Darwin MacBook-Pro.local 20.5.0 x86_64
16:37  up 5 days, 18:32, 3 users, load averages: 5.37 3.07 2.15
 ~  /Users/pq/Projects/t-rex/target/aarch64-apple-darwin/release/t_rex ; exit;
t_rex 0.14.0-dev
Pirmin Kalberer <[email protected]>
vector tile server specialized on publishing MVT tiles from your own data

USAGE:
    t_rex [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    drilldown    Tile layer statistics
    genconfig    Generate configuration template
    generate     Generate tiles for cache
    help         Prints this message or the help of the given subcommand(s)
    serve        Start web server and serve MVT vector tiles


[Process completed]

I don't really know whether I need the gdal dependency, but kind of looks like it works right?!

zouterover avatar Jul 07 '21 14:07 zouterover

This looks good. You need GDAL for non-PostGIS data (like GPKG or Shp) only. The proper way for building without GDAL is cargo build --all --no-default-features

pka avatar Jul 07 '21 21:07 pka

when I run cargo build --all --no-default-features it seems GDAL is still troubling me:

 ...
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rustc-cfg=gdal_sys_3_3_1

  --- stderr
  thread 'main' panicked at 'No pre-built bindings available for GDAL version 3.3. Use `--features bindgen` to generate your own bindings.', /Users/pq/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-sys-0.4.0/build.rs:219:17
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

musicformellons avatar Jul 19 '21 20:07 musicformellons

The above is actually an attempt to have a t-rex app that works on Apple Silicon. I think I got that working (without gdal) by cross-compiling to aarch64-apple-darwin. In the meantime I noticed however what I really need is a (ubuntu) container that runs on Apple Silicon with T-rex in it. For that to work I need to cross-compile T-rex to aarch64-unknown-linux-gnu so it matches an ubuntu container that runs on Apple Silicon. When doing so I run into openssl-sys cross-compile issues which are 'known' and apparently hard to tackle.

musicformellons avatar Aug 18 '21 07:08 musicformellons

Looks like openssl could be swapped by rustls: https://github.com/rustls/rustls which might solve above issue.

musicformellons avatar Jan 09 '22 15:01 musicformellons