Tech-Nik
Tech-Nik
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
docker run --name test --rm -p 9999:9999 uptimeflare:latest
⛅️ wrangler 3.57.0
-------------------
▲ [WARNING] --local is no longer required and will be removed in a future version.

`wrangler dev` now uses the local Cloudflare Workers runtime by default. :tada:


▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.


Your worker has access to the following bindings:
- KV Namespaces:
- UPTIMEFLARE_STATE: UPTIMEFLARE_STATE
⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:9999
⎔ Reloading local server...
docker run --name test --rm -p 9999:9999 uptimeflare:latest
⛅️ wrangler 3.57.0
-------------------
▲ [WARNING] --local is no longer required and will be removed in a future version.

`wrangler dev` now uses the local Cloudflare Workers runtime by default. :tada:


▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.


Your worker has access to the following bindings:
- KV Namespaces:
- UPTIMEFLARE_STATE: UPTIMEFLARE_STATE
⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:9999
⎔ Reloading local server...
never mind got it to work with another node image, still thank for your help
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
Ok I got a new error now, since wrangler wasnt install globally.
docker run --name test --rm uptimeflare:latest
🪵 Writing logs to "/root/.config/.wrangler/logs/wrangler-2024-05-17_09-08-42_848.log"
⛅️ wrangler 3.57.0
-------------------
[WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.

- KV Namespaces:
- UPTIMEFLARE_STATE: UPTIMEFLARE_STATE
Starting local server...
[wrangler-ProxyWorker:dbg] Updated `Request.cf` object cache!

/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:29749
throw a;
^

Error: spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
path: '/usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
spawnargs: [
'serve',
'--binary',
'--experimental',
'--socket-addr=entry=localhost:9999',
'--external-addr=loopback=localhost:36931',
'--control-fd=3',
'-',
'--verbose'
]
}

Node.js v20.13.1
docker run --name test --rm uptimeflare:latest
🪵 Writing logs to "/root/.config/.wrangler/logs/wrangler-2024-05-17_09-08-42_848.log"
⛅️ wrangler 3.57.0
-------------------
[WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.

- KV Namespaces:
- UPTIMEFLARE_STATE: UPTIMEFLARE_STATE
Starting local server...
[wrangler-ProxyWorker:dbg] Updated `Request.cf` object cache!

/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:29749
throw a;
^

Error: spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
path: '/usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
spawnargs: [
'serve',
'--binary',
'--experimental',
'--socket-addr=entry=localhost:9999',
'--external-addr=loopback=localhost:36931',
'--control-fd=3',
'-',
'--verbose'
]
}

Node.js v20.13.1
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
# Use Node.js 20 Alpine as base image
FROM node:20-alpine AS base

# Update package index and install necessary dependencies
RUN apk update

# Create and set the working directory
WORKDIR /app

# Copy the application code to the working directory
COPY ./data /app

# Install global npm packages and local dependencies
RUN npm install -g npm && \
npm install --save-dev wrangler

# Create a .env file
RUN touch .env

# Define volume for /app
VOLUME [ "/app" ]

# Expose port 9999
EXPOSE 9999

# Set the default command to run the development server
CMD ["wrangler", "dev", "--local", "-c", "worker/wrangler-dev.toml", "--node-compat", "--port", "9999", "--log-level", "debug"]
# Use Node.js 20 Alpine as base image
FROM node:20-alpine AS base

# Update package index and install necessary dependencies
RUN apk update

# Create and set the working directory
WORKDIR /app

# Copy the application code to the working directory
COPY ./data /app

# Install global npm packages and local dependencies
RUN npm install -g npm && \
npm install --save-dev wrangler

# Create a .env file
RUN touch .env

# Define volume for /app
VOLUME [ "/app" ]

# Expose port 9999
EXPOSE 9999

# Set the default command to run the development server
CMD ["wrangler", "dev", "--local", "-c", "worker/wrangler-dev.toml", "--node-compat", "--port", "9999", "--log-level", "debug"]
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
$ docker run --name test --rm uptimeflare:latest
node:internal/modules/cjs/loader:1148
throw err;
^

Error: Cannot find module '/app/wrangler'
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v20.13.1
$ docker run --name test --rm uptimeflare:latest
node:internal/modules/cjs/loader:1148
throw err;
^

Error: Cannot find module '/app/wrangler'
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v20.13.1
I don't understand why wrangler doesn't exist inside the docker container, well the files are there but i still get the error. As you can see, the files exist:
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #workers-help
Docker x Wrangler
bur i am installing them with npm install
3 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
any*
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
(I dont have anz experience with cloudflare workers so please excuse me)
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
Your worker has access to the following bindings:
- KV Namespaces:
- UPTIMEFLARE_STATE: UPTIMEFLARE_STATE
Starting local server...
[wrangler-ProxyWorker:dbg] Updated `Request.cf` object cache!

/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:29573
throw a;
^

Error: spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
path: '/usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
spawnargs: [
'serve',
'--binary',
'--experimental',
'--socket-addr=entry=localhost:9999',
'--external-addr=loopback=localhost:34009',
'--control-fd=3',
'-',
'--verbose'
]
}

Node.js v20.13.1
Your worker has access to the following bindings:
- KV Namespaces:
- UPTIMEFLARE_STATE: UPTIMEFLARE_STATE
Starting local server...
[wrangler-ProxyWorker:dbg] Updated `Request.cf` object cache!

/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:29573
throw a;
^

Error: spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
path: '/usr/local/lib/node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
spawnargs: [
'serve',
'--binary',
'--experimental',
'--socket-addr=entry=localhost:9999',
'--external-addr=loopback=localhost:34009',
'--control-fd=3',
'-',
'--verbose'
]
}

Node.js v20.13.1
so this would be the correct error ig
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
okay then the other message is the error, one sec im gonna spin up my server again
12 replies
CDCloudflare Developers
Created by Tech-Nik on 5/16/2024 in #general-help
Wrangler x Docker
ohhh i see
12 replies