forked from civiform/civiform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod.Dockerfile
51 lines (42 loc) · 1.81 KB
/
prod.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
# syntax=docker/dockerfile:1
# For production images, use the adoptium.net official JRE & JDK docker images.
FROM --platform=$BUILDPLATFORM eclipse-temurin:11.0.16_8-jdk-alpine AS stage1
ENV SBT_VERSION "1.6.2"
ENV INSTALL_DIR /usr/local
ENV SBT_HOME /usr/local/sbt
ENV PATH "${PATH}:${SBT_HOME}/bin"
ENV SBT_URL "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz"
RUN set -o pipefail && \
apk update && \
apk add --upgrade apk-tools && \
apk upgrade --available && \
apk add --no-cache --update bash wget npm git openssh && \
mkdir -p "$SBT_HOME" && \
wget -qO - "${SBT_URL}" | tar xz -C "${INSTALL_DIR}" && \
echo -ne "- with sbt $SBT_VERSION\n" >> /root/.built
ENV PROJECT_HOME /usr/src
ENV PROJECT_NAME server
ENV PROJECT_LOC "${PROJECT_HOME}/${PROJECT_NAME}"
COPY "${PROJECT_NAME}" "${PROJECT_LOC}"
RUN cd "${PROJECT_LOC}" && \
npm install -g [email protected] && \
npm install && \
sbt update && \
sbt dist && \
unzip "${PROJECT_LOC}/target/universal/civiform-server-0.0.1.zip" -d / && \
chmod +x /civiform-server-0.0.1/bin/civiform-server
# This is a common trick to shrink container sizes. We discard everything added
# during the build phase and use only the inflated artifacts created by sbt dist.
FROM eclipse-temurin:11.0.16_8-jre-alpine AS stage2
COPY --from=stage1 /civiform-server-0.0.1 /civiform-server-0.0.1
# Upgrade packages for stage2 to include latest versions.
RUN set -o pipefail && \
apk update && \
apk add --upgrade apk-tools && \
apk upgrade --available && \
apk add --no-cache --update bash openssh
ARG image_tag
ENV CIVIFORM_IMAGE_TAG=$image_tag
ARG git_commit_sha
LABEL civiform.git.commit_sha=$git_commit_sha
CMD ["/civiform-server-0.0.1/bin/civiform-server", "-Dconfig.file=/civiform-server-0.0.1/conf/application.conf"]