-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Labels
documentationDocumentation related (improving, adding, etc)Documentation related (improving, adding, etc)
Description
Description of the modifications
I created a multipart dockerfile that doesn't take the already installed ansys product, but rather runs the AnsysInstaller.sh script in ubuntu. This is much easier for mac users.
This is basically the same as https://github.com/ansys/pymapdl/blob/main/docker/Dockerfile but multipart
Recommend adding this to the https://github.com/ansys/pymapdl/tree/main/docker folder and add instructions to https://github.com/ansys/pymapdl/blob/main/doc/source/getting_started/macos.rst
FROM ubuntu:22.04 AS builder
ARG MAPDL_PATH
RUN apt-get update && \
apt-get install -y libcurl4 libjpeg62 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-util1 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0 libxkbcommon0 lsb-core xfonts-100dpi xfonts-75dpi \
libglib2.0-0
RUN mkdir -p /ansys_inc
# Copying files
COPY $MAPDL_PATH .
RUN ./AnsysInstaller.sh -- -install_dir ./ansys_inc -nochecks -mechapdl -ansyscust -silent
FROM ubuntu:22.04
ARG VERSION
ARG USERNAME=mapdl
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Storing version in a env var
ENV ANSYS_VERSION=$VERSION
# Location env var
# This var needs to be updated when version changes.
ENV AWP_ROOT242=/ansys_inc
# LABELS
LABEL description="MAPDL on Ubuntu"
LABEL email="pyansys.core@ansys.com"
# OCI LABELS
LABEL org.opencontainers.image.documentation="https://mapdl.docs.pyansys.com"
# Update packages before packing and
# installing dependencies
# libxp.so missing. This is a workaround
#https://bugs.launchpad.net/ubuntu/+source/libxp/+bug/1517884
RUN apt-get update && \
apt-get install -y \
sudo \
git \
python3.10-venv \
python3-pip \
openssh-client \
libgomp1 \
libgl1 \
libglu1 \
libxm4 \
libxi6
# libxp.so missing. This is a workaround
#https://bugs.launchpad.net/ubuntu/+source/libxp/+bug/1517884
RUN apt install -y software-properties-common \
&& add-apt-repository -y ppa:zeehio/libxp \
&& apt-get update \
&& apt-get install -y libxp6
# Setting home directory
ENV HOME=/home/$USERNAME
RUN mkdir $HOME && touch $HOME/.bashrc
COPY --from=builder /ansys_inc /ansys_inc
# Setting working directory
ENV WORKING_DIRECTORY=/jobs
# Adding locales
RUN apt-get install -y locales && \
locale-gen 'en_US.UTF-8' && \
update-locale LC_ALL='en_US.UTF-8' && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen && \
echo -e '\nexport LANG=en_US.UTF-8\nexport LANGUAGE=en_US:en\nexport LC_ALL=en_US.UTF-8' >> ~/.bashrc
# Cleaning
RUN rm -rf .dockerignore \
&& rm -rf Dockerfile \
&& rm -rf *.log
# License server
# (Optional)
# ENV LICENSE_SERVER=111.222.333.444
# ENV ANSYSLMD_LICENSE_FILE=1055@$LICENSE_SERVER
# Add username, create the working directory and make it accessible to any user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \
mkdir -p /home/$USERNAME/$WORKING_DIRECTORY \
&& \
chown -R $USERNAME:$USERNAME /home/$USERNAME/$WORKING_DIRECTORY \
&& \
chmod a+rwx /home/$USERNAME/$WORKING_DIRECTORY
# Setting other env vars
## For MAPDL awareness
ENV ON_DOCKER=TRUE
ENV DEBIAN_FRONTEND=noninteractive
ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
# Adding alias to ansys executable
RUN echo 'alias ansys="/ansys_inc/v$ANSYS_VERSION/ansys/bin/mapdl"' >> ~/.bashrc && \
printf '#!/bin/bash\n/ansys_inc/v$ANSYS_VERSION/ansys/bin/mapdl "$@"' > /usr/bin/ansys && \
chmod +x /usr/bin/ansys && \
printf '#!/bin/bash\n/ansys_inc/v$ANSYS_VERSION/ansys/bin/mapdl -grpc "$@"' > /usr/bin/ansysgrpc && \
chmod +x /usr/bin/ansysgrpc
# Setting user
USER $USERNAME
WORKDIR /home/$USERNAME/$WORKING_DIRECTORY
# Setting entrypoint
EXPOSE 50052
ENTRYPOINT [ "bash", "-c", "/ansys_inc/v${ANSYS_VERSION}/ansys/bin/mapdl -grpc -dir ${WORKING_DIRECTORY}"]Useful links and references
No response
Metadata
Metadata
Assignees
Labels
documentationDocumentation related (improving, adding, etc)Documentation related (improving, adding, etc)