Closed raphaeljoie closed 5 years ago
sbt "set test in assembly := {}" server/assembly
works for me - you only want to build the assembly for the server project.
The result will then be in server/target/scala-2.12/elasticmq-server-assembly-VERSION.jar
Thanks a lot. It's working as expected. Open question : why did you decide to load the jar from the mirroring site, instead of building the project directly in the Docker image ?
Here is my final Dockerfile:
FROM openjdk:8-alpine
ENV SBT_VERSION 1.1.4
ENV SBT_HOME /usr/local/sbt
ENV PATH ${PATH}:${SBT_HOME}/bin
ENV VERSION 0.13.10
RUN apk add --update \
git \
&& rm -rf /var/cache/apk/*
# Install sbt
RUN apk add --update curl ca-certificates bash && \
curl -sL "https://piccolo.link/sbt-$SBT_VERSION.tgz" | gunzip | tar -x -C /usr/local && \
echo -ne "- with sbt $SBT_VERSION\n" >> /root/.built &&\
apk del curl
# Define working directory
WORKDIR /app
RUN git clone https://github.com/adamw/elasticmq.git . && git checkout tags/v${VERSION}
# do a first run to isolate sbt initialisation to the other sbt commands
RUN sbt exit
RUN sbt "set test in assembly := {}" server/assembly
COPY custom.conf custom.conf
RUN echo "#!/bin/sh" > entrypoint.sh \
&& echo "java -Dconfig.file=custom.conf -jar server/target/scala-2.12/elasticmq-server-assembly-${VERSION}.jar" >> entrypoint.sh \
&& chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
EXPOSE 9324
Well I suppose the Docker image could run the build on the host, and use that - however I'm not the author of the Dockerfile
, so I can't say what the exact reasoning was.
I don't think there's normally a need to build the project in docker? And even if, the image to build the server would be different from the image containing the server. That latter doesn't need to include sbt, for example, only java.
You're right, including jar directly in the Docker image has the same effect. The advantage to put the build instructions in the Dockerfile is to provide a complete working example of this process.
Anyway, great library ! I tested it this weekend and will certainly use it for tests in CI.
@raphaeljoie Right, though isn't it still the "standard practice" to build outside of docker, and only create docker images with the build artifacts, vs. building inside the docker image?
Anyway, at least documenting how to build locally is definitely a good idea :)
To be honest, I don't know about this practice since I've never published any Docker image. I only use it for dev, tests and internal deployments. that said, I could understand this practice since it's way faster to download a package than to build it from scratch.
From my experience I know that the build process of an opensource library often fails because of a slight environment change. No matter the quality of the doc. And I personally find it easier to get the build I want if the repo's owner gives the exact commands he used to gets its own, starting from git clone
to the final run.sh
in a neutral environment (i.e. a Docker image).
but maybe the best solution to keep the image fast to build is to put the "docker-like" instructions directly in the doc ?
I'm no expert on docker best practices as well :) I think it might make sense to have two docker images: one for building the project, the other for using it. No idea how to implement this though :)
Adding instructions in the docs is a great idea - could you submit a PR maybe?
Hi, I want to build my own jar of this great project but I'm not an expert in Scala and I hit an error in the tests each time I run
sbt 'set test in assembly := {}' assembly
Can you explain how to run
sbt assembly
without the tests in non-interactive mode ? Or how to updatebuild.sbt
to remove those tests ?best regards,
You can recreate the issue with the following Dockerfile
error is