Open abstractionfactory opened 1 week ago
Inspired by https://www.srvrlss.io/blog/Cloudflare-Worker-docker/
Dockerfile
# Use the official Node.js 10 image.
# https://hub.docker.com/_/node
FROM node:18
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package*.json ./
# Install production dependencies.
RUN npm install --only=production
RUN npm install wrangler --save-dev
# Copy local code to the container image.
COPY . ./
# Wrangler will prompt, and thus hang if you don't specify this
ENV WRANGLER_SEND_METRICS=false
ENV DATABASE_URL="postgresql://query-master:8waBeSvZk3xO@ep-summer-violet-a5ep4e0f.us-east-2.aws.neon.tech/registry-ui?sslmode=require"
# Run the web service on container startup.
CMD [ "npm", "start" ]
diff --git a/search/worker/package.json b/search/worker/package.json
index a9cb0a0..9afd542 100644
--- a/search/worker/package.json
+++ b/search/worker/package.json
@@ -5,7 +5,7 @@
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
- "start": "wrangler dev",
+ "start": "wrangler dev --ip 0.0.0.0",
"test": "vitest",
"cf-typegen": "wrangler types"
},
diff --git a/search/worker/wrangler.toml b/search/worker/wrangler.toml
index cc35b31..397e514 100644
--- a/search/worker/wrangler.toml
+++ b/search/worker/wrangler.toml
@@ -3,8 +3,10 @@ name = "registry-ui-search"
main = "src/index.ts"
compatibility_date = "2024-08-21"
compatibility_flags = ["nodejs_compat"]
+vars = { DATABASE_URL = "<REDACTED FILL ME IN>" }
docker build . -t myworker:latest docker run -i -p 8787:8787 -t myworker:latest
curl 'localhost:8787/registry/docs/search?q=vsphere' | jq | less
@cam72cam I'm further along than this, getting wrangler running is the tricky bit, but I'll sort it out hopefully soon.
We need a way to run the entire stack locally for development.