Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
imshashank committed Nov 7, 2024
1 parent 82f85bb commit 8165622
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "magicapi-ai-gateway"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
description = "A high-performance AI Gateway proxy for routing requests to various AI providers, offering seamless integration and management of multiple AI services"
authors = ["MagicAPI Team <team@magicapi.com>"]
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Build stage
FROM rust:1.82-slim-bookworm as builder

# Install required dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Create a new empty shell project
WORKDIR /usr/src/app
COPY . .

# Build with release profile for maximum performance
RUN cargo build --release

# Runtime stage
FROM debian:bookworm-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*

# Copy the binary from builder
COPY --from=builder /usr/src/app/target/release/magicapi-ai-gateway /usr/local/bin/

# Set the startup command
CMD ["magicapi-ai-gateway"]
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,67 @@ This project is dual-licensed under both the MIT License and the Apache License
## Acknowledgments

Special thanks to all our contributors and the Rust community for making this project possible.

## Docker Support

### Building and Running with Docker

1. Build the Docker image:
```bash
docker build -t magicapi1/magicapi-ai-gateway:latest .
```

2. Run the container:
```bash
docker run -p 3000:3000 \
-e RUST_LOG=info \
magicapi1/magicapi-ai-gateway:latest
```

### Using Pre-built Docker Image

```bash
docker pull magicapi1/magicapi-ai-gateway:latest
docker run -p 3000:3000 \
-e RUST_LOG=info \
magicapi1/magicapi-ai-gateway:latest
```

### Docker Compose

#### Option 1: Build from Source

Create a `docker-compose.yml` file:

```yaml
version: '3.8'
services:
gateway:
build: .
ports:
- "3000:3000"
environment:
- RUST_LOG=info
restart: unless-stopped
```
#### Option 2: Use Prebuilt Image
Create a `docker-compose.yml` file:

```yaml
version: '3.8'
services:
gateway:
image: magicapi1/magicapi-ai-gateway:latest
ports:
- "3000:3000"
environment:
- RUST_LOG=info
restart: unless-stopped
```

Then run either option with:
```bash
docker-compose up -d
```

0 comments on commit 8165622

Please sign in to comment.