Skip to content

Commit

Permalink
fix: nginx deployment and docker secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjibansg committed Feb 1, 2024
1 parent e9a0780 commit bf7f30d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 9 deletions.
5 changes: 4 additions & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ RUN pip install --no-cache-dir --upgrade -r /api/requirements.txt

COPY ./ /api/

CMD ["uvicorn", "app:app", "--reload", "--port", "9090"]
RUN --mount=type=secret,id=VITE_SESSION_SECRET \
cat /run/secrets/VITE_SESSION_SECRET

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--reload", "--port", "9090"]
2 changes: 1 addition & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def substrait_fiddle_openapi():


app = FastAPI()
app.include_router(router, prefix="/route")
app.include_router(router, prefix="/api/route")
app.openapi = substrait_fiddle_openapi
app.add_middleware(
TrustedHostMiddleware,
Expand Down
2 changes: 1 addition & 1 deletion api/components/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Pool size is default at 5 for maintaining
# 5 concurrent DuckDB connection objects
POOL_SIZE = int(os.environ.get("DUCKDB_POOL_SIZE"))
POOL_SIZE = int(os.environ.get("DUCKDB_POOL_SIZE", 5))



Expand Down
2 changes: 2 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM node:18-alpine as builder
WORKDIR /app
COPY . .
RUN --mount=type=secret,id=VITE_SESSION_SECRET \
cat /run/secrets/VITE_SESSION_SECRET
RUN npm ci
RUN npm run build

Expand Down
11 changes: 10 additions & 1 deletion client/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,14 @@ http {
server_tokens off;

root /app/static;

location /api/ {
proxy_pass http://api:9090; # Use the service name instead of IP
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
}
5 changes: 2 additions & 3 deletions client/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import inject from "@rollup/plugin-inject";

const path = require("path");

export default defineConfig({
base: '/',
plugins: [
vue(),
inject({
Expand All @@ -29,10 +29,9 @@ export default defineConfig({
server: {
proxy: {
"/api": {
target: "http://127.0.0.1:9090",
target: "http://api:9090",
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace("/api", ""),
},
},
},
Expand Down
23 changes: 21 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
version: '3.8'

services:
api:
build: ./api
ports:
- "9090:9090"
environment:
- DUCKDB_POOL_SIZE=5
- DUCKDB_POOL_SIZE=5
networks:
- fiddle-network
secrets:
- vite_sess_secrt

client:
build: ./client
ports:
- "80:8080"
- "8080:8080"
networks:
- fiddle-network
secrets:
- vite_sess_secrt

networks:
fiddle-network:
driver: bridge

secrets:
vite_sess_secrt:
external: true
name: "${secrets.VITE_SESSION_SECRET}"

0 comments on commit bf7f30d

Please sign in to comment.