Git Product home page Git Product logo

cs50_commerce's Introduction

CS50w Commerce

Revisiting my first django app. This project does not aim to reproduce all of ebay's functionality but does intend to generally allow any user to view content and for authenticated users to create or interact with auctions.

Prerequisites

This project uses docker for local development, to ensure that docker and docker-compose are properly installed on your local system please review Docker's installation guide and Docker-Compose

Build stage

This project utilizes the python3.9-slim-bullseye image - depending on how exicted you are about the new python 3.11 features you may update the local and production Django Dockerfiles to your desired python version (currently 3.7-3.11.0).

Note this project is tested/run on Debian flavored linux containers. You will need to embark on your own Dockerfile journey should you want to use Alpine linux for an itty bitty image size.

$ docker-compose -f local.yml build

Pre-commit

Check out pre-commit to catch any nitpicky issues before they are pushed to the remote repository. Before committing any code please follow pre-commit's installation instructions

Here we are creating a local virtual environment to contain this locally installed version of pre-commit.

$ python -m venv venv
$ source venv/bin/activate
$ pip install pre-commit
$ pre-commit install

Local development

Now we're ready to roll, simply run the following to launch the dev server

$ docker-compose -f local.yml up

Management commands and directly accessing your django container

To run migrations and create your first superuser

$ docker-compose -f local.yml run --rm django python manage.py migrate
$ docker-compose -f local.yml run --rm django python manage.py createsuperuser

To directly access a local container you can view all running containers by running:

$ docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED       STATUS       PORTS                                       NAMES
934c0f431cc4   wagtail_web            "./manage.py runserv…"   5 weeks ago   Up 5 weeks   0.0.0.0:8085->8085/tcp, :::8085->8085/tcp   web
a7d06cdda977   wagtail_frontend       "docker-entrypoint.s…"   5 weeks ago   Up 5 weeks                                               frontend
aa183c54dc68   postgres:12.3-alpine   "docker-entrypoint.s…"   5 weeks ago   Up 5 weeks   5432/tcp                                    db

You can then directly log into the target container by running the following with either the IMAGE_NAME or IMAGE_ID of the container:

$ docker exec -it bash IMAGE_NAME

or

$ docker exec -it bash IMAGE_ID

Note I've found that you will need to update two environment variables inside of the django container in order to successfully interact with postgres.

$ export CELERY_BROKER_URL="${REDIS_URL}"
$ export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"

both of these env variable export commands can be found in the compose/production/django/entrypoin.sh file.

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.