Skip to content

Commit

Permalink
chore: provide custom https server
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashimin committed Jul 14, 2024
1 parent 8911ae5 commit 458e6f0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
7 changes: 2 additions & 5 deletions docker/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ networks:
services:
bootstrap:
image: ghcr.io/canner/wren-bootstrap:${WREN_BOOTSTRAP_VERSION}
pull_policy: always
platform: ${PLATFORM}
environment:
DATA_PATH: /app/data
Expand All @@ -22,7 +21,6 @@ services:

wren-engine:
image: ghcr.io/canner/wren-engine:${WREN_ENGINE_VERSION}
pull_policy: always
platform: ${PLATFORM}
expose:
- ${WREN_ENGINE_SQL_PORT}
Expand All @@ -37,8 +35,8 @@ services:

wren-ai-service:
image: ghcr.io/canner/wren-ai-service:${WREN_AI_SERVICE_VERSION}
pull_policy: always
platform: ${PLATFORM}
pull_policy: never
ports:
- ${AI_SERVICE_FORWARD_PORT}:${WREN_AI_SERVICE_PORT}
environment:
Expand All @@ -53,6 +51,7 @@ services:
# sometimes the console won't show print messages,
# using PYTHONUNBUFFERED: 1 can fix this
PYTHONUNBUFFERED: 1
command: [ "/app/entrypoint.sh" ]
networks:
- wren
depends_on:
Expand All @@ -61,7 +60,6 @@ services:

ibis-server:
image: ghcr.io/canner/wren-engine-ibis:${IBIS_SERVER_VERSION}
pull_policy: always
platform: ${PLATFORM}
expose:
- 8000
Expand All @@ -75,7 +73,6 @@ services:

qdrant:
image: qdrant/qdrant:v1.7.4
pull_policy: always
ports:
- 6333:6333
- 6334:6334
Expand Down
1 change: 1 addition & 0 deletions wren-ai-service/src/force_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async def force_deploy():
async with aiohttp.ClientSession() as session:
async with session.post(
f"{os.getenv("WREN_UI_ENDPOINT", "http://wren-ui:3000")}/api/graphql",
ssl=False,
json={
"query": "mutation Deploy($force: Boolean) { deploy(force: $force) }",
"variables": {"force": True},
Expand Down
1 change: 1 addition & 0 deletions wren-ai-service/src/providers/engine/wren.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async def dry_run_sql(
) -> Tuple[bool, Optional[Dict[str, Any]]]:
async with session.post(
f"{self._endpoint}/api/graphql",
ssl=False,
json={
"query": "mutation PreviewSql($data: PreviewSQLDataInput) { previewSql(data: $data) }",
"variables": {
Expand Down
3 changes: 2 additions & 1 deletion wren-ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"!**/*",
".next/**/*",
"src/apollo/client/graphql/__types__.ts",
"src/apollo/client/graphql/*.generated.ts"
"src/apollo/client/graphql/*.generated.ts",
"server.https.js"
],
"overrides": [
{
Expand Down
30 changes: 30 additions & 0 deletions wren-ui/server.https.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { createServer } = require('https');
const mkcert = require('mkcert');
const fs = require('fs');
const { parse } = require('url');
const path = require('path');
const next = require('next');

const currentPort = parseInt(process.env.PORT, 10) || 3000
const hostname = process.env.HOSTNAME || '0.0.0.0'

const app = next({
dev: false,
hostname,
port: currentPort,
});

const httpsOptions = {
key: fs.readFileSync(path.join(__dirname, 'certificates/localhost-key.pem')),
cert: fs.readFileSync(path.join(__dirname, 'certificates/localhost.pem')),
}

const handle = app.getRequestHandler();
app.prepare().then(async () => {
createServer(httpsOptions, async (req, res) => {
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
}).listen(currentPort, async () => {
console.log(`> Ready on https://${hostname}:${currentPort}`);
});
});

0 comments on commit 458e6f0

Please sign in to comment.