[Kotlin/Native] Linking stage fails
37 Replies
windows build succeeds. minimal repro: https://github.com/vyfor/kord-test
i think I need to build
curl
from source with websockets support. i copied a script that does just that, but now the linker is unable to find curl
at allThis is what we do https://github.com/kordlib/setup-curl/blob/v1/action.yml#L25-L38
GitHub
setup-curl/action.yml at v1 · kordlib/setup-curl
Contribute to kordlib/setup-curl development by creating an account on GitHub.
you can also find an example here
GitHub
GitHub - DRSchlaubi/alphabet: Test bot for Kord on Kotlin/JS and Ko...
Test bot for Kord on Kotlin/JS and Kotlin/Native. Contribute to DRSchlaubi/alphabet development by creating an account on GitHub.
works like a charm, thank you !
hey, i'm new to Docker, and i tried using that Docker template, but i'm not sure how the application is built. i added my build command to the Dockerfile, but it's just skipping it, and in the end, it can't find the compiled application:
Run the build outside of the container
the copy command is for copying files from outside the container into it
but you shouldn't build in the container b/c you'll be leaving all the development stuff in the layers
alternatively, you can use docker to build, but don't use a dockerfile for that, use the docker command directly and map a volume between a local build directory and the target directory in the container
but yeah really the canonical way to do this is to build outside of the container and then copy the result into it
ohh right, that's how it works
i'll give it a go
there isn't really any good reason to build inside the container
you can't run eg an ARM container on x64 anyway so
do you want a bit more in-depth info?
that'd be awesome
so, containers are structured in a more complex way than you'd expect
when you write a dockerfile, you're instructing the docker daemon on how to build the final container image
but it actually creates a separate layer for each actionable command
what that means is if, for example, you have a step running git, then a step downloading a toolchain, then a step building the project, then a step deleting the git files...
each one of those is a layer docker has to download and deploy whenever you use the container, and those layers also have to be uploaded to your docker registry
you really want to avoid doing that if you can
the containers themselves run in a very light virtualisation layer that shares the kernel with the host OS
which means you can't really cross-compile easily and the containers you're building and running will be specific to your machine's architecture
tho these days that's really just ARM and x64
(there are others, but commonly)
oh hmm i never realized that
docker is a lot simpler in concept than most people expect
then you have volumes, which allow you to map a path in a container to a mount of some sort
often that'll be a bind mount to a path on the host, but not always
the dockerfile won't contain a mapping, but you can still define the volumes you expect to exist
but you probably don't need to worry about that right now
this reference is pretty handy https://docs.docker.com/reference/dockerfile/
Docker Documentation
Dockerfile reference
Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more.
and if you need to generate a dockerfile based on your project's data, I released this today https://docs.kordex.dev/docker-plugin
Kord Extensions Help
Docker Plugin | Kord Extensions
gotcha! i've never had to deal with Docker before, i went for it as the hosting wouldn't allow me to do authorized stuff unless i used a container, though i found a workaround just now
docker is very useful
i don't understand one thing though
I'd recommend learning it for deployment work
ah?
you said that i have to run the build command outside of the container, but these two actually depend on each other
the linker needs curl setup beforehand
you'd build against curl statically
that way it'd be included in your final artefact
I am not sure if k/n can actually do that, though
i think the dockerfile builds libcurl, but expects the application to be already compiled
if you're building an application then you should have everything in the same environment
libcurl is a very common library
if you need to custom-compile it, then your build script should be doing that
you can technically still do that in docker, even in a dockerfile, but you don't want to upload that container once you've built it
so what you could do is build the container, then run it locally by tag
using a bind mount volume so you can get the output generated in some local directory
then you've got libcurl and you can put it wherever it needs to be for the project to build
and then create a new container
using another dockerfile
though really if you're building in docker you should be using a one-shot single use container
there's no reason you can't compile libcurl on the host if you're compiling this project as well
got it, either ways im forced to use a container
the build keeps failing though
The github actions yaml explains exactly how to compile libcurl with websocket support
Without a container
nevermind, i got the build working
thank you guys !
though i'd appreciate it if
kordx.emoji (feature/mpp)
could be republishedI would say that building in a seperate container (multi-stage build) is the canonical way these days
however building outside is better for caching
https://github.com/vyfor/kord-native-docker That's not how you're supposed to do it
GitHub
GitHub - vyfor/kord-native-docker: Docker base images for Kord nati...
Docker base images for Kord native applications. Contribute to vyfor/kord-native-docker development by creating an account on GitHub.
that's not how i'm doing it
i just copied the gh action
yeah that's also not what you are supposed to do
hmm
ghcr.io/kordlib/docker:main
is a runtime image, not a build-time image
it's there so you don't need to build curl inside your container
you install a bunch of things in your container you do not needi know that some of them aren't really necessary, but i've been struggling to get this app working for days. i got frustrated and ended up copying things from all kinds of gists until it finally worked lol
This way you just bloat your docker image since you have the entire c toolchain
got it, do you see any other issues with the dockerfile?
generially you shouldn't build in the end-product image, also you should not use cp and mv but the COPY and MOVE commands
simply copy mine
alright