Skip to content

Commit d5d8c2b

Browse files
committed
Dremio Docker Container and Setup Script
1 parent bb933aa commit d5d8c2b

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# GH-48068 TODO: run remote ODBC tests on Linux
19+
20+
services:
21+
dremio:
22+
platform: linux/x86_64
23+
image: dremio/dremio-oss:latest
24+
ports:
25+
- 9047:9047 # REST API
26+
- 31010:31010 # JDBC/ODBC
27+
- 32010:32010
28+
container_name: dremio_container
29+
environment:
30+
- DREMIO_JAVA_SERVER_EXTRA_OPTS=-Dsaffron.default.charset=UTF-8 -Dsaffron.default.nationalcharset=UTF-8 -Dsaffron.default.collation.name=UTF-8$$en_US
31+
healthcheck:
32+
test: curl --fail http://localhost:9047 || exit 1
33+
interval: 10s
34+
timeout: 5s
35+
retries: 30
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# GH-48068 TODO: run remote ODBC tests on Linux
19+
20+
#!/bin/bash
21+
set -e
22+
23+
HOST_URL="http://localhost:9047"
24+
NEW_USER_URL="$HOST_URL/apiv2/bootstrap/firstuser"
25+
LOGIN_URL="$HOST_URL/apiv2/login"
26+
SQL_URL="$HOST_URL/api/v3/sql"
27+
28+
ADMIN_USER="admin"
29+
ADMIN_PASSWORD="admin2025"
30+
31+
# Wait for Dremio to be available.
32+
until curl -s "$NEW_USER_URL"; do
33+
echo 'Waiting for Dremio to start...'
34+
sleep 5
35+
done
36+
37+
echo ""
38+
echo 'Creating admin user...'
39+
40+
# Create new admin account.
41+
curl -X PUT "$NEW_USER_URL" \
42+
-H "Content-Type: application/json" \
43+
-d "{ \"userName\": \"$ADMIN_USER\", \"password\": \"$ADMIN_PASSWORD\" }"
44+
45+
echo ""
46+
echo "Created admin user."
47+
48+
# Use admin account to login and acquire a token.
49+
TOKEN=$(curl -s -X POST "$LOGIN_URL" \
50+
-H "Content-Type: application/json" \
51+
-d "{ \"userName\": \"$ADMIN_USER\", \"password\": \"$ADMIN_PASSWORD\" }" \
52+
| grep -oP '(?<="token":")[^"]+')
53+
54+
SQL_QUERY="Create Table \$scratch.ODBCTest As SELECT CAST(2147483647 AS INTEGER) AS sinteger_max, CAST(9223372036854775807 AS BIGINT) AS sbigint_max, CAST(999999999 AS DECIMAL(38,0)) AS decimal_positive, CAST(3.40282347E38 AS FLOAT) AS float_max, CAST(1.7976931348623157E308 AS DOUBLE) AS double_max, CAST(true AS BOOLEAN) AS bit_true, CAST(DATE '9999-12-31' AS DATE) AS date_max, CAST(TIME '23:59:59' AS TIME) AS time_max, CAST(TIMESTAMP '9999-12-31 23:59:59' AS TIMESTAMP) AS timestamp_max;"
55+
ESCAPED_QUERY=$(printf '%s' "$SQL_QUERY" | sed 's/"/\\"/g')
56+
57+
echo "Creating \$scratch.ODBCTest table."
58+
59+
# Create a new table by sending a SQL query.
60+
curl -i -X POST "$SQL_URL" \
61+
-H "Authorization: _dremio$TOKEN" \
62+
-H "Content-Type: application/json" \
63+
-d "{\"sql\": \"$ESCAPED_QUERY\"}"
64+
65+
echo ""
66+
echo "Finished setting up dremio docker instance."

0 commit comments

Comments
 (0)