Deployment Overview of gpt-oss-20b on Server¶
Prerequisites and Basic Requirements¶
The deployment requires a server running the Ubuntu operating system. The following conditions must be met before proceeding:
- Root privileges or
sudoaccess are required to install system packages, manage services, and configure Docker. - Docker Engine must be installed and running on the server to host the application containers.
- The server must have access to the internet to download the Ollama installer, the
gpt-oss:20bmodel, and Docker images. - Port
8080must be available for the Open WebUI application. - Port
11434is used internally by the Ollama service. - Ports
80and443are required for the Nginx proxy and SSL certificate management via Certbot.
File and Directory Structure¶
The application utilizes the following directory structure for configuration, data, and certificates:
/root/nginx: Contains the Docker Compose configuration for the Nginx proxy and Certbot./root/nginx/compose.yml: The Docker Compose file defining the Nginx service./data/nginx/nginx-certbot.env: Environment file containing configuration for the Nginx-Certbot container./data/nginx/user_conf.d: Directory storing custom Nginx configuration files for specific host keys./etc/systemd/system/ollama.service: Systemd unit file for the Ollama service./usr/share/ollama/.ollama/models: Default storage location for the downloadedgpt-oss:20bmodel./var/lib/docker/volumes/open-webui: Docker volume storing persistent data for the Open WebUI application.
Application Installation Process¶
The deployment involves installing the Ollama inference engine, pulling the specific model, and launching the Open WebUI interface via Docker.
- Install Ollama: The Ollama package is installed using the official installation script.
- Create System User: A system user named
ollamais created to run the service. - Configure Ollama Service: The
ollama.servicefile is updated to expose the service on all network interfaces and enable specific environment variables:OLLAMA_HOST=0.0.0.0OLLAMA_ORIGINS=*LLAMA_FLASH_ATTENTION=1
- Pull Model: The
gpt-oss:20bmodel is downloaded and stored in the default Ollama model directory. - Launch Open WebUI: The Open WebUI container is started with GPU acceleration enabled, connecting to the local Ollama instance.
Docker Containers and Their Deployment¶
Two primary Docker containers are deployed: one for the Open WebUI application and one for the Nginx proxy with Certbot.
Open WebUI Container¶
The Open WebUI container is launched using the following command parameters:
- Image:
ghcr.io/open-webui/open-webui:cuda - Container Name:
open-webui - Ports: Maps host port
8080to container port8080. - GPU Access: The
--gpus allflag is used to enable GPU acceleration. - Host Resolution: The
--add-host=host.docker.internal:host-gatewayflag allows the container to reach the host machine. - Volumes: A named volume
open-webuiis mounted to/app/backend/datafor data persistence. - Environment Variables:
ENV=devOLLAMA_BASE_URLS=http://host.docker.internal:11434
- Restart Policy: Set to
alwaysto ensure the container restarts automatically.
Nginx and Certbot Container¶
The Nginx proxy and SSL certificate management are handled by a container defined in a Docker Compose file located at /root/nginx/compose.yml.
- Image:
jonasal/nginx-certbot:latest - Restart Policy:
unless-stopped - Network Mode:
host - Volumes:
nginx_secrets(external) mounted to/etc/letsencryptfor SSL certificates./data/nginx/user_conf.dmounted to/etc/nginx/user_conf.dfor custom configurations.
- Environment:
[email protected]- Configuration loaded from
/data/nginx/nginx-certbot.env.
Proxy Servers¶
The Nginx proxy is configured to handle incoming traffic and manage SSL certificates using Certbot.
- Configuration Location: Custom Nginx configurations are stored in
/data/nginx/user_conf.d. - Proxy Pass: The proxy is configured to forward requests to the Open WebUI application running on the host.
- Target:
http://127.0.0.1:8080
- Target:
- SSL Management: The
nginx-certbotcontainer automatically handles the generation and renewal of SSL certificates. - Deployment: The proxy stack is started using the Docker Compose command within the
/root/nginxdirectory.
Access Rights and Security¶
Security and access control are managed through the following mechanisms:
- Ollama Service: The Ollama service runs under the dedicated
ollamasystem user. - Firewall: The deployment assumes that the firewall allows traffic on ports
80,443, and8080. - Nginx Configuration: The Nginx configuration files in
/data/nginx/user_conf.dare owned byrootwith permissions set to0644. - Directory Permissions: The
/root/nginxdirectory is owned byrootwith permissions0755. - CORS: The Ollama service is configured with
OLLAMA_ORIGINS=*to allow cross-origin requests from the web interface.
Starting, Stopping, and Updating¶
The services are managed using systemd for Ollama and docker compose for the Nginx proxy.
Ollama Service¶
- Restart Service:
- Enable Service on Boot:
- Reload Daemon: Required after modifying the service file.
Nginx Proxy¶
- Start/Update: Navigate to the configuration directory and run the compose command.
- Stop:
Open WebUI Container¶
- Start: The container is started via the
docker runcommand. If the container is already running, the command will indicate that the port is in use. - Stop:
- Remove: