Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker-compose support #82

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
AGORA_APP_ID="<your_agora_appid>"
AGORA_APP_CERTIFICATE="<your_agora_app_certificate>"
AZURE_STT_KEY="<your_azure_stt_key>"
AZURE_STT_REGION="<your_azure_stt_region>"
OPENAI_API_KEY="<your_openai_api_key>"
AZURE_TTS_KEY="<your_azure_tts_key>"
AZURE_TTS_REGION="<your_azure_tts_region>"

ASTRA_AGENTS_SERVER_URL=http://localhost:8080
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
astra_agents_server:
image: agoraio/astra_agents_server:latest
build:
context: .
dockerfile: Dockerfile
container_name: astra_agents_server
restart: always
ports:
- "8080:8080"
volumes:
- /tmp:/tmp
environment:
AGORA_APP_ID: ${AGORA_APP_ID}
AGORA_APP_CERTIFICATE: ${AGORA_APP_CERTIFICATE}
AZURE_STT_KEY: ${AZURE_STT_KEY}
AZURE_STT_REGION: ${AZURE_STT_REGION}
OPENAI_API_KEY: ${OPENAI_API_KEY}
AZURE_TTS_KEY: ${AZURE_TTS_KEY}
AZURE_TTS_REGION: ${AZURE_TTS_REGION}
astra_playground:
image: agoraio/astra_playground:latest
build:
context: ./playground
dockerfile: Dockerfile
args:
NEXT_PUBLIC_REQUEST_URL: ${ASTRA_AGENTS_SERVER_URL}
container_name: astra_playground
restart: always
ports:
- "3000:3000"
volumes:
- /tmp:/tmp
9 changes: 9 additions & 0 deletions playground/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git

.env
2 changes: 0 additions & 2 deletions playground/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,3 @@ dist
# lock
package-lock.json
yarn.lock

Dockerfile
70 changes: 70 additions & 0 deletions playground/Dockerfile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use the following code:

FROM node:20-alpine AS base

FROM base AS builder

WORKDIR /app

COPY . .

RUN npm i && \
    npm run build


FROM base AS runner

WORKDIR /app

ENV NODE_ENV production

RUN mkdir .next

COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

EXPOSE 3000

CMD HOSTNAME="0.0.0.0" node server.js

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

ARG NEXT_PUBLIC_REQUEST_URL
ENV NEXT_PUBLIC_REQUEST_URL=${NEXT_PUBLIC_REQUEST_URL}

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

#COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js
1 change: 1 addition & 0 deletions playground/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nextConfig = {
// basePath: '/ai-agent',
// output: 'export',
output: 'standalone', // for docker build
reactStrictMode: false,
webpack(config) {
// Grab the existing rule that handles SVG imports
Expand Down