forked from vivo-community/scholars-discovery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
64 lines (48 loc) · 1.41 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
# Settings.
ARG USER_ID=3001
ARG USER_NAME=scholars
ARG HOME_DIR=/$USER_NAME
ARG SOURCE_DIR=$HOME_DIR/source
# Maven stage.
FROM maven:3-eclipse-temurin-17-alpine AS maven
ARG USER_ID
ARG USER_NAME
ARG HOME_DIR
ARG SOURCE_DIR
# Create the group (use a high ID to attempt to avoid conflits).
RUN addgroup -g $USER_ID $USER_NAME
# Create the user (use a high ID to attempt to avoid conflits).
RUN adduser -h $HOME_DIR -u $USER_ID -G $USER_NAME -D $USER_NAME
# Update the system.
RUN apk -U upgrade
# Set deployment directory.
WORKDIR $SOURCE_DIR
# Copy files over.
COPY ./checkstyles.xml ./checkstyles.xml
COPY ./pom.xml ./pom.xml
COPY ./src ./src
COPY ./solr ./solr
# Assign file permissions.
RUN chown -R ${USER_ID}:${USER_ID} ${SOURCE_DIR}
# Login as user.
USER $USER_NAME
# Build.
RUN mvn package
# Switch to Normal JRE Stage.
FROM eclipse-temurin:17-alpine
ARG USER_ID
ARG USER_NAME
ARG HOME_DIR
ARG SOURCE_DIR
# Create the group (use a high ID to attempt to avoid conflits).
RUN addgroup -g $USER_ID $USER_NAME
# Create the user (use a high ID to attempt to avoid conflits).
RUN adduser -h $HOME_DIR -u $USER_ID -G $USER_NAME -D $USER_NAME
# Login as user.
USER $USER_NAME
# Set deployment directory.
WORKDIR $HOME_DIR
# Copy over the built artifact from the maven image.
COPY --from=maven $SOURCE_DIR/target/middleware*.jar ./scholars-discovery.jar
# Run java command.
CMD ["java", "-jar", "./scholars-discovery.jar"]