Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/userguide dockerfile #1089

Merged
merged 5 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions documentation/userguide/docker/prod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUN dnf upgrade -y;\
dnf autoremove -y; \
dnf clean all; rm -rfv /var/cache/dnf

# Installing libraries
# Installing libraries
RUN dnf -y install shadow-utils wget
RUN dnf -y install openssl-devel bzip2-devel libffi-devel postgresql-devel gcc unzip tar gzip
Expand All @@ -24,31 +23,39 @@ RUN dnf -y install python$PYTHON_VERSION
RUN dnf -y install python$PYTHON_VERSION-pip

RUN groupadd -r ${CONTAINER_USER_GROUP} && useradd -r -m -g ${CONTAINER_USER_GROUP} ${CONTAINER_USER}
RUN chown -R ${CONTAINER_USER_GROUP}:root /usr/local/
RUN chown -R ${CONTAINER_USER}:root /tmp

USER ${CONTAINER_USER}
RUN mkdir -p /var/cache/nginx /var/log/nginx /var/lib/nginx /var/run/nginx /var/www/html && \
chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /var/cache/nginx /var/log/nginx /var/lib/nginx /var/run/nginx /var/www/html && \
touch /run/nginx.pid && chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /run/nginx.pid && \
mkdir -p /etc/nginx/templates /etc/nginx/ssl/certs && \
chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /etc/nginx

RUN touch ~/.bashrc
# Install necessary packages and grant permissions
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx

COPY --chown=${CONTAINER_USER}:root . ./
WORKDIR /app

RUN python$PYTHON_VERSION -m pip install -r documentation/userguide/requirements.txt
RUN python$PYTHON_VERSION -m mkdocs build
RUN chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /usr/local/
RUN chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /tmp
RUN chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /usr/share/nginx
RUN chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /etc/nginx
RUN chown -R ${CONTAINER_USER}:${CONTAINER_USER_GROUP} /app

USER ${CONTAINER_USER}

RUN curl -L https://github.com/a8m/envsubst/releases/download/$ENVSUBST_VERSION/envsubst-`uname -s`-`uname -m` -o /usr/local/bin/envsubst && \
chmod +x /usr/local/bin/envsubst
COPY --chown=${CONTAINER_USER}:root ./documentation/userguide/docker/prod/nginx.config /etc/nginx/nginx.template
RUN python$PYTHON_VERSION -m pip install -r requirements.txt
RUN python$PYTHON_VERSION -m mkdocs build
RUN touch ~/.bashrc

COPY --chown=${CONTAINER_USER}:${CONTAINER_USER_GROUP} . ./

RUN python$PYTHON_VERSION -m pip install -r ./requirements.txt
RUN python$PYTHON_VERSION -m mkdocs build -d usr/local/site

RUN curl -L https://github.com/a8m/envsubst/releases/download/$ENVSUBST_VERSION/envsubst-`uname -s`-`uname -m` -o /usr/local/bin/envsubst && \
chmod +x /usr/local/bin/envsubst
COPY --chown=${CONTAINER_USER}:root ./documentation/userguide/docker/prod/nginx.config /etc/nginx/nginx.template
COPY --chown=${CONTAINER_USER}:${CONTAINER_USER_GROUP} ./docker/prod/nginx.config /etc/nginx/nginx.template

CMD ["/bin/sh", "-c", "envsubst < /etc/nginx/nginx.template > /etc/nginx/conf.d/default.conf"]
CMD ["/bin/sh", "-c", "/usr/local/bin/envsubst < /etc/nginx/nginx.template > /etc/nginx/conf.d/default.conf"]

RUN cp -a site/. /usr/share/nginx/html/
RUN cp -a usr/local/site/. /usr/share/nginx/html/

CMD ["nginx", "-g", "daemon off;"]
Loading