Skip to content

Commit a0ba3c6

Browse files
committed
wip
1 parent 3f5751b commit a0ba3c6

File tree

4 files changed

+10
-35
lines changed

4 files changed

+10
-35
lines changed

.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Server Configuration
2-
PORT=3000
32
NODE_ENV=development
43

54
# Logging
@@ -15,4 +14,4 @@ JWT_SECRET=your-secret-key-here
1514
JWT_EXPIRATION=7d
1615

1716
# OpenAI Configuration
18-
OPENAI_API_KEY=your-openai-api-key-here
17+
OPENAI_API_KEY=your-openai-api-key-here

Dockerfile

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,44 @@
1-
# Multi-stage build for optimal image size
21
FROM node:20-alpine AS builder
32

4-
# Set working directory
53
WORKDIR /app
64

7-
# Enable Corepack for Yarn 4
85
RUN corepack enable
96

10-
# Copy package files and Yarn configuration
117
COPY package.json yarn.lock .yarnrc.yml ./
128

13-
# Install dependencies
149
RUN yarn install --immutable
1510

16-
# Copy source code
1711
COPY src ./src
1812
COPY tsconfig.json ./
1913

20-
# Build TypeScript
2114
RUN yarn build
2215

23-
# Final stage
2416
FROM node:20-alpine
2517

26-
# Set environment variables
27-
ENV NODE_ENV=production \
28-
PORT=3000
18+
ENV NODE_ENV=production
2919

30-
# Create app directory and set permissions for node user
3120
RUN mkdir -p /app && \
3221
chown -R node:node /app
3322

34-
# Set working directory
3523
WORKDIR /app
3624

37-
# Enable Corepack for Yarn 4
3825
RUN corepack enable
3926

40-
# Copy package files and Yarn configuration
4127
COPY package.json yarn.lock .yarnrc.yml ./
4228

43-
# Install production dependencies only
4429
RUN yarn workspaces focus --all --production && \
4530
yarn cache clean --all
4631

47-
# Copy built application from builder
4832
COPY --from=builder --chown=node:node /app/dist ./dist
4933

50-
# Copy examples directory for configs
5134
COPY --chown=node:node examples ./examples
5235

53-
# Switch to non-root user
5436
USER node
5537

56-
# Create directories for configs and logs
5738
RUN mkdir -p /app/logs /app/configs
5839

59-
# Expose default port
60-
EXPOSE 3000
61-
62-
# Health check
6340
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
6441
CMD node -e "require('http').get('http://localhost:${PORT}/health', (r) => { process.exit(r.statusCode === 200 ? 0 : 1); }).on('error', () => process.exit(1));"
6542

66-
# Default command - can be overridden
6743
ENTRYPOINT ["node", "dist/index.js"]
6844
CMD ["--config=/app/configs/simulation.json", "--simulation-name=summer_vacation"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Multi-agent AI simulation runtime engine powered by TypeScript, BullMQ, and OpenAI
44
5-
[![Tests](https://github.com/margostino/autobox/actions/workflows/engine-ts-tests.yml/badge.svg?branch=main)](https://github.com/margostino/autobox/actions/workflows/engine-ts-tests.yml)
5+
[![Tests](https://github.com/margostino/autobox-engine-ts/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/margostino/autobox-engine-ts/actions/workflows/tests.yml)
66
[![codecov](https://codecov.io/gh/margostino/autobox/branch/main/graph/badge.svg?flag=autobox-engine-ts)](https://codecov.io/gh/margostino/autobox)
77
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
88
[![Node.js](https://img.shields.io/badge/Node.js-18+-green.svg)](https://nodejs.org/)

bin/docker-run

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -e
44

5-
# Check if OPENAI_API_KEY is set
65
if [ -z "$OPENAI_API_KEY" ]; then
76
echo "Error: OPENAI_API_KEY environment variable is not set"
87
echo "Please export OPENAI_API_KEY=<your-api-key>"
@@ -50,7 +49,7 @@ while [[ $# -gt 0 ]]; do
5049
echo " -s, --simulation-name NAME Simulation name (default: summer_vacation)"
5150
echo " -d, --daemon Keep server alive after simulation (default: false)"
5251
echo " -t, --tag TAG Docker image tag (default: latest)"
53-
echo " -p, --host-port PORT Host port to bind (default: auto-detect from PORT env or 3000)"
52+
echo " -p, --host-port PORT Host port to bind (default: auto-detect from server.json)"
5453
echo " --redis-host HOST Redis host (default: host.docker.internal)"
5554
echo " --redis-port PORT Redis port (default: 6379)"
5655
echo " -h, --help Show this help message"
@@ -63,10 +62,13 @@ while [[ $# -gt 0 ]]; do
6362
esac
6463
done
6564

66-
# Use PORT from environment or default to 3000
67-
SERVER_PORT="${PORT:-3000}"
65+
SERVER_CONFIG="examples/server/server.json"
66+
SERVER_PORT=$(grep -o '"port":[[:space:]]*[0-9]*' "$SERVER_CONFIG" | grep -o '[0-9]*$')
67+
if [ -z "$SERVER_PORT" ]; then
68+
echo "Warning: Could not determine port from server config, using default 9000"
69+
SERVER_PORT=9000
70+
fi
6871

69-
# Function to find a free port
7072
find_free_port() {
7173
local start_port=$1
7274
local port=$start_port
@@ -112,14 +114,12 @@ else
112114
echo "Host port: Docker will assign a random available port"
113115
fi
114116

115-
# Prepare port arguments
116117
if [ -n "$HOST_PORT" ]; then
117118
PORT_ARGS=(-p "$HOST_PORT:$SERVER_PORT")
118119
else
119120
PORT_ARGS=(-P)
120121
fi
121122

122-
# Run container
123123
docker run \
124124
--rm \
125125
-it \

0 commit comments

Comments
 (0)