-
Notifications
You must be signed in to change notification settings - Fork 213
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
Can I deploy without using port 80 ? #1909
Comments
To deploy without using port 80 and resolve the issue where the front-end keeps requesting the port 80 interface, follow these steps:
Here is an example of how you can modify your services:
reverse-proxy:
image: traefik:v2.10
command: --api.insecure=true --providers.docker --entrypoints.web.address=:90
ports:
- "90:90"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- agenta-network
restart: always
backend:
build: ./agenta-backend
environment:
- MONGODB_URI=mongodb://username:password@mongo:27017
- REDIS_URL=redis://redis:6379/0
- ALLOW_ORIGINS=${ALLOW_ORIGINS}
- ENVIRONMENT=production
- FEATURE_FLAG=oss
- AGENTA_TEMPLATE_REPO=agentaai/templates_v2
- CELERY_BROKER_URL=amqp://guest@rabbitmq//
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/tests:/app/tests
- /var/run/docker.sock:/var/run/docker.sock
- ./agenta-backend/db:/db
labels:
- "traefik.http.routers.backend.rule=Host(`${BARE_DOMAIN_NAME}`) && PathPrefix(`/api/`)"
- "traefik.http.routers.backend.entrypoints=web"
- "traefik.http.middlewares.backend-strip.stripprefix.prefixes=/api"
- "traefik.http.middlewares.backend-strip.stripprefix.forceslash=true"
- "traefik.http.routers.backend.middlewares=backend-strip"
- "traefik.http.services.backend.loadbalancer.server.port=8881"
- "traefik.http.routers.backend.service=backend"
networks:
- agenta-network
extra_hosts:
- "host.docker.internal:host-gateway"
command:
[
"uvicorn",
"agenta_backend.main:app",
"--host",
"0.0.0.0",
"--port",
"8881",
"--reload",
"--root-path",
"/api"
]
env_file:
- .env
depends_on:
mongo:
condition: service_healthy
restart: always
agenta-web:
build:
context: ./agenta-web
dockerfile: prod.Dockerfile
volumes:
- ./agenta-web/src:/app/src
- ./agenta-web/public:/app/public
ports:
- "3001:3000"
networks:
- agenta-network
labels:
- "traefik.http.routers.agenta-web.rule=Host(`${BARE_DOMAIN_NAME}`) && PathPrefix(`/`)"
- "traefik.http.routers.agenta-web.entrypoints=web"
- "traefik.http.services.agenta-web.loadbalancer.server.port=3000"
environment:
- NEXT_PUBLIC_POSTHOG_API_KEY=phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7
restart: always Additionally, ensure that your NEXT_PUBLIC_AGENTA_API_URL=http://localhost:90/api
NEXT_PUBLIC_FF=oss
NEXT_PUBLIC_TELEMETRY_TRACKING_ENABLED=true Make sure the |
The agenta web I executed in this way is in development mode. How can I change it to online mode |
To change your Agenta web application from development mode to production mode, follow these steps:
Additionally, ensure that your Dockerfile is optimized for production. Here is an example of a production Dockerfile: # Stage 1: Build Stage
FROM node:22-alpine3.18 AS builder
WORKDIR /app
# Install only production dependencies
COPY package.json package-lock.json* ./
RUN npm ci
# Copy only necessary files
COPY src ./src
COPY public ./public
COPY next.config.js .
COPY tsconfig.json .
COPY postcss.config.js .
COPY tailwind.config.ts .
COPY .env.production .
COPY sentry.* .
# Build the Next.js app for production
RUN npm run build
# Stage 2: Production Stage
FROM node:22-alpine3.18 AS prod
WORKDIR /app
# Copy only the necessary files from the build stage
COPY --from=builder /app/package.json /app/package-lock.json* /app
COPY --from=builder /app/.next /app/.next
COPY --from=builder /app/public /app/public
COPY --from=builder /app/next.config.js /app/tsconfig.json /app/postcss.config.js /app/tailwind.config.ts /app/.env.production /app/sentry.* /app/
# Install only production dependencies
RUN npm ci --omit=dev
# Expose the necessary port
EXPOSE 3000
# Start the production server
CMD ["npm", "start"] By following these steps and using the |
It looks like App code needs to be fixed to fetch those via server side props or inlining them during the SSR pipeline Edit
agenta-web:
image: ghcr.io/agenta-ai/agenta-web
command: npm run dev However, served app does seem to have issues: Edit 2 - styling
Both files override image contents as mounted volumes: volumes:
- ./agenta/tailwind.config.ts:/app/tailwind.config.ts
- ./agenta/antd-themeConfig.json:/app/src/styles/tokens/antd-themeConfig.json The app finally matches cloud version after that: Edit 3I'm not sure how this line is supposed to work at all: If that code is in prod - it shouldn't be possible to create new apps. Edit 4You can't Docker networks with name different from |
@av Thanks for all the comments. Unfortunately I missed the notification the first time, then since you were making edits I did not get any notification. Port issue:I am looking into this now. We'll have a PR ready soon. Inter issue:Thanks for noticing this, that has been fixed How does this code work in prodThanks for noticing this. It works because the logging level is set to error and thereby the command is not executed. I am creating a fix now. Docker network issueYes that is a limitation, not sure what is the use case of having a different network name? |
Discussed in #1907
Originally posted by lsm1103 July 18, 2024
When I try to deploy without using port 80, the front-end keeps requesting the port 80 interface;
When I changed the environment variables for frontend deployment to the backend ports;
(I changed it to nginx deployment here)
Still unable to access, the front-end keeps requesting the interface of port 80;
Is it like this that x modification doesn't work?
The text was updated successfully, but these errors were encountered: