Update Docker configurations for backend and frontend services to include ENV_MODE variable

This commit is contained in:
Korzhavin Ivan 2025-04-24 22:38:10 +02:00
parent 0a97b43beb
commit a1c0d5f5da
5 changed files with 106 additions and 3 deletions

39
.github/workflows/docker-build.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Build and Push Docker Images
on:
push:
branches: [ main ]
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Backend image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/suna-backend:latest
- name: Build and push Frontend image
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/suna-frontend:latest

View File

@ -1,13 +1,14 @@
FROM python:3.11-slim
WORKDIR /app
RUN pip install --no-cache-dir gunicorn
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir gunicorn
# Copy the .env file first
COPY .env .
# COPY .env . # ATTENTION. We shouldn't copy secrets to the image
# Copy the backend code
COPY . .
@ -15,10 +16,11 @@ COPY . .
# Set environment variable
ENV PYTHONPATH=/app
ENV ENV_MODE="production"
# Expose the port the app runs on
EXPOSE 8000
# 24 workers
CMD ["gunicorn", "api:app", "--workers", "24", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "--timeout", "600", "--graceful-timeout", "300", "--keep-alive", "250", "--max-requests", "0", "--max-requests-jitter", "0", "--forwarded-allow-ips", "*", "--worker-connections", "5000", "--worker-tmp-dir", "/dev/shm", "--preload"]
CMD ["gunicorn", "api:app", "--workers", "24", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "--timeout", "600", "--graceful-timeout", "300", "--keep-alive", "250", "--max-requests", "0", "--max-requests-jitter", "0", "--forwarded-allow-ips", "*", "--worker-connections", "5000", "--worker-tmp-dir", "/dev/shm", "--preload"]

22
docker-compose.ghcr.yaml Normal file
View File

@ -0,0 +1,22 @@
version: '3.8'
services:
backend:
image: ghcr.io/${GITHUB_REPOSITORY}/suna-backend:latest
ports:
- "8000:8000"
volumes:
- ./backend/.env:/app/.env:ro
environment:
- ENV_MODE=local
frontend:
image: ghcr.io/${GITHUB_REPOSITORY}/suna-frontend:latest
ports:
- "3000:3000"
volumes:
- ./frontend/.env.local:/app/.env.local:ro
environment:
- NODE_ENV=development
depends_on:
- backend

26
docker-compose.yaml Normal file
View File

@ -0,0 +1,26 @@
version: '3.8'
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "8000:8000"
volumes:
- ./backend/.env:/app/.env:ro
environment:
- ENV_MODE=local
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ./frontend/.env.local:/app/.env.local:ro
environment:
- NODE_ENV=development
depends_on:
- backend

14
frontend/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM node:20-slim
WORKDIR /app
# Copy package files first for better layer caching
COPY package*.json ./
RUN npm install
# Copy the frontend code
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev"]