Skip to content

Instantly share code, notes, and snippets.

View gagansh7171's full-sized avatar
🎯
Focusing

Gagan Sharma gagansh7171

🎯
Focusing
View GitHub Profile
@gagansh7171
gagansh7171 / check_db.py
Created August 23, 2020 18:59
Check DB before manage.py
import socket
import time
import argparse
""" Check if port is open, avoid docker-compose race condition """
parser = argparse.ArgumentParser(description='Check if port is open, avoid\
docker-compose race condition')
parser.add_argument('--service-name', required=True)
parser.add_argument('--ip', required=True)
parser.add_argument('--port', required=True)
@gagansh7171
gagansh7171 / redis.py
Created August 23, 2020 18:47
Settings Redis
CHANNEL_LAYERS = {
'default' : {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG' : {
"hosts" : [('redis', 6379)], # You are supposed to use service name and not localhost
},
},
}
@gagansh7171
gagansh7171 / database.py
Last active August 23, 2020 18:46
Settings Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'bug',
'USER': config('DB_USER'),
'PASSWORD': config('DBPASS'),
'HOST': 'db', # You are supposed to use service name not localhost
'PORT': '3306',
}
@gagansh7171
gagansh7171 / Dockerfile
Created August 23, 2020 18:30
Frontend Dockerfile
FROM node:13.12.0-alpine
WORKDIR /app/frontend
COPY package.json package-lock.json ./
RUN npm install
RUN npm install react-scripts@3.4.1 -g
COPY . ./
EXPOSE 3000
@gagansh7171
gagansh7171 / Dockerfile
Created August 23, 2020 18:28
Project Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
WORKDIR /app/api
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . ./
EXPOSE 8000
@gagansh7171
gagansh7171 / docker-compose.yaml
Created August 23, 2020 18:26
Docker Compose File
version: "3.2"
services:
redis:
restart: always
image: redis:5
ports:
- "6379:6379"
networks:
- db-net