Comments (9)
Oh, I see your snippet is from the README! Sorry about that, I will amend.
from deno_docker.
Oh, maybe this was the issue:
NOTE: I have no deps.ts file in my source directory
If you don't have a deps.ts then you should remove the deps.ts lines in the Dockerfile.
I recommend to have a deps.ts as this caches all of the dependencies and allows quicker iteration cycle (as dependencies don't need to be downloaded/compiled on each build).
In your case deps.ts would be:
// deps.ts
export { Application, Router } from "https://deno.land/x/oak/mod.ts";
// main.ts
import { Application, Router } from "./deps.ts";
const router = new Router();
router
...
from deno_docker.
If you change to
app.listen(`:1993`);
your example works (at least for me).
I suspect this is something to do with internal IP addresses inside the container... 🤷♂
(Perhaps https://stackoverflow.com/q/24319662/1240268 ?)
Note: This is a very simple example only meant to get my into a Docker container. I only have 3 files in the root of the directory (no other directories):
This should be sufficient (COPY and fetching deps.ts, then everything else) for even more complex deno projects (although the deno-lambda one I link to above is more complicated - since I want to aggressively cache compilation inside layers).
I'd eventually like to use this Docker container on an Azure App Service.
It reads in the documentation that this ought to be straightforward... it looks like the port to EXPORT will have to be 8000 (instead of 1993).
https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image
from deno_docker.
Yes, just changing the line to:
app.listen(`:1993`);
Worked for me as well.
from deno_docker.
Maybe I will.
Also, I also got this working locally by using this line too:
app.listen(`0.0.0.0:8000`);
from deno_docker.
Can you try with:
COPY deps.ts .
Similarly:
ADD . .
See the example: https://github.com/hayd/deno-docker/blob/master/example/Dockerfile
(And a more complicated example in deno-lambda)
from deno_docker.
Added deps.ts file:
export { Application, Router } from "https://deno.land/x/oak/mod.ts";
Modified main.ts file for deps.ts:
import { Application, Router } from "./deps.ts";
const router = new Router();
router
.get("/", context => {
console.log('called /');
context.response.body = "Hello world!";
})
.get('/fetch', async context => {
console.log('called /fetch');
const res = await fetch('https://pokeapi.co/api/v2/pokemon/ditto/')
.then(res => res.json());
context.response.body = JSON.stringify(res);
});
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
console.log('started on 1993');
app.listen(`127.0.0.1:1993`);
Updated the Dockerfile:
FROM hayd/deno:alpine-0.31.0
EXPOSE 1993
WORKDIR /app
# Prefer not to run as root.
USER deno
# Cache the dependencies as a layer (this is re-run only when deps.ts is modified).
# Ideally this will download and compile _all_ external files used in main.ts.
COPY deps.ts .
RUN deno fetch deps.ts
# These steps will be re-run upon each file change in your working directory:
ADD . .
# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno fetch main.ts
ENTRYPOINT ["deno", "run", "--allow-net", "main.ts"]
Now it builds:
docker build -t app .
And runs:
docker run -it --init -p 1993:1993 app
started on 1933
But when I try to curl > curl http://localhost:1993
curl: (52) Empty reply from server
Note: This is a very simple example only meant to get my into a Docker container. I only have 3 files in the root of the directory (no other directories):
- depts.ts
- Dockerfile
- main.ts
Just in case it matters somehow or you have some insight on this: I'd eventually like to use this Docker container on an Azure App Service.
Thank you for the help so far.
from deno_docker.
Just wanted to follow up.
I was able to deploy this image to ACR and then created an Azure web app from that running Deno. So basically a containerized Deno web app in Azure -- one step from serverless Deno.
Thanks again for your help!
from deno_docker.
Great! If you ever write anything up about this I'll happily link to it in the project (I think people will find it useful in the future).
from deno_docker.
Related Issues (20)
- Release improvements
- Create Alpine/APK package for Deno HOT 9
- Tini warning when building 1.28.1 image HOT 3
- Containers for 1.30.0 have Deno CLI version 1.29.4 HOT 2
- Add release workflow HOT 1
- Cache not caching all deps? HOT 10
- Become a docker verified publisher
- Use Docker official actions
- Document tini HOT 3
- Bash function not working as intended from the documentation
- No tag for 1.36.2 HOT 1
- Permission denied (os error 13) when writing to file from Dockerfile
- Simple express app segfaults in alpine Docker image HOT 2
- Docker sponsorship and/or alternate container registry options HOT 1
- Proposal: Distroless and Alpine image improvements. HOT 3
- Add ARM64 platform to docker images HOT 1
- Alpine ARM64 docker container broken HOT 1
- Latest image (1.40.5) missing unzip HOT 2
- Unable to pull v1.40.5 HOT 2
- Latest image broke nodejs / npm usage (maybe related to libgcc) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno_docker.