wso2 / docker-apim

Docker and Docker Compose resources for WSO2 API Manager
Apache License 2.0
143 stars 215 forks source link

Error when restarting docker container with profiles active #473

Open diogopruch opened 2 years ago

diogopruch commented 2 years ago

Description:

For the first image build and and container run with the the environment variable PROFILE_NAME=control-plane or PROFILE_NAME=gateway-worker it works ok. However when the container is restarted, an error occurs because the script sh ${WSO2_SERVER_HOME}/bin/profileSetup.sh -Dprofile=${PROFILE_NAME} is executed again.

I solved this problem, removing the lines from docker-entrypoint.sh files:

# optimize WSO2 Carbon Server, if the profile name is defined as an environment variable
if [[ ! -z "${PROFILE_NAME}" ]]
then
  echo "Optimizing WSO2 Carbon Server" >&2
  sh ${WSO2_SERVER_HOME}/bin/profileSetup.sh -Dprofile=${PROFILE_NAME}
fi

Adding the lines to the Dockerfile files:

# optimize WSO2 Carbon Server, if the profile name is defined as an environment variable
ARG PROFILE_NAME
ENV PROFILE_NAME=${PROFILE_NAME}
RUN if [ ! -z "$PROFILE_NAME" ] ; then sh ${WSO2_SERVER_HOME}/bin/profileSetup.sh -Dprofile=${PROFILE_NAME} ; fi

And executing the build with arguments instead of ENV variable:

docker build --build-arg PROFILE_NAME=control-plane

Suggested Labels:

Suggested Assignees:

Affected Product Version:

Docker container wso2am-4.1.0

Steps to reproduce:

Restart a docker container with ENV variable PROFILE_NAME=control-plane or PROFILE_NAME=gateway-worker

Related Issues: