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

Proxy properties from .mill-jvm-opts don't have an effect #1986

Closed
aheiska opened this issue Aug 8, 2022 · 2 comments
Closed

Proxy properties from .mill-jvm-opts don't have an effect #1986

aheiska opened this issue Aug 8, 2022 · 2 comments
Labels
duplicate The issue is a duplicate of another one. Progress is tracked in another issue.
Milestone

Comments

@aheiska
Copy link
Contributor

aheiska commented Aug 8, 2022

I'm behind corporate proxy using custom certificates. I made container to run mill and configure all the local certificates.

The mill Dockerfile:

FROM eclipse-temurin:17-jdk-jammy

SHELL ["/bin/bash", "-c"]

COPY privateCert.crt /usr/local/share/ca-certificates/privateCert.crt
COPY privateCert2.crt /usr/local/share/ca-certificates/privateCert2.crt

ENV HTTP_PROXY="http://proxy.xxxxx.local:8080"
ENV HTTPS_PROXY="http://proxy.xxxxx.local:8080"
ENV NO_PROXY="localhost,127.0.0.1,.xxxxx.local"

ENV SCALA_VERSION=2.13.8
ENV MILL_VERSION=0.10.5

RUN \
  apt-get update && \
  apt-get install -y ca-certificates && \
  update-ca-certificates && \
  keytool -importcert -trustcacerts -file /etc/ssl/certs/privateCert.pem -alias private-cert -cacerts -noprompt -storepass changeit && \
  keytool -importcert -trustcacerts -file /etc/ssl/certs/privateCert2.pem -alias private-cert2 -cacerts -noprompt -storepass changeit

WORKDIR /root

# Install Scala
RUN \
  curl -fsL https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
  mv /root/scala-$SCALA_VERSION /opt/scala

ENV PATH="/opt/scala/bin:$PATH"

# Install mill
RUN \
  curl -L -o /usr/local/bin/mill https://github.com/lihaoyi/mill/releases/download/$MILL_VERSION/$MILL_VERSION && \
  chmod +x /usr/local/bin/mill

ENTRYPOINT /bin/bash

(I will add mill initialization here later, now container is kept as clean as possible for testing.)

I also have a trivial mill project

$ tree -a
.
├── app
│   └── src
│       └── App.scala
├── build.sc
└── .mill-jvm-opts

Where App is simple:

object App {
  def main(args: Array[String]): Unit = {
    println("Hello app")
    println(test())
  }

  def test(): String = {
    import upickle.default._
    write((1, "omg", true))
  }
}

build.sc is:

import mill._, scalalib._

object app extends ScalaModule {
  def scalaVersion = "2.13.8"

  def ivyDeps = Agg(
     ivy"com.lihaoyi::upickle:1.6.0"
  )
}

And .mill-jvm-opts is:

-Dhttp.proxyHost=proxy.xxxxx.local
-Dhttp.proxyPort=8080
-Dhttp.nonProxyHosts="localhost|127.0.0.1|*.local"
-Dhttps.proxyHost=proxy.xxxxx.local
-Dhttps.proxyPort=8080
-Dhttps.nonProxyHosts="localhost|127.0.0.1|*.local"

When running with this project in container result is:

$ docker run -it --rm --mount type=bind,source=`pwd`,target=/root/src mill-new
root@70a310842dd3:~# cd src/
root@70a310842dd3:~/src# mill -d app.run
Using explicit system properties: Map()
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 62.0M  100 62.0M    0     0  6572k      0  0:00:09  0:00:09 --:--:-- 15.7M
Preparing Java 17.0.4 runtime; this may take a minute or two ...
Compiling /root/src/build.sc
[2/45] mill.scalalib.ZincWorkerModule.classpath 
1 targets failed
mill.scalalib.ZincWorkerModule.classpath 
Resolution failed for 1 modules:
--------------------------------------------
  com.lihaoyi:mill-scalalib-worker_2.13:0.10.5 
	not found: /root/.ivy2/local/com.lihaoyi/mill-scalalib-worker_2.13/0.10.5/ivys/ivy.xml
	download error: Caught java.net.ConnectException (Connection timed out) while downloading https://repo1.maven.org/maven2/com/lihaoyi/mill-scalalib-worker_2.13/0.10.5/mill-scalalib-worker_2.13-0.10.5.pom

root@70a310842dd3:~/src#

However when proxy settings are given directly to mill

root@70a310842dd3:~/src# mill -D http.proxyHost=proxy.xxxxx.local -D http.proxyPort=8080 -D http.nonProxyHosts="localhost|127.0.0.1|*.local" -D https.proxyHost=proxy.xxxxx.local -D https.proxyPort=8080 -D https.nonProxyHosts="localhost|127.0.0.1|*.local" app.run
[32/45] app.compile 
Compiling compiler interface...
[info] compiling 1 Scala source to /root/src/out/app/compile.dest/classes ...
[info] done compiling
[45/45] app.run 
Hello app
[1,"omg",true]
root@70a310842dd3:~/src# 

it succeeds. Also if proxy settings are in JAVA_OPTS and mill is started with -i flag it runs successfully. Using -i with .mill-jvm-opts however fails at scalalib-worker fetch.

So currently when using mill behind proxy it requires either explicit config via -D flags or run with JAVA_OPTS with -i flag. Getting proxy properties from .mill-jvm-opts never seems to work.

@lefou
Copy link
Member

lefou commented Aug 9, 2022

@lefou lefou closed this as completed Aug 9, 2022
@lefou lefou added the duplicate The issue is a duplicate of another one. Progress is tracked in another issue. label Aug 9, 2022
@lefou lefou added this to the after 0.10.5 milestone Aug 9, 2022
@aheiska
Copy link
Contributor Author

aheiska commented Aug 9, 2022

Thanks. And sorry, completely missed #1908.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The issue is a duplicate of another one. Progress is tracked in another issue.
Projects
None yet
Development

No branches or pull requests

2 participants