Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make local dev work #523

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crm/celery.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals

import os
import django.conf as conf

from celery import Celery

Expand All @@ -18,4 +19,4 @@
app.config_from_object("django.conf:settings", namespace="CELERY")

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
app.autodiscover_tasks(lambda: conf.settings.INSTALLED_APPS)
11 changes: 11 additions & 0 deletions docker/celery.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM common-bottle-dockerfile

# Intall dependencies
COPY requirements.txt /app

RUN python3 -m pip install --no-cache-dir -r requirements.txt

COPY . /app

ENTRYPOINT ["celery", "-A", "crm", "worker"]
CMD ["--loglevel=INFO"]
12 changes: 12 additions & 0 deletions docker/common.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ARG PIP_EXTRA_INDEX_URL

WORKDIR /app

RUN apt-get update -y
RUN apt install -y git ruby-dev ruby-ffi redis-server wkhtmltopdf
RUN apt clean
RUN apt install -y python3-pip
RUN python3 -m pip install --no-cache-dir redis
46 changes: 38 additions & 8 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,65 @@
version: '3'
services:
celery:
image: celery-bottlecrm-broker
build:
context: ..
dockerfile: docker/celery.dockerfile
container_name: celery-bottlecrm
depends_on:
- crm-app
- redis
networks:
- custom_network

crm-app:
image: djcrm:1
build:
context: ..
dockerfile: docker/dockerfile
container_name: crm-app
environment:
- DBNAME=crm
- DBUSER=crm
- DBPASSWORD=crm
- DBHOST=crm-db
- DBPORT=5432

depends_on:
- crm-db
- redis
ports:
- "8000:8000"
networks:
- custom_network

redis:
image: redis:latest
container_name: redis-bottlecrm
ports:
- 8000:8000
- "6379:6379"
networks:
- nw
- custom_network

crm-db:
image: postgres:latest
container_name: crm-db
volumes:
- /var/lib/containers/storage/volumes/bottlecrm/_data:/var/lib/postgresql/data/pgdata
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is left as a reference only to providing volume that i created using podman for local mount which ofcourse could be modified to a more standard mount point.

environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- PGHOST=localhost
- PGPORT=5432
- POSTGRES_DB=crm
- PGDATABASE=crm
- POSTGRES_USER=crm
- PGUSER=crm
- POSTGRES_PASSWORD=crm
ports:
- 5432:5432
volumes:
- /var/run/postgresql/:/var/run/postgresql
- "5432:5432"
networks:
- nw
- custom_network

networks:
nw: {}
custom_network:
driver: bridge

23 changes: 7 additions & 16 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
FROM ubuntu:22.04
FROM common-bottle-dockerfile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure to build this image first

docker build -t common-bottle-dockerfile docker/dockerfile

ARG DEBIAN_FRONTEND=noninteractive
ARG PIP_EXTRA_INDEX_URL

WORKDIR /app

# Intall dependencies
COPY requirements.txt /app

RUN apt update
RUN apt install -y git ruby-dev ruby-ffi postgresql-client redis-server wkhtmltopdf
RUN apt clean
RUN gem install sass
RUN gem install compass
# install nvm/npm
# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
RUN apt install nodejs npm -y
RUN npm -g install less
RUN apt install -y python3-pip
RUN python3 -m pip install --no-cache-dir -r requirements.txt
RUN python3 -m pip install --no-cache-dir redis

RUN apt install -y postgresql-client

# Install dependencies
COPY requirements.txt /app

RUN python3 -m pip install --no-cache-dir -r requirements.txt
COPY . /app
COPY docker/entrypoint.sh /app
COPY docker/wait-for-postgres.sh /app


RUN chmod +x entrypoint.sh
RUN chmod +x wait-for-postgres.sh
ENTRYPOINT ["./entrypoint.sh"]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ django_storages==1.13.2
drf-rw-serializers==1.0.5
django-crum==0.7.9
Redis==4.6.0
SQLAlchemy==2.0.28
# remove it
django-phonenumber-field==7.1.0
arrow==1.2.3
Expand Down
Loading