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

REST: Docker file for Rest catalog adapter image #11283

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,9 @@ project(':iceberg-snowflake') {

project(':iceberg-open-api') {
apply plugin: 'java-test-fixtures'
apply plugin: 'io.github.goooler.shadow'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Goooler/shadow is an archived repo. Is the plugin still maintained?


build.dependsOn shadowJar

dependencies {
testImplementation project(':iceberg-api')
Expand Down Expand Up @@ -1006,6 +1009,37 @@ project(':iceberg-open-api') {
recommend.set(true)
}
check.dependsOn('validateRESTCatalogSpec')

// Create a custom configuration that extends testFixturesImplementation and is resolvable
configurations {
testFixturesShadowImplementation {
canBeResolved = true
canBeConsumed = false
extendsFrom testFixturesImplementation
}
}

shadowJar {
archiveBaseName.set("iceberg-open-api-test-fixtures-runtime")
archiveClassifier.set(null)
configurations = [project.configurations.testFixturesShadowImplementation]
from sourceSets.testFixtures.output
zip64 true

// include the LICENSE and NOTICE files for the runtime Jar
from(projectDir) {
include 'LICENSE'
include 'NOTICE'
}

manifest {
attributes 'Main-Class': 'org.apache.iceberg.rest.RESTCatalogServer'
}
}

jar {
enabled = false
}
}

@Memoized
Expand Down
44 changes: 44 additions & 0 deletions docker/iceberg-rest-adapter-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

FROM azul/zulu-openjdk:17 as builder

WORKDIR /app/
COPY open-api/build/libs/iceberg-open-api-test-fixtures-runtime-*.jar /app/

FROM azul/zulu-openjdk:17-jre-headless

RUN \
set -xeu && \
groupadd iceberg --gid 1000 && \
useradd iceberg --uid 1000 --gid 1000 --create-home

WORKDIR /usr/lib/iceberg-rest
COPY --from=builder --chown=iceberg:iceberg /app/iceberg-open-api-test-fixtures-runtime-*.jar /usr/lib/iceberg-rest/iceberg-rest-adapter.jar

ENV CATALOG_CATALOG__IMPL=org.apache.iceberg.jdbc.JdbcCatalog
ENV CATALOG_URI=jdbc:sqlite:file:/tmp/iceberg_rest_mode=memory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this does not create an in-memory database, it ends up creating the file /tmp/iceberg_rest_mode=memory instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENV CATALOG_JDBC_USER=user
ENV CATALOG_JDBC_PASSWORD=password
ENV REST_PORT=8181
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these ENV variables acting as default values that are meant to be overridden?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


EXPOSE $REST_PORT
USER iceberg:iceberg
ENV LANG=en_US.UTF-8
CMD ["java", "-jar", "iceberg-rest-adapter.jar"]
87 changes: 87 additions & 0 deletions docker/iceberg-rest-adapter-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-->

# Iceberg rest adapter image

For converting different catalog implementations into a rest one.

## Building the Docker Image locally

If you want to make changes to the local files, and test them out, you can build the image locally and use that instead:

```bash
# Navigate to the iceberg root directory
cd ../../

# Build the project
./gradlew build -x test -x integrationTest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just build the iceberg-open-api project? i know it depends on other projects in the repo, so maybe it'll just end up building everything anyways...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is a manual process, user can choose if they want to build only open api module.

I prefer clean build as most of the things are needed for this module.


# Rebuild the docker image
docker image rm -f apache/iceberg-rest-adapter && docker build -t apache/iceberg-rest-adapter -f docker/iceberg-rest-adapter-image/Dockerfile .
```

## Browse

To browse the catalog, you can use `pyiceberg`:

```
➜ ~ pyiceberg --uri http://localhost:8181 list
default
nyc
ride_sharing_dataset
➜ ~ pyiceberg --uri http://localhost:8181 list nyc
nyc.taxis
nyc.taxis3
nyc.taxis4
nyc.taxis_copy_maybe
nyc.taxis_skeleton
nyc.taxis_skeleton2
➜ ~ pyiceberg --uri http://localhost:8181 describe --entity=table tpcds_iceberg.customer
Table format version 2
Metadata location s3://iceberg-test-data/tpc/tpc-ds/3.2.0/1000/iceberg/customer/metadata/00001-1bccfcc4-69f6-4505-8df5-4de78356e327.metadata.json
Table UUID dce215f7-6301-4a73-acc4-6e12db016abb
Last Updated 1653550004061
Partition spec []
Sort order []
Schema Schema
├── 1: c_customer_sk: optional int
├── 2: c_customer_id: optional string
├── 3: c_current_cdemo_sk: optional int
├── 4: c_current_hdemo_sk: optional int
├── 5: c_current_addr_sk: optional int
├── 6: c_first_shipto_date_sk: optional int
├── 7: c_first_sales_date_sk: optional int
├── 8: c_salutation: optional string
├── 9: c_first_name: optional string
├── 10: c_last_name: optional string
├── 11: c_preferred_cust_flag: optional string
├── 12: c_birth_day: optional int
├── 13: c_birth_month: optional int
├── 14: c_birth_year: optional int
├── 15: c_birth_country: optional string
├── 16: c_login: optional string
├── 17: c_email_address: optional string
└── 18: c_last_review_date: optional string
Snapshots Snapshots
└── Snapshot 0: s3://iceberg-test-data/tpc/tpc-ds/3.2.0/1000/iceberg/customer/metadata/snap-643656366840285027-1-5ce13497-7330-4d02-8206-7e313e43209c.avro
Properties write.object-storage.enabled true
write.object-storage.path s3://iceberg-test-data/tpc/tpc-ds/3.2.0/1000/iceberg/customer/data
```