Giter VIP home page Giter VIP logo

airbnb-clone's Introduction

Airbnb Clone

Website: https://airproject.xyz

Technologies:

  • Django 3
  • Django Channels
  • DRF
  • Postgres
  • Celery
  • Redis

Configuration

Docker containers:

  1. nginx
  2. db
  3. redis
  4. daphne
  5. server
  6. celery
  7. flower
  8. celery_beat

docker-compose files:

  1. docker-compose-local.yml - for local development
  2. docker-compose-master.yml - for production

Swarm stack files:

  1. stack-prod.yml - for production

To run docker containers you have to create a .env file in the root directory.

Example of .env file:

ENV=.env


# Python
PYTHONUNBUFFERED=


# Project
ENVIRONMENT=<local|test|prod>
DJANGO_SETTINGS_MODULE=<airbnb.settings.local|airbnb.settings.pro>
PROJECT_ALLOWED_HOSTS=<host1,host2>
PROJECT_ADMIN_EMAIL=<[email protected]>
PROJECT_FULL_DOMAIN=<http://127.0.0.1>
SITE_DEFAULT_PROTOCOL=<http>


# Yandex Object Storage
USE_S3_BUCKET=<0|1>
YANDEX_STORAGE_BUCKET_NAME=
YANDEX_STORAGE_ACCESS_KEY_ID=
YANDEX_STORAGE_SECRET_ACCESS_KEY=


# Media & staticfiles
MEDIA_URL=
STATIC_URL=


# Emails
EMAIL_HOST_USER_ESL=<email@username>
EMAIL_HOST_PASSWORD_ESL=<email.password>


# Postgres
POSTGRES_DEFAULT_USER=
POSTGRES_DEFAULT_PASSWORD=
POSTGRES_DB=
POSTGRES_HOST=<db>
POSTGRES_PORT=

# Prod
POSTGRES_PROD_USER=
POSTGRES_PROD_PASSWORD=
POSTGRES_PROD_DB=

# Yandex.Cloud Managed PostgreSQL
USE_MANAGED_POSTGRES=<0|1>
POSTGRES_YANDEX_CLUSTER_NAME=
POSTGRES_YANDEX_USER=
POSTGRES_YANDEX_PASSWORD=
POSTGRES_YANDEX_DB=
POSTGRES_YANDEX_HOST=
POSTGRES_YANDEX_PORT=
POSTGRES_SSL_CERT_DOCKER_PATH=</docker/path/to/root.crt>


# Celery
CELERY_BROKER_URL=<redis://redis:6379/0>
CELERY_RESULT_BACKEND=<redis://redis:6379/0>


# Redis
REDIS_DECODE_RESPONSES=1
REDIS_PORT=6379
REDIS_URL=
AIRBNB_REDIS_HOST=<redis>

# Prod
REDIS_SSL_CERT_DOCKER_PATH=</docker/path/to/YandexInternalRootCA.crt>
REDIS_SENTINEL_HOSTS=<server-1,server-2>
REDIS_CLUSTER_NAME=
REDIS_CLUSTER_PASSWORD=

# Redis DBs
REDIS_CACHE_DB=
REDIS_MAIN_DB=
REDIS_SESSION_DB=
CELERY_REDIS_DB=
REDIS_CHANNELS_DB=

# Channels
REDIS_CHANNELS_URL=


# Twilio
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_PHONE_NUMBER=


# Sentry
AIRBNB_SENTRY_DSN=


# Flower
FLOWER_PORT=


# Traefik - optional
TRAEFIK_PILOT_TOKEN=
TRAEFIK_DASHBOARD_USER_CREDENTIALS=


# DOCKER HUB / CI - optional
DOCKER_HUB_USERNAME=<dockerhub-username>
DOCKER_HUB_PASSWORD=<dockerhub-password>
CI_COMMIT_SHORT_SHA=<latest>

Start project:

Local:

docker-compose -f docker-compose-local.yml build
docker-compose -f docker-compose-local.yml run --rm server sh -c "cd airbnb_app && ./manage.py migrate && ./manage.py populate_db"
docker-compose -f docker-compose-local.yml up

Production docker-compose:

  1. Create ./config/nginx/certs/ folder (in the repository root)
  2. Add ssl files:
    • airproject.crt: ssl certificate
    • airproject.key: private key
    • ca.crt: root certificate
  3. Run docker containers
docker-compose -f docker-compose-master.yml build
docker-compose -f docker-compose-master.yml up

Production Swarm:

  1. Create ./config/nginx/certs/ folder (in the repository root)
  2. Add ssl files:
    • airproject.crt: ssl certificate
    • airproject.key: private key
    • ca.crt: root certificate
  3. Build and push your image to the Docker Hub
  4. Deploy Swarm stack
env $(cat .env | grep ^[A-Z] | xargs) docker stack deploy -c stack-prod.yml airbnb_app --with-registry-auth

Migrations will be applied automatically.

Code style:

Before pushing a commit run all linters:

docker-compose -f docker-compose-local.yml run --rm server sh -c "make check"

You also have to add a makefile.env file (for pre-commit):

# Your docker-compose file name
DOCKER_COMPOSE_FILENAME=<docker-compose-local.yml>

And then run linters:

make check-docker

pre-commit:

To configure pre-commit on your local machine:

docker-compose -f docker-compose-local.yml build
docker-compose -f docker-compose-local.yml run --rm server sh -c "pre-commit install"

Project guides

airbnb-clone's People

Contributors

reznikovroman avatar shapranov-maxim avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.