Giter VIP home page Giter VIP logo

django-angular-crud's Introduction

django-angular-crud



Django Backend: Docker setup (Ubuntu)

  1. Install Docker.

  2. Start the Docker service:

    sudo service docker start
  3. Change to the django/ directory:

    cd django/
  4. Build the Docker image:

    sudo docker build -t da8ah/django-angular-crud .
  5. Run the Docker image without Detach mode (-d) nor Volume (-v) for simplicity:

    sudo docker run -p 8000:8000 da8ah/django-angular-crud
    sudo docker run -d -v ~/programming/django-angular-crud/django/:/app -p 8000:8000 da8ah/django-angular-crud
  6. Test if it's running; it should return an array from the database:

    http://localhost:8000/read/


Build

sudo docker build -t <tag-name> <dockerfile-dir>
  • Tag (-t): image alias
  • Dockerfile directory: directory where the Dockerfile is

Run

sudo docker run -d -v <project-dir>/:/app -p <host-port>:<container-port> <tag-name>
  • Detached mode (-d): runs container in its own process so it doesn't close when the terminal is closed.
  • Volume (-v): mount directory as a volume bind so changes made in the files of the given directory will update in the container.
  • Ports (-p): the container port will be forwarded to the host port so you can use it in any browser like http://localhost:<host-port>.
  • Tag: tag of the image that must run.

Troubleshooting

These commands can be useful for manage images and containers.

  • Stop and remove container processes:

    sudo docker stop <container-id>
    sudo docker rm <container-id>
  • List all images and remove images:

    sudo docker images
    sudo docker image rm <image-id>

Use the container id returned by the run command to operate with the container.

  • Open the container and Django server logs:

    sudo docker logs --follow <container-id>
  • Access the container shell:

    sudo docker exec -it <container-id> sh
  • Make Django migrations in the container shell if they are required:

    python3 manage.py migrate
    python3 manage.py makemigrations <app-name>


Angular Frontend

  1. Make sure Backend it's running.

  2. Open the Angular project in another terminal:

    cd angular/
  3. Install packages:

    npm i
  4. Run the server:

    ng serve -o
  5. If your browser ensures https usage you may use incognito mode with http only.

    http://localhost:4200/


django-angular-crud's People

Contributors

da8ah avatar

Watchers

 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.