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: combine the docker-compose files #3169

Merged
merged 11 commits into from
Jun 18, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ docker/mapdl/v211
docker/mapdl/v212
docker/mapdl/_old
docker/mapdl/*.sh
distributions/
Revathyvenugopal162 marked this conversation as resolved.
Show resolved Hide resolved
Revathyvenugopal162 marked this conversation as resolved.
Show resolved Hide resolved


# temp testing
Expand Down
6 changes: 6 additions & 0 deletions doc/source/getting_started/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ Using the `docker-compose.yml <pymapdl_docker_compose_base_>`_ file is recommend
This is the *base* configuration file for launching an instance of MAPDL that you can connect
to remotely.

you can use the following command to launch MAPDL:

.. code:: bash

docker-compose -f docker-compose.yml up -d mapdl


.. _pymapdl_connect_to_MAPDL_container:

Expand Down
17 changes: 0 additions & 17 deletions docker/docker-compose.dpf.yml

This file was deleted.

39 changes: 0 additions & 39 deletions docker/docker-compose.local.yml

This file was deleted.

127 changes: 101 additions & 26 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,133 @@
version: '3.3'

# This is a docker-compose file which launch a remote MAPDL instance in a dockerized environment.
# You can connect to this instance throught the port 50052 and 50055 (for the database feature).
# This is a docker-compose file that will run Ansys MAPDL, and optionally DPF, in a container.
# You can connect to this instance through port 50052 and 50055 (for the MAPDL database feature).
# DPF server can be connected to using the port 50056.
#
# For the license, you need to provide the hostname of the license server.
# For the license, you need to provide the hostname of the license server using ``ANSYSLMD_LICENSE_FILE``
# environment variable.
#
# REQUIREMENTS:
# =============
#
# - docker
# - docker images from ghcr.io (you might need to do 'docker login ghcr.io' first)
# - Docker
# - MAPDL docker images
# - (Optional) DPF docker images
#
# USAGE:
# ======
# USAGE
# =====
#
# 1. You need two environment variables. One called ``DOCKER_IMAGE`` which contains the path to the
# docker image, and another one called ``ANSYSLMD_LICENSE_FILE`` which points to the license server.
# 1. You need two environment variables. One called `DOCKER_IMAGE` which contains the path to the
# Docker image, and another one called `ANSYSLMD_LICENSE_FILE` which points to the license server.
# For example:
#
# export ANSYSLMD_LICENSE_FILE=1055@mylicensehost
# export DOCKER_IMAGE=myregistry.com/myimage:mytag
# .. code:: bash
#
# export ANSYSLMD_LICENSE_FILE=1055@mylicenseserver
# export DOCKER_IMAGE=myregistry.com/myimage:mytag
# export DPF_DOCKER_IMAGE=myregistry.com/mydpfimage:mydpftag # optional
#
# Additionally you can also configure the following environment variables:
#
# - ``AWP_ROOT``: Set the environment variable ``AWP_ROOTXXX`` where XXX is the MAPDL version.
# For instance, MAPDL 2022R1 is 222.
# - ``AWP_ROOT_VALUE``: Set the value of the ``AWP_ROOTXXX`` environment variable, which normally points
# to the MAPDL installation directory.
# - ``DOCKER_USER``: It should match the username inside the container. You can obtain this value by executing
# ``echo $USER`` in a terminal inside the container.
#
# 2. Run the following command:
# 2. Run the following command from the ``docker`` directory.
#
# docker-compose up
# .. code:: bash
#
# cd docker
# docker-compose up -d %service_name%
#
# Optionally you can specify the '-d' flag for detaching mode (the container will run in the background).
# This docker-compose file contains three services:
#
# - ``mapdl``: Core service. It runs an MAPDL instance with the gRPC server activated, and it open the
# specified port to allow incoming connections to it.
# - ``dpf``: DPF service which can be used for data processing.
# - ``mapdl-local``: Use this service to start an ubuntu docker image with MAPDL installed in it.
# It is said to be running as 'local' because it will mount the parent directory (``../``) in '/home/mapdl/pymapdl'
# This service allow VS Code to attach to it and do development inside the container.
# and it will override the entrypoint to run the 'bash' command.
#
# NOTES:
# ======
# You can also specify multiple services:
#
# - 'AWP_ROOT222' is where Ansys is installed.
# - The entrypoint must be defined in the docker image.
# - If you want to mount the local directory, please add the 'volumes' section to the 'mapdl' service.
# .. code:: bash
#
# volumes:
# - ./:/local
# docker-compose up -d mapdl dpf
#
# Or use profiles:
#
#
# .. code:: bash
#
# docker-compose --profile dpf up -d
#
# The following profiles are are available:
#
# - ``mapdl`` - Equivalent to run ``docker-compose up -d mapdl``.
# - ``mapdl-dpf`` - Equivalent to run ``docker-compose up -d mapdl dpf``.
# - ``local`` - Equivalent to run ``docker-compose up -d mapdl-local``.
# - ``local-dpf`` - Equivalent to run ``docker-compose up -d mapdl-local dpf``.
# - ``dpf`` - Equivalent to run ``docker-compose up -d dpf``.
#
# Optionally, you can specify the '-d' flag for detached mode (the container will run in the background).
#
# NOTES
# =====
#
# - ``AWP_ROOT222`` is where Ansys 2022 R1 (v222) is installed.
#

services:
mapdl:
profiles:
- mapdl
- mapdl-dpf
restart: always
shm_size: '8gb'
container_name: mapdl
mem_reservation: 8g
environment:
- ANSYSLMD_LICENSE_FILE=${ANSYSLMD_LICENSE_FILE}
- ANSYS_LOCK=OFF
- AWP_ROOT222=/ansys_inc
- ${AWP_ROOT:-AWP_ROOT222}=${AWP_ROOT_VALUE:-/ansys_inc}
ports:
- '50052:50052'
- '50055:50055'
image: ${DOCKER_IMAGE}
user: "0:0"
entrypoint: "/bin/bash ansys -grpc"


dpf:
profiles:
- dpf
- mapdl-dpf
- local-dpf
image: ${DPF_DOCKER_IMAGE}
ports:
- '50056:50052'
restart: always
environment:
- ANSYSLMD_LICENSE_FILE=${ANSYSLMD_LICENSE_FILE}

mapdl-local:
profiles:
- local
- local-dpf
restart: always
shm_size: '8gb'
container_name: mapdl-local
mem_reservation: 8g
environment:
- ANSYSLMD_LICENSE_FILE=${ANSYSLMD_LICENSE_FILE}
- ANSYS_LOCK=OFF
- ${AWP_ROOT:-AWP_ROOT222}=${AWP_ROOT_VALUE:-/ansys_inc}
ports:
- '50052:50052'
- '50055:50055'
image: ${DOCKER_IMAGE}
volumes:
- ../:/home/${DOCKER_USER:-mapdl}/pymapdl:cached
working_dir: /home/${DOCKER_USER:-mapdl}/pymapdl
entrypoint: /bin/sh -c "echo 'Container is ready. You can now attach to it.'; while sleep 1000; do :; done"
Loading