Commit
·
98bebe2
1
Parent(s):
55a0975
docker
Browse files- .dockerignore +60 -0
- Dockerfile +64 -0
.dockerignore
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Node modules (will be installed in container)
|
| 2 |
+
node_modules/
|
| 3 |
+
|
| 4 |
+
# Test files
|
| 5 |
+
tests/
|
| 6 |
+
*.test.ts
|
| 7 |
+
*.test.js
|
| 8 |
+
|
| 9 |
+
# Development files
|
| 10 |
+
.git/
|
| 11 |
+
.gitignore
|
| 12 |
+
*.md
|
| 13 |
+
README.md
|
| 14 |
+
TODO.md
|
| 15 |
+
|
| 16 |
+
# Development scripts
|
| 17 |
+
simple-duckai.js
|
| 18 |
+
|
| 19 |
+
# IDE and editor files
|
| 20 |
+
.vscode/
|
| 21 |
+
.idea/
|
| 22 |
+
*.swp
|
| 23 |
+
*.swo
|
| 24 |
+
*~
|
| 25 |
+
|
| 26 |
+
# OS generated files
|
| 27 |
+
.DS_Store
|
| 28 |
+
.DS_Store?
|
| 29 |
+
._*
|
| 30 |
+
.Spotlight-V100
|
| 31 |
+
.Trashes
|
| 32 |
+
ehthumbs.db
|
| 33 |
+
Thumbs.db
|
| 34 |
+
|
| 35 |
+
# Logs
|
| 36 |
+
logs/
|
| 37 |
+
*.log
|
| 38 |
+
npm-debug.log*
|
| 39 |
+
yarn-debug.log*
|
| 40 |
+
yarn-error.log*
|
| 41 |
+
|
| 42 |
+
# Runtime data
|
| 43 |
+
pids/
|
| 44 |
+
*.pid
|
| 45 |
+
*.seed
|
| 46 |
+
*.pid.lock
|
| 47 |
+
|
| 48 |
+
# Coverage directory used by tools like istanbul
|
| 49 |
+
coverage/
|
| 50 |
+
|
| 51 |
+
# Environment files
|
| 52 |
+
.env
|
| 53 |
+
.env.local
|
| 54 |
+
.env.development.local
|
| 55 |
+
.env.test.local
|
| 56 |
+
.env.production.local
|
| 57 |
+
|
| 58 |
+
# Build outputs
|
| 59 |
+
dist/
|
| 60 |
+
build/
|
Dockerfile
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Build stage - install dependencies and prepare source
|
| 2 |
+
FROM oven/bun:1.2.14-alpine AS build
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Copy package files
|
| 7 |
+
COPY package.json bun.lock* ./
|
| 8 |
+
|
| 9 |
+
# Install all dependencies
|
| 10 |
+
RUN bun install --frozen-lockfile
|
| 11 |
+
|
| 12 |
+
# Copy source code
|
| 13 |
+
COPY . ./
|
| 14 |
+
|
| 15 |
+
# Production stage - minimal Bun runtime
|
| 16 |
+
FROM oven/bun:1.2.14-alpine AS production
|
| 17 |
+
|
| 18 |
+
# Install essential runtime dependencies
|
| 19 |
+
RUN apk add --no-cache \
|
| 20 |
+
ca-certificates \
|
| 21 |
+
curl \
|
| 22 |
+
&& rm -rf /var/cache/apk/*
|
| 23 |
+
|
| 24 |
+
# The bun user already exists in the base image, so we'll use it
|
| 25 |
+
|
| 26 |
+
# Set working directory
|
| 27 |
+
WORKDIR /app
|
| 28 |
+
|
| 29 |
+
# Copy package files
|
| 30 |
+
COPY package.json bun.lock* ./
|
| 31 |
+
|
| 32 |
+
# Install only production dependencies
|
| 33 |
+
RUN bun install --frozen-lockfile --production && \
|
| 34 |
+
bun pm cache rm
|
| 35 |
+
|
| 36 |
+
# Copy source code from build stage
|
| 37 |
+
COPY --from=build --chown=bun:bun /app/src ./src
|
| 38 |
+
COPY --from=build --chown=bun:bun /app/tsconfig.json ./tsconfig.json
|
| 39 |
+
COPY --from=build --chown=bun:bun /app/bunfig.toml ./bunfig.toml
|
| 40 |
+
|
| 41 |
+
# Change ownership of the app directory to the bun user
|
| 42 |
+
RUN chown -R bun:bun /app
|
| 43 |
+
|
| 44 |
+
# Switch to non-root user
|
| 45 |
+
USER bun
|
| 46 |
+
|
| 47 |
+
# Expose the port the app runs on
|
| 48 |
+
EXPOSE 3000
|
| 49 |
+
|
| 50 |
+
# Set environment variables
|
| 51 |
+
ENV NODE_ENV=production
|
| 52 |
+
ENV PORT=3000
|
| 53 |
+
|
| 54 |
+
# Add labels for better container management
|
| 55 |
+
LABEL maintainer="Duck.ai OpenAI Server"
|
| 56 |
+
LABEL version="1.0.0"
|
| 57 |
+
LABEL description="OpenAI-compatible HTTP server using Duck.ai backend"
|
| 58 |
+
|
| 59 |
+
# Health check with proper endpoint
|
| 60 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
| 61 |
+
CMD curl -f http://localhost:3000/health || exit 1
|
| 62 |
+
|
| 63 |
+
# Start the application with Bun runtime
|
| 64 |
+
CMD ["bun", "run", "src/server.ts"]
|