Skip to content

For production


Production ready Dockerfile

The following Dockerfile contains the minimum configuration settings for you to deploy your application to production.

This template assumes that you provide a requirements.txt file with all the Python dependencies of your application.

Make sure you update the Docker command CMD with the appropriate file name and Flask settings for your application as describe in Running a Taipy application.

# Your Python version
FROM python:3.9 as taipy

# Web port of the application

# Create taipy user for security
RUN groupadd -r taipy && useradd -r -m -g taipy taipy
USER taipy

# Go to the dedicated folder and add the python corresponding folder in PATH
WORKDIR /home/taipy
ENV PATH="${PATH}:/home/taipy/.local/bin"

# Update pip and install Gunicorn with a suitable worker
RUN python -m pip install --upgrade pip
RUN python -m pip install gunicorn gevent-websocket

# Install your application
COPY . .
RUN python -m pip install -r requirements.txt

# Start up command
ENTRYPOINT [ "gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-w", "1", "--bind=", "--timeout", "1800" ]
CMD [ "<main>:<app>" ]


If you are using a SQL database based on Microsoft SQL Server, you need to add the following commands before creating the user:

RUN apt-get update && apt-get install -y lsb-release && apt-get clean all
RUN curl | apt-key add -
RUN curl$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt update && ACCEPT_EULA=Y apt install -y msodbcsql18 unixodbc-dev

Production ready Docker Compose

It is not recommended to expose Gunicorn to the Internet. It is better to let Nginx handle this responsibility.

Beside your docker-compose.yaml, create a file named nginx.conf with the following content.

Then, update your docker-compose.yaml:

version: "3.9"
    build: ""
    image: nginx:1.23
       - "5000:80"
      - ./nginx.conf:/etc/nginx/nginx.conf