-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile.api
72 lines (56 loc) · 2.71 KB
/
Dockerfile.api
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
66
67
68
69
70
71
72
FROM openjdk:11-slim
##
## This Dockerfile setups the SysML v2 API server and is designed to be
## run in conjunction with the Jupyter server. This dockerfile is specifically
## designed to be run with docker compose.
##
RUN apt-get --quiet --yes update && apt-get install -yqq wget xmlstarlet
##
## Use a non-root user for installation
##
ARG NB_USER=sysml
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
USER root
RUN chown -R ${NB_UID} ${HOME}
## Switch to the lowly user, no more root.
USER ${NB_USER}
WORKDIR ${HOME}
ARG SBT_VERSION=1.2.8
RUN wget -q https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz
## Defining the RELEASE down here ensures that the previous comamnds can
## be recycled since they're not affected by the release version.
ARG RELEASE=2023-02
RUN wget -q https://github.com/Systems-Modeling/SysML-v2-API-Services/archive/${RELEASE}.tar.gz?ts=20220819Z020300+00 -O ${RELEASE}.tar.gz
RUN tar xfz sbt-${SBT_VERSION}.tgz
RUN tar xfz ${RELEASE}.tar.gz
WORKDIR ${HOME}/SysML-v2-API-Services-${RELEASE}
##
## Basically this is all taken from
## https://github.com/Systems-Modeling/SysML-v2-API-Services
## and the installation instructions over there.
##
RUN ${HOME}/sbt/bin/sbt clean
RUN ${HOME}/sbt/bin/sbt update
RUN ${HOME}/sbt/bin/sbt compile
## Play framework complains about the secret key length...
RUN sed s/key=.whatever./key=\"longersecretnowarnings\"/ -i conf/application.conf
## need to allow the jupyter server access to the API server
ARG SYSML_API_SERVER="sysmlapiserver:9000"
RUN echo "\n\nplay.filters.hosts {\n allowed = [\"${SYSML_API_SERVER}\", \"localhost:9000\"]\n}\n" >> conf/application.conf
## set the database connection information
ARG DB_SERVER_URL="jdbc:postgresql://postgresdbserver:5432/sysml2"
ARG DB_USER="postgres"
ARG DB_PASSWORD="mysecretpassword"
RUN xmlstarlet ed --inplace -u '_:persistence/_:persistence-unit/_:properties/_:property[@name="javax.persistence.jdbc.url"]/@value' -v ${DB_SERVER_URL} conf/META-INF/persistence.xml \
&& xmlstarlet ed --inplace -u '_:persistence/_:persistence-unit/_:properties/_:property[@name="javax.persistence.jdbc.user"]/@value' -v ${DB_USER} conf/META-INF/persistence.xml \
&& xmlstarlet ed --inplace -u '_:persistence/_:persistence-unit/_:properties/_:property[@name="javax.persistence.jdbc.password"]/@value' -v ${DB_PASSWORD} conf/META-INF/persistence.xml \
&& xmlstarlet ed --inplace -u '_:persistence/_:persistence-unit/_:properties/_:property[@name="hibernate.hbm2ddl.auto"]/@value' -v "update" conf/META-INF/persistence.xml
EXPOSE 9000
ENTRYPOINT ${HOME}/sbt/bin/sbt run