Local Development with Docker

This guide covers how to set up and run the CodeNull AI Backend locally using Docker for development and testing.

Building the Docker Image

To create a Docker image from your CodeNull AI Backend source code:

docker build --tag codenull-ai-backend .

This command builds a Docker image with the tag codenull-ai-backend using the Dockerfile in the current directory.

Running the Container Locally

Once you’ve built the image, you can run it as a container:

docker run -d --name codenull-ai-backend -p 8000:8000 codenull-ai-backend

This command:

  • Creates a container named codenull-ai-backend
  • Maps port 8000 on your host to port 8000 in the container
  • Runs the container in detached mode (-d)

After running this command, your application will be accessible at http://localhost:8000.

Checking Container Status

To verify that your container is running:

docker ps

This command lists all running containers. Look for codenull-ai-backend in the list.

Viewing Container Logs

To see the logs from your container:

docker logs codenull-ai-backend

Add the -f flag to follow the logs in real-time:

docker logs -f codenull-ai-backend

Stopping the Container

When you’re done, you can stop the container:

docker stop codenull-ai-backend

And remove it:

docker rm codenull-ai-backend

Accessing the API

With the container running, you can access:

Next Steps

After successfully running the application locally: