-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
65 lines (60 loc) · 2.24 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# syntax=docker/dockerfile:latest
ARG BUILD_IMAGE=adoptopenjdk:11-jdk-hotspot
ARG JRE_IMAGE=adoptopenjdk:11-jre-hotspot
FROM ${BUILD_IMAGE} as build
SHELL [ "/bin/bash", "-cx" ]
WORKDIR /tmp
RUN apt update; apt install -yqq git curl wget ssh; \
mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
# COPY ./project/build.properties ./
# COPY <<EOF /root/.ssh/id_rsa
# PRIV KEY TO FETCH THE REPO
# EOF
RUN --mount=type=secret,id=git,target=/root/.ssh/id_rsa \
SBT_VERSION=$(grep 'sbt.version' build.properties | cut -d'=' -f2); \
curl -sLo - https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz | tar -xvzf -; \
mv sbt/bin/* /usr/local/bin/; \
chmod 0400 -cR /root/.ssh/id_rsa; \
rm -rf /tmp/*
WORKDIR /app
ENV JAVA_OPTS="-Xms4G -Xmx8G -Xss6M -XX:ReservedCodeCacheSize=256M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC"
ENV JVM_OPTS="-Xms4G -Xmx8G -Xss6M -XX:ReservedCodeCacheSize=256M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC"
ENV SBT_OPTS="-Xms4G -Xmx8G -Xss6M -XX:ReservedCodeCacheSize=256M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC"
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
COPY . .
RUN --mount=type=cache,target=/root/.sbt \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.ivy2 \
sbt dist; \
echo $APP_VERSION
FROM ${JRE_IMAGE} as extract
SHELL [ "/bin/bash", "-cx" ]
WORKDIR /app
RUN --mount=type=cache,target=/var/lib/apt/cache \
--mount=type=cache,target=/var/lib/cache \
apt update; \
apt install unzip -y
COPY --from=build /app/target/universal/ /app
RUN cp *.zip assetmantle.zip; \
ls -alt; \
unzip assetmantle.zip; \
ls -alt; \
rm *.zip; \
ls -alt; \
mv assetmantle* assetmantle; \
ls -alt
FROM scratch as dist
WORKDIR /
COPY --from=build /app/target/universal/assetmantle*.zip /assetmantle.zip
FROM ${JRE_IMAGE}
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
LABEL org.opencontainers.image.title=explorer
LABEL org.opencontainers.image.base.name=${JRE_IMAGE}
LABEL org.opencontainers.image.description=explorer
LABEL org.opencontainers.image.source=https://github.com/assetmantle/client
LABEL org.opencontainers.image.documentation=https://github.com/assetmantle/client
WORKDIR /
COPY --from=extract /app/assetmantle /explorer
CMD [ "/explorer/bin/assetmantle" ]