-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
45 lines (33 loc) · 1.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
### Local linux/docker usage
# docker build --rm -t xchess .
# docker run --rm -it --name xchess -p 8080:8080 xchess
### BUILD
FROM hseeberger/scala-sbt:eclipse-temurin-17.0.2_1.6.2_2.13.8 AS build
# /root is the standard dir of the hseeberger/scala-sbt images
WORKDIR /root
# Configure SBT
ENV SBT_OPTS "-Xmx256M -Xss2M -Dfile.encoding=utf8 -Dsbt.log.noformat=true"
# Prepare SBT and download dependencies
COPY server/build.sbt .
COPY server/project/build.properties project/
RUN sbt update
# Build - collects all JARs in /root/target/universal/jars
COPY server/src src
RUN sbt collectJars
### LIST BUILD CONTEXT
FROM busybox AS buildcontext
RUN mkdir /context/
COPY . /context/
RUN find /context
### PRODUCTION IMAGE
FROM openjdk:17.0.2-slim AS prod
# Server install location, workdir for entrypoint
WORKDIR /opt/xchess/server
# Copy server
COPY --from=build /root/target/universal/jars lib
# Copy client
COPY client ../client
# We don't want to run the service as root user
RUN useradd -lMs /bin/bash docker
USER docker
CMD [ "java", "-cp", "lib/*", "-Xmx64M", "-XX:+ExitOnOutOfMemoryError", "xchess.Main" ]