diff --git a/registration-processor/init/registration-processor-dmz-packet-server/Dockerfile b/registration-processor/init/registration-processor-dmz-packet-server/Dockerfile index e1922f2297b..5a3826b4d2c 100644 --- a/registration-processor/init/registration-processor-dmz-packet-server/Dockerfile +++ b/registration-processor/init/registration-processor-dmz-packet-server/Dockerfile @@ -1,39 +1,32 @@ FROM nginx -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -# Define arguments for user and group +# Define arguments ARG container_user=mosip ARG container_user_group=mosip ARG container_user_uid=1001 ARG container_user_gid=1001 -# Expose port 8082 -EXPOSE 8082 +# Create a user and group inside the container +RUN addgroup --gid ${container_user_gid} ${container_user_group} && \ + adduser --disabled-password --gecos '' --uid ${container_user_uid} --gid ${container_user_gid} ${container_user} -# Set working directory +# Set the working directory WORKDIR /home/${container_user} -# Copy nginx configuration file +# Copy nginx.conf file COPY nginx.conf /etc/nginx/nginx.conf -# Ensure the user and group exist, copy files, set permissions -RUN groupadd -g ${container_user_gid} ${container_user_group} \ - && useradd -u ${container_user_uid} -g ${container_user_group} -m ${container_user} \ - && mkdir -p /home/mosip/landing/ \ - && cp /home/mosip/landing/healthcheck.txt /home/mosip/landing/healthcheck.txt.bak \ - && chown -R ${container_user}:${container_user} /home/${container_user} \ - && mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak \ - && mv /home/mosip/landing/healthcheck.txt /home/mosip/landing/healthcheck.txt.bak +# Copy healthcheck.txt file +COPY healthcheck.txt /home/${container_user}/landing/healthcheck.txt -# Start Nginx with daemon off -CMD ["nginx", "-g", "daemon off;"] +# Change ownership of /home/mosip directory +RUN chown -R ${container_user}:${container_user} /home/${container_user} +# Change user and group to the created user and group USER ${container_user_uid}:${container_user_gid} + +# Expose port 8082 +EXPOSE 8082 + +# Run nginx +CMD ["nginx", "-g", "daemon off;"]