JetBrains/kotlin-compiler-server

Issues building docker file on windows machine

chriscoomber opened this issue · 4 comments

Hi, as you may have seen in my other issue I've been trying to create my own version of this server including my library. After giving up on Amazon Lambda I figured I could just use Amazon ECS with a docker image. Alas, docker build . didn't work for me.

C:\Users\chris\Documents\code\kotlin-compiler-server>docker build .
[+] Building 64.7s (10/20)
 => [internal] load build definition from Dockerfile                                                                                                                               0.0s
 => => transferring dockerfile: 1.24kB                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/openjdk:8-jdk-alpine                                                                                                           11.5s
 => [auth] library/openjdk:pull token for registry-1.docker.io                                                                                                                     0.0s
 => [internal] load build context                                                                                                                                                 51.9s
 => => transferring context: 409.05MB                                                                                                                                             51.9s
 => [build 1/6] FROM docker.io/library/openjdk:8-jdk-alpine@sha256:94792824df2df33402f201713f932b58cb9de94a0cd524164a0f2283343547b3                                                0.0s
 => CACHED [build 2/6] RUN mkdir -p /kotlin-compiler-server                                                                                                                        0.0s
 => CACHED [build 3/6] WORKDIR /kotlin-compiler-server                                                                                                                             0.0s
 => [build 4/6] ADD . /kotlin-compiler-server                                                                                                                                      0.6s
 => ERROR [build 5/6] RUN ./gradlew build -x test                                                                                                                                  0.6s
------
 > [build 5/6] RUN ./gradlew build -x test:
': No such file or directory 'sh
------
executor failed running [/bin/sh -c ./gradlew build -x test]: exit code: 127

I'm using a windows machine, and I guessed this error was something to do with that.

I worked around this by running the docker build . command from within a linux docker container.

For anyone else struggling over this I used the following command docker run -it -v //var/run/docker.sock:/var/run/docker.sock chriscoomber/android-kotlin to spin up an ubuntu image which I could then simply git clone my fork of kotlin-compile-server and then run docker build . (since I linked my host windows machine's docker socket to the container's docker socket, it creates a docker image on the host machine). That image chriscoomber/android-kotlin is simply an ubuntu image with various android-y and java-y things installed on it, as well as git and docker command-line tools. It's based on bilueandroid/android-kotlin.

Anyway, worth raising this issue to either improve the README.md to help out Windows users a bit more, or fix whatever was going wrong in the error above. Apologies if any of the above sounds dumb, I'm a complete noob to all of this.

Also, setting up Amazon ECS was pretty hard, but that's not you guys' fault! I swear they make the documentation intentionally hard for beginners to ensure those with the expertise get high salaries. But I got it working! http://18.130.70.180:8080/versions (pls no DDOS). Edit: that link no longer works - check out https://chriscoomber.github.io/manydice/

Hi! Validated it on my windows machine. Works fine.

Please make sure that you have latest version of Docker installed.

I'm using docker engine 20.10.2. This seems to be the latest version available on docker desktop for windows.

C:\Users\chris\Documents\code>docker -v
Docker version 20.10.2, build 2291f61

C:\Users\chris\Documents\code>git clone https://github.com/AlexanderPrendota/kotlin-compiler-server test
Cloning into 'test'...
remote: Enumerating objects: 5444, done.
remote: Total 5444 (delta 0), reused 0 (delta 0), pack-reused 5444
Receiving objects: 100% (5444/5444), 1.15 MiB | 238.00 KiB/s, done.
Resolving deltas: 100% (2115/2115), done.

C:\Users\chris\Documents\code>cd test

C:\Users\chris\Documents\code\test>docker build .
[+] Building 2.6s (9/19)
 => [internal] load build definition from Dockerfile                                                               0.1s
 => => transferring dockerfile: 1.24kB                                                                             0.0s
 => [internal] load .dockerignore                                                                                  0.1s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/openjdk:8-jdk-alpine                                            0.0s
 => [stage-1  1/10] FROM docker.io/library/openjdk:8-jdk-alpine                                                    0.0s
 => [internal] load build context                                                                                  1.7s
 => => transferring context: 1.97MB                                                                                1.6s
 => CACHED [build 2/6] RUN mkdir -p /kotlin-compiler-server                                                        0.0s
 => CACHED [build 3/6] WORKDIR /kotlin-compiler-server                                                             0.0s
 => [build 4/6] ADD . /kotlin-compiler-server                                                                      0.2s
 => ERROR [build 5/6] RUN ./gradlew build -x test                                                                  0.6s
------
 > [build 5/6] RUN ./gradlew build -x test:
': No such file or directory 'sh
------
executor failed running [/bin/sh -c ./gradlew build -x test]: exit code: 127

I'm running Windows 10 Home 64-bit (10.0, Build 19041).

I doubt this will have been fixed between 20.10.2 and 20.10.4. Maybe it's something else to do with my environment. I'm running docker via the CLI, on a plain old non-admin windows cmd prompt.

Fixed. You have to clone the repo into fresh directory to check it.

Fixed with the commit 4eca7f1