New API Docker Compose Setup
New API Docker Compose Setup
This note records a minimal New API deployment with Docker Compose.
Example values:
- public domain:
newapi.example.com - public HTTPS port:
8445 - container app port:
3000 - repo:
https://github.com/QuantumNous/new-api.git
The domain and port are examples. Replace them with your own values.
Install Docker
If Docker is not installed yet:
1 | curl -fsSL https://get.docker.com -o get-docker.sh |
Check it:
1 | docker version |
Clone
1 | git clone https://github.com/QuantumNous/new-api.git |
Review the compose file before starting it:
1 | vim docker-compose.yml |
For a reverse-proxy setup, bind the app to localhost if the compose file allows it:
1 | ports: |
If the upstream compose file also starts MySQL and Redis, keep their ports internal unless you have a reason to expose them.
Start
1 | docker compose up -d |
Check status:
1 | docker compose ps |
For first-time initialization, open the web page and follow the setup wizard:
1 | https://newapi.example.com:8445 |
If you test without Caddy first, use:
1 | http://198.51.100.20:3000 |
198.51.100.20 is a documentation IP address.
Caddy Reverse Proxy
Caddy config:
1 | newapi.example.com:8445 { |
Reload Caddy:
1 | sudo caddy validate --config /etc/caddy/Caddyfile |
Open the firewall port if needed:
1 | sudo nft add rule inet filter input tcp dport 8445 accept |
Update
1 | cd /opt/new-api |
If you modified tracked files directly and git pull
complains, either move local changes into override files or clean the
tree intentionally. Do not blindly reset --hard unless you
know what you are throwing away.
Logs
1 | # all services |