Skip to content

Commit

Permalink
Merge pull request #61 from mantiumai/AlexN/redis-stack
Browse files Browse the repository at this point in the history
Install redis-stack for vss
  • Loading branch information
alex-nork authored Jul 13, 2023
2 parents dc69541 + 828fa88 commit 114313c
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 35 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile.celery
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Dockerfile.celery
FROM mcr.microsoft.com/devcontainers/python:0-3.11

# Install Celery and any other dependencies
RUN pip install --no-cache-dir celery

# Set the command for the Celery worker
CMD ["celery", "-A", "chirps", "worker", "--loglevel=info"]
45 changes: 13 additions & 32 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"features": {
"ghcr.io/devcontainers-contrib/features/rabbitmq-asdf:1": {
"version": "latest",
"erlangVersion": "latest"
},
"ghcr.io/devcontainers-contrib/features/redis-homebrew:1": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/vault-asdf:2": {
"version": "latest"
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"name": "Python 3",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
"features": {
"ghcr.io/devcontainers-contrib/features/rabbitmq-asdf:1": {},
"ghcr.io/devcontainers-contrib/features/vault-asdf:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"forwardPorts": [4369, 5672, 6379, 8000],
"postCreateCommand": "docker-compose up -d",
"runServices": ["redis", "celery", "rabbitmq", "vault"]
}
64 changes: 64 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: '3.8'

services:
app:
image: mcr.microsoft.com/devcontainers/python:0-3.11
volumes:
- ..:/workspace:cached
command: sleep infinity
depends_on:
- redis
- celery
- rabbitmq
- vault
networks:
default:
aliases:
- localhost

celery:
build:
context: .
dockerfile: Dockerfile.celery
volumes:
- .:/workspace:cached
depends_on:
- rabbitmq
networks:
default:
aliases:
- localhost

redis:
image: redis/redis-stack:latest
ports:
- 6379:6379
networks:
default:
aliases:
- localhost

rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
- 15672:15672
networks:
default:
aliases:
- localhost

vault:
image: hashicorp/vault:latest
ports:
- 8200:8200
environment:
VAULT_DEV_ROOT_TOKEN_ID: myroot
VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200
networks:
default:
aliases:
- localhost

networks:
default:
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.11

RUN apt-get update && \
apt-get install -y git docker.io docker-compose

WORKDIR /app
COPY ../requirements.txt /app/
RUN pip install -r requirements.txt

COPY . /app
6 changes: 3 additions & 3 deletions chirps/base_app/management/commands/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def add_arguments(self, parser):
def handle(self, *args, **options):
"""Handle redis command"""
if options['start']:
os.system('redis-server --daemonize yes')
os.system('docker-compose -f /workspace/.devcontainer/docker-compose.yml up -d redis')
elif options['stop']:
os.system('redis-cli shutdown')
os.system('docker-compose -f /workspace/.devcontainer/docker-compose.yml down')
elif options['status']:
os.system('redis-cli ping')
os.system('docker-compose -f /workspace/.devcontainer/docker-compose.yml ps')

0 comments on commit 114313c

Please sign in to comment.