Getting Started
Prepare your application for deployment
mkdir ~/my-first-dstack-app cd ~/my-first-dstack-app
# app.py from flask import Flask, jsonify import os import socket app = Flask(__name__) @app.route('/') def hello(): return jsonify({ 'message': 'Hello from dstack! 🔒', 'secure': 'Running in a Trusted Execution Environment', 'hostname': socket.gethostname(), 'environment': os.environ.get('DSTACK_ENV', 'production') }) @app.route('/health') def health(): return jsonify({'status': 'healthy'}), 200 if __name__ == '__main__': app.run(host='0.0.0.0', port=8080)
# requirements.txt flask==3.0.0 gunicorn==21.2.0
# Dockerfile FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY app.py . EXPOSE 8080 CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "2", "app:app"]