summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/apex-pdp-docker/src/main/docker/Dockerfile18
-rw-r--r--packages/apex-pdp-docker/src/main/docker/suse.Dockerfile20
-rwxr-xr-xpackages/apex-pdp-package-full/src/main/package/scripts/apexAsh.sh30
3 files changed, 41 insertions, 27 deletions
diff --git a/packages/apex-pdp-docker/src/main/docker/Dockerfile b/packages/apex-pdp-docker/src/main/docker/Dockerfile
index adea8e152..28a83db91 100644
--- a/packages/apex-pdp-docker/src/main/docker/Dockerfile
+++ b/packages/apex-pdp-docker/src/main/docker/Dockerfile
@@ -40,19 +40,15 @@ LABEL org.opencontainers.image.revision="${git.commit.id.abbrev}"
ARG POLICY_LOGS=/var/log/onap/policy/apex-pdp
ENV POLICY_HOME=/opt/app/policy/apex-pdp
ENV POLICY_LOGS=$POLICY_LOGS
+ENV APEX_HOME=$POLICY_HOME
+ENV APEX_USER=policy
-RUN apk update \
- && apk add --no-cache \
- vim \
- iputils \
- && addgroup -S apexuser && adduser -S apexuser -G apexuser \
- && mkdir -p $POLICY_HOME $POLICY_LOGS \
- && chown -R apexuser:apexuser $POLICY_HOME $POLICY_LOGS
+RUN mkdir -p $POLICY_HOME $POLICY_LOGS && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS
-COPY --chown=apexuser:apexuser --from=tarball /extracted $POLICY_HOME
-RUN cp -pr $POLICY_HOME/examples /home/apexuser
+COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME
-USER apexuser
+USER $APEX_USER
ENV PATH $POLICY_HOME/bin:$PATH
-WORKDIR /home/apexuser
+WORKDIR $APEX_HOME
ENTRYPOINT [ "/bin/sh" ]
diff --git a/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile b/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile
index d947a3cc7..9921f45e6 100644
--- a/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile
+++ b/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile
@@ -38,19 +38,21 @@ LABEL org.opencontainers.image.revision="${git.commit.id.abbrev}"
ARG POLICY_LOGS=/var/log/onap/policy/apex-pdp
ENV POLICY_HOME=/opt/app/policy/apex-pdp
ENV POLICY_LOGS=$POLICY_LOGS
+ENV APEX_HOME=$POLICY_HOME
+ENV APEX_USER=policy
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
ENV JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11
-RUN zypper -n -q install --no-recommends java-11-openjdk-devel netcat-openbsd \
- && zypper -n -q update && zypper -n -q clean --all \
- && groupadd --system apexuser && useradd --system --shell /bin/sh -G apexuser apexuser \
- && mkdir -p $POLICY_HOME $POLICY_LOGS \
- && chown -R apexuser:apexuser $POLICY_HOME $POLICY_LOGS
+RUN zypper -n -q install --no-recommends java-11-openjdk-devel netcat-openbsd && \
+ zypper -n -q update && zypper -n -q clean --all && \
+ groupadd --system policy && \
+ useradd --system --shell /bin/sh -G policy policy && \
+ mkdir -p $POLICY_HOME $POLICY_LOGS && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS
-COPY --chown=apexuser:apexuser --from=tarball /extracted $POLICY_HOME
-RUN cp -pr $POLICY_HOME/examples /home/apexuser
+COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME
-USER apexuser
+USER $APEX_USER
ENV PATH $POLICY_HOME/bin:$PATH
-WORKDIR /home/apexuser
+WORKDIR $APEX_HOME
ENTRYPOINT [ "/bin/sh" ]
diff --git a/packages/apex-pdp-package-full/src/main/package/scripts/apexAsh.sh b/packages/apex-pdp-package-full/src/main/package/scripts/apexAsh.sh
index 60608f922..0b7b25afb 100755
--- a/packages/apex-pdp-package-full/src/main/package/scripts/apexAsh.sh
+++ b/packages/apex-pdp-package-full/src/main/package/scripts/apexAsh.sh
@@ -2,7 +2,7 @@
#-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
-# Copyright (C) 2016-2018 Ericsson. All rights reserved.
+# Copyright (C) 2016-2022 Ericsson. All rights reserved.
# Modifications Copyright (C) 2020-2021 AT&T Intellectual Property.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,12 +21,28 @@
# ============LICENSE_END=========================================================
#-------------------------------------------------------------------------------
-# Run from the Apex home directory
-if [ ! -d /home/apexuser ]; then
- echo Apex user home directory "/home/apexuser" not found
- exit
+if [ -z $APEX_HOME ]; then
+ APEX_HOME="/opt/app/policy/apex-pdp"
+fi
+
+if [ ! -d $APEX_HOME ]; then
+ echo
+ echo 'Apex directory "'$APEX_HOME'" not set or not a directory'
+ echo "Please set environment for 'APEX_HOME'"
+ exit
+fi
+
+if [ -z "$APEX_USER" ]; then
+ APEX_USER="apexuser"
+fi
+
+id $APEX_USER > /dev/null 2>& 1
+if [ "$?" != "0" ]; then
+ echo 'cannot run apex, user "'$APEX_USER'" does not exit'
+ exit
fi
+# Run from the Apex home directory
+cd $APEX_HOME
# Run the command as "apexuser"
-cd /home/apexuser
-su apexuser
+su $APEX_USER