frigjord
frigjord13mo ago

Can't connect to http server on official alpine deno with std serve.

I'm using the official alpine docker container to run deno, listening on port 8080, but a simple curl to it and I can't connect. Seems like it isn't listening at all. Deno server shows no error.
# Use the official Deno Docker image with version 1.32.0
FROM denoland/deno:alpine-1.32.0

# Set the working directory inside the container
WORKDIR /app

# Copy the necessary files to the container
COPY . .

RUN deno cache --lock=deno.lock --lock-write deps.ts
RUN deno cache --lock=deno.lock --lock-write server.js
RUN apk add vim curl

# Allow network access to the application
EXPOSE 8080

# Set the entrypoint command to run the Deno application
CMD ["deno", "run", "--allow-net", "--allow-env", "server.js"]
# Use the official Deno Docker image with version 1.32.0
FROM denoland/deno:alpine-1.32.0

# Set the working directory inside the container
WORKDIR /app

# Copy the necessary files to the container
COPY . .

RUN deno cache --lock=deno.lock --lock-write deps.ts
RUN deno cache --lock=deno.lock --lock-write server.js
RUN apk add vim curl

# Allow network access to the application
EXPOSE 8080

# Set the entrypoint command to run the Deno application
CMD ["deno", "run", "--allow-net", "--allow-env", "server.js"]
Using https://deno.land/std@0.123.0/http/server.ts works fine on local dev.
8 Replies
mmastrac
mmastrac13mo ago
If you change EXPOSE 8080 to EXPOSE 8000 does that work? The default port is 8000 and this is exposing 8080. Could you post your server.js file?
frigjord
frigjord13mo ago
We've tried most things, custom ports, custom hostnames, with http/https, different servers.
Hexagon
Hexagon13mo ago
Which comand do you use to run the container? Do you get any logs out of it?
frigjord
frigjord13mo ago
Thing is, we're connecting to the deno on the same container it runs on.. Logs aren't giving any clues or errors
export { serve } from "https://deno.land/std@0.123.0/http/server.ts";

async function handler (request, connInfo) {
return new Response('OK');
}

serve(handler, { port: 8080 });
export { serve } from "https://deno.land/std@0.123.0/http/server.ts";

async function handler (request, connInfo) {
return new Response('OK');
}

serve(handler, { port: 8080 });
Found the issue, redis client hanged indefinitely when connecting
bartlomieju
bartlomieju13mo ago
Are you using npm:redis?
frigjord
frigjord13mo ago
No the top redis package from deno.land
ioB
ioB13mo ago
@iuioiua is this yours?