Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno compile example? #369

Open
AFCMS opened this issue Jun 4, 2024 · 5 comments
Open

deno compile example? #369

AFCMS opened this issue Jun 4, 2024 · 5 comments

Comments

@AFCMS
Copy link

AFCMS commented Jun 4, 2024

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" ]
@twosaturdayscode
Copy link

I got the same issue it seems to happen only inside Docker containers, but the strange thing is that if I run it manually inside a devcontainer this error does not occur

@chrismclarke
Copy link

chrismclarke commented Nov 19, 2024

I get the same issue. It seems unhappy using alpine as the second stage (there seem to be a number of issues related to glibc requirements)

So if running a multi-stage build you still need to use denoland/deno:alpine in the runtime stage, which doesn't save anywhere near as much on image size.

Similar issue noted in #428, #373 and #350, there's also a lot of discussion on https://github.com/denoland/deno_docker/issues/373

If you really need to use the alpine image I think the workarounds included here should fix:
https://github.com/dojyorin/deno_docker_image/blob/master/src/alpine.dockerfile

@twosaturdayscode
Copy link

twosaturdayscode commented Nov 22, 2024

It seemes like with version 2.1.1 on Debian it is solved at least for my case, give it a try

@proof-llc
Copy link

proof-llc commented Nov 22, 2024

@twosaturdayscode i still get errors - can you provide a short version of your Dockerfile to compare?

@twosaturdayscode
Copy link

@twosaturdayscode i still get errors - can you provide a short version of your Dockerfile to compare?

I think it would just confuse you, but let me give more details about my case, I'm using denoland/deno:debian-2.1.1 as base image for my devcontainer that will use the docker-in-docker feature, then I have a post-create hook that compiles a cli of mine, when I use the 2.0.6 it would always fail saying the same error of OP but since I've switched it doesn't occur anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants