Skip to content

Commit

Permalink
feat: Improve docker compose (all environments)
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Oct 10, 2024
1 parent 92a9310 commit 6f445ab
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 39 deletions.
1 change: 1 addition & 0 deletions .env.docker.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ MARIADB_USER=uvlhubdb_user
MARIADB_PASSWORD=uvlhubdb_password
MARIADB_ROOT_PASSWORD=uvlhubdb_root_password
WORKING_DIR=/app/
REDIS_URL=redis://redis:6379
1 change: 1 addition & 0 deletions .env.docker.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ MARIADB_PASSWORD=<CHANGE_THIS>
MARIADB_ROOT_PASSWORD=<CHANGE_THIS>
WEBHOOK_TOKEN=<CHANGE_THIS>
WORKING_DIR=/app/
REDIS_URL=redis://redis:6379
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ MARIADB_USER=uvlhubdb_user
MARIADB_PASSWORD=uvlhubdb_password
MARIADB_ROOT_PASSWORD=uvlhubdb_root_password
WORKING_DIR=""
REDIS_URL=redis://localhost:6379
1 change: 1 addition & 0 deletions .env.vagrant.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ MARIADB_USER=uvlhubdb_user
MARIADB_PASSWORD=uvlhubdb_password
MARIADB_ROOT_PASSWORD=uvlhubdb_root_password
WORKING_DIR=/vagrant/
REDIS_URL=redis://localhost:6379
2 changes: 1 addition & 1 deletion app/templates/base_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

<a href="/dataset/download/all" class="nav-link d-none d-sm-inline-block" style="border-radius: 5px;">
<i data-feather="download-cloud"></i>
Download all dataset
Get the entire collection!
</a>

<button onclick="goToMyCart()" class="nav-link d-none d-sm-inline-block" style="border-radius: 5px;">
Expand Down
16 changes: 16 additions & 0 deletions docker/docker-compose.prod.ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ services:
networks:
- uvlhub_network

worker:
container_name: rq_worker_container
env_file:
- ../.env
depends_on:
- redis
build:
context: ../
dockerfile: docker/images/Dockerfile.worker
volumes:
- ../app/:/app/app
- ../core/:/app/core
- ../uploads/:/app/uploads
networks:
- uvlhub_network

watchtower:
container_name: watchtower_container
image: containrrr/watchtower
Expand Down
16 changes: 16 additions & 0 deletions docker/docker-compose.prod.webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ services:
networks:
- uvlhub_network

worker:
container_name: rq_worker_container
env_file:
- ../.env
depends_on:
- redis
build:
context: ../
dockerfile: docker/images/Dockerfile.worker
volumes:
- ../app/:/app/app
- ../core/:/app/core
- ../uploads/:/app/uploads
networks:
- uvlhub_network

volumes:
db_data:

Expand Down
16 changes: 16 additions & 0 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ services:
networks:
- uvlhub_network

worker:
container_name: rq_worker_container
env_file:
- ../.env
depends_on:
- redis
build:
context: ../
dockerfile: docker/images/Dockerfile.worker
volumes:
- ../app/:/app/app
- ../core/:/app/core
- ../uploads/:/app/uploads
networks:
- uvlhub_network

watchtower:
container_name: watchtower_container
image: containrrr/watchtower
Expand Down
2 changes: 1 addition & 1 deletion docker/images/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ COPY --chmod=0755 scripts/init-testing-db.sh ./scripts/
COPY rosemary/ ./rosemary
COPY setup.py ./
COPY docker/ ./docker
COPY worker.py ./
COPY docker/redis/worker.py ./

# Create the .moduleignore file with the module 'webhook' inside
RUN echo "webhook" > /app/.moduleignore
Expand Down
22 changes: 22 additions & 0 deletions docker/redis/worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import logging
from rq import Worker, Queue, Connection
from dotenv import load_dotenv
from app import create_app

load_dotenv()
logger = logging.getLogger(__name__)


if __name__ == '__main__':

app = create_app()

with app.app_context():

# Connect to Redis and start listening to the queue
listen = ['default']
conn = app.config['SESSION_REDIS']

with Connection(conn):
worker = Worker(list(map(Queue, listen)))
worker.work()
37 changes: 0 additions & 37 deletions worker.py

This file was deleted.

0 comments on commit 6f445ab

Please sign in to comment.