denoland / deno_docker

Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu
https://hub.docker.com/r/denoland/deno
MIT License
873 stars 101 forks source link

`deno compile` example? #369

Open AFCMS opened 1 month ago

AFCMS commented 1 month ago

Currently the README explains how to use deno with the deno run command inside the Docker images.

But there are no examples for using deno compile

I have tried to do so, but I didn't succeed, getting an error like that:

 => ERROR [build 10/10] RUN deno compile --output /app/custom_binary --allow-read=".env,.env.defaults,.env.example" --allow-net main.ts                           2.5s 
------                                                                                                                                                                    
 > [build 10/10] RUN deno compile --output /app/custom_binary --allow-read=".env,.env.defaults,.env.example" --allow-net main.ts:                                      
0.268 Check file:///app/main.ts                                                                                                                                           
0.368 Compile file:///app/main.ts to /app/custom_binary                                                                                                                
0.368 Download https://dl.deno.land/release/v1.44.0/denort-x86_64-unknown-linux-gnu.zip                                                                                   
1.775 Archive:  /tmp/.tmpyRVvzh/denort.zip
1.775   inflating: denort                  
2.365 error: Writing /app/custom_binary
2.365 
2.365 Caused by:
2.365     No such file or directory (os error 2)
------
Dockerfile:16
--------------------
  14 |     RUN ls -la && exit 0
  15 |     
  16 | >>> RUN deno compile --output /app/custom_binary --allow-read=".env,.env.defaults,.env.example" --allow-net main.ts
  17 |     
  18 |     FROM alpine as runtime
--------------------
ERROR: failed to solve: process "/bin/sh -c deno compile --output /app/custom_binary --allow-read=\".env,.env.defaults,.env.example\" --allow-net main.ts" did not complete successfully: exit code: 1
FROM denoland/deno:alpine as build

RUN apk add --no-cache unzip

WORKDIR /app

COPY deno.json /app/
COPY deno.lock /app/
COPY main.ts /app/
COPY schema.gen.ts /app/

RUN deno cache main.ts

RUN deno compile --output /app/custom_binary --allow-read=".env,.env.defaults,.env.example" --allow-net main.ts

FROM alpine as runtime

COPY --from=build /app/custom_binary /app/

CMD [ "/app/custom_binary" ]