Skip to content

Commit

Permalink
feat: celery & flower
Browse files Browse the repository at this point in the history
  • Loading branch information
vladyoslav committed Oct 29, 2024
1 parent 9670f16 commit 5d7716a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RABBITMQ_DEFAULT_PASSWORD=guest
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672

BACKEND_IMAGE=ghcr.io/desbordante/desbordante-server:main
BACKEND_IMAGE_TAG=88bde31
BACKEND_PORT=8000

UPLOADED_FILES_DIR_PATH=/uploads
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

# Environment
.env

# Volumes
volumes/*
!volumes/.gitkeep
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ env:
@echo >> .env
@echo "SECRET_KEY=$$(openssl rand -hex 32)" >> .env

## Create folders for volumes
volumes:
@for volume in postgres rabbitmq uploads; do \
mkdir -p ./volumes/$$volume; \
chmod 777 ./volumes/$$volume; \
done

## Initiate repository
init:
make env
make env volumes

## Pull docker containers
pull:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ make init
Update the secrets and variables in the organization settings on GitHub

Secrets:

- `SSH_HOST`
- `SSH_USERNAME`
- `SSH_PASSWORD`

Variables:

- `PROJECT_DIR` - Project directory on the server, example: `~/desbordante`

## Commands
Expand All @@ -27,3 +29,10 @@ Execute `make` to see all available rules with documentation
1. Pull containers: `make pull`
2. Start containers: `make up`
3. Pull & start (update): `make update`

## Accessing Services

After starting the containers, you can access the following services on `localhost`:

- **FastAPI documentation (Swagger UI):** [http://localhost:8000/docs](http://localhost:8000/docs)
- **Flower Celery monitoring panel:** [http://localhost:5555](http://localhost:5555)
44 changes: 31 additions & 13 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: desbordante

services:
postgres:
# container_name: ${COMPOSE_PROJECT_NAME}-postgres
image: postgres:16.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
Expand All @@ -16,15 +15,15 @@ services:
rabbitmq:
image: rabbitmq:3.12-management-alpine
volumes:
- rabbit_data:/var/lib/rabbitmq
- rabbitmq_data:/var/lib/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASSWORD}
ports:
- "${RABBITMQ_PORT}:5672"

backend:
image: ${BACKEND_IMAGE}
image: ghcr.io/desbordante/desbordante-server:${BACKEND_IMAGE_TAG}
volumes:
- ./volumes/uploads:${UPLOADED_FILES_DIR_PATH}
env_file:
Expand All @@ -35,16 +34,35 @@ services:
restart: always
ports:
- "${BACKEND_PORT}:8000"
deploy:
mode: replicated
replicas: 1
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:${BACKEND_PORT}/ping" ]
interval: 10s
timeout: 10s
retries: 3
start_period: 15s

celery:
image: ghcr.io/desbordante/desbordante-server:${BACKEND_IMAGE_TAG}
command: /celery
volumes:
- ./volumes/uploads:${UPLOADED_FILES_DIR_PATH}
env_file:
- .env
depends_on:
- rabbitmq
restart: always

flower:
image: ghcr.io/desbordante/desbordante-server:${BACKEND_IMAGE_TAG}
command: /flower
volumes:
- ./volumes/uploads:${UPLOADED_FILES_DIR_PATH}
env_file:
- .env
environment:
- FLOWER_USER=admin
- FLOWER_PASSWORD=admin
depends_on:
- rabbitmq
- celery
restart: always
ports:
- "5555:5555"

volumes:
postgres_data:
rabbit_data:
rabbitmq_data:
Empty file added volumes/.gitkeep
Empty file.

0 comments on commit 5d7716a

Please sign in to comment.