Git Product home page Git Product logo

maiden's Introduction

Docker, <Django + React>, <Ngnix + Postgres>

Dockerized boilerplate. Ngnix server + PostgreSQL database + Django / DRF API backend + React frontend.
Inspired by this and that.

During development, used SQLite + Django + React. In deployment, used Ngnix + PostgreSQL + Django.

Backend used:

Frontend used:

Prerequisites

Docker

  1. Docker
  2. docker-compose

Installation

Development

  • docker-compose up will build the image and run the container.

  • After running, you can see frontend at http://127.0.0.1:3000/ and backend at http://127.0.0.1:8000/.
    (Django built-in admin page at http://127.0.0.1:8000/api/admin/)

  • If you want to add a new npm package to the frontend, use docker-compose exec frontend yarn add ... or run ./frontend/fexec.sh yarn add ....
    (fexec.sh is just a wrapper for the former)

  • Similarly, if you want to add a new python package to the backend, use docker-compose exec backend pip install ... or run ./backend/bexec.sh pip install ....
    Save dependencies in requirements.txt. pip doesn't care about requirements.txt so you have to add dependency manually in the file.

    You can have a dedicated shell by running docker-compose exec service_name sh.

  • After you've added/modified models in the backend, you need to run database migration. docker-compose exec backend python manage.py makemigrations and docker-compose exec backend python manage.py migrate will compile migrations and migrate. Instead, you can run docker-compose up --no-deps --build backend to rebuild backend image since it automatically runs migrations during the build.

Deployment

  • ./build_front.sh will build React frontend and put files into ./backend/front_build directory. This should take a while.
  • docker-compose -f docker-compose.prod.yml up will build the image and run the container. While building, collecting Django static files, migrating PostgreSQL database, and configuring nginx server is done behind the scenes.
  • If it's successful, you can see the nginx server running at http://localhost. Django backend is served by gunicorn and configured as a reverse proxy in nginx configuration.
  • Django built-in admin page is at http://localhost/api/auth and you can log in with email: [email protected], password: devPass1!.
    This user is a superadmin and created automatically during the build of the docker image.
  • See .env.prod for production environment variables.

Made with ❤️ in Docker.

maiden's People

Contributors

eulerbeat5 avatar

Watchers

 avatar

Forkers

mojarcode

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.