diff --git a/.env.example b/.env.example index f952e87..73a11cd 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/.gitignore b/.gitignore index e83f7c7..df994b4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ # Environment .env + +# Volumes +volumes/* +!volumes/.gitkeep diff --git a/Makefile b/Makefile index 583c40f..e8c4570 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/README.md b/README.md index db58452..5868c6d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) diff --git a/docker-compose.yaml b/docker-compose.yaml index 732f5d8..00b84fb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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 @@ -16,7 +15,7 @@ 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} @@ -24,7 +23,7 @@ services: - "${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: @@ -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: \ No newline at end of file + rabbitmq_data: diff --git a/volumes/.gitkeep b/volumes/.gitkeep new file mode 100644 index 0000000..e69de29