Skip to content

Commit

Permalink
[MOSIP-31575] Updated docker file.
Browse files Browse the repository at this point in the history
Signed-off-by: abhishek8shankar <[email protected]>
  • Loading branch information
abhishek8shankar authored Apr 3, 2024
1 parent 6ca6bd2 commit 53d8710
Showing 1 changed file with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -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;"]

0 comments on commit 53d8710

Please sign in to comment.