deploy AI server to AWS
overview
building the ai speech server was only half the job so i pushed the fastapi service onto AWS EC2 and wired a github based delivery pipeline to keep deployments hands off
background
- requests
- players talk to the golem npc through voice inside the local build so the fastapi speech api must live on a remote endpoint
- the previous local setup has to stay reachable from anywhere
- priorities
- host the fastapi service on the remote node
- prepare the AWS EC2 environment
- add a github deploy workflow
- lower priority
- harden secrets with .env files kept outside docker images
- stop exposing the EC2 ssh port to every ip
purpose
make the speech to text server land on the AWS instance automatically with zero manual patching
environment setup
- dependency stack managed with uv and pyproject.toml
- server docs endpoint: http://44.210.134.73:8000/docs
- websocket endpoint: ws://44.210.134.73:8000/api/v1/ws/speech/v1
implementation
ec2 instance
Image hidden for security reasons
design
- added a github action near the repo root
1
2
3
.github/
└── workflows/
└── deploy.yml
- deployment workflow reference
https://github.com/ob1hnk/Triolingo/blob/main/.github/workflows/deploy.yml
result
- accessing the instance through the pem key shows the container running
1
2
3
ubuntu@ip-*:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9b20bf338df7 ghcr.io/ob1hnk/triolingo/gogo-golem-ai:main-fec67ba "uv run uvicorn..." 14 hours ago Up 14 hours 0.0.0.0:8000->8000/tcp [::]:8000->8000/tcp gogo-golem-ai-server
- confirmed the websocket api responds end to end
pr
https://github.com/ob1hnk/Triolingo/pull/2
troubleshooting
issue 1
docker refused any uppercase letters in the image tag even though IMG_NAME was lowercase the whole time in the workflow reruns the old commit kept executing because rerun failed job sticks to its original sha this made the fix look ineffective check the screenshot log for proof

issue 2
after editing cached image names the pushed tag and the pulled tag no longer matched so ec2 tried to fetch an image that did not exist i standardized everything to main-{short_sha} with seven characters to kill the mismatch
reference commit: https://github.com/ob1hnk/Triolingo/commit/f3edcc47965ff26b92be86c143f645b9e842dd4c
