diff --git a/Dockerfile b/Dockerfile index 046c7dffe..12abb5e21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,25 @@ +# Use official Python base image FROM python:3.9 +# Set working directory WORKDIR /app/backend +# Copy requirements and install system dependencies COPY requirements.txt /app/backend RUN apt-get update \ && apt-get upgrade -y \ - && apt-get install -y gcc default-libmysqlclient-dev pkg-config \ + && apt-get install -y gcc default-libmysqlclient-dev pkg-config net-tools iproute2 \ && rm -rf /var/lib/apt/lists/* - -# Install app dependencies +# Install Python dependencies RUN pip install mysqlclient RUN pip install --no-cache-dir -r requirements.txt +# Copy the rest of the application code COPY . /app/backend +# Expose Django default port EXPOSE 8000 -#RUN python manage.py migrate -#RUN python manage.py makemigrations + +# Run Django development server bound to 0.0.0.0 so it's accessible externally +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/notesapp/settings.py b/notesapp/settings.py index deae53e73..a194ee6aa 100644 --- a/notesapp/settings.py +++ b/notesapp/settings.py @@ -1,36 +1,18 @@ """ Django settings for notesapp project. - -Generated by 'django-admin startproject' using Django 4.1.5. - -For more information on this file, see -https://docs.djangoproject.com/en/4.1/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/4.1/ref/settings/ """ import os from pathlib import Path -# Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-&dzi#zsb(hz6p(s#anunt&#-a%ohr2hld71*i72*^exvw-yq$y' -# SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] - -# Application definition - INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', @@ -40,16 +22,16 @@ 'django.contrib.staticfiles', 'api.apps.ApiConfig', 'rest_framework', - 'corsheaders' + 'corsheaders', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'corsheaders.middleware.CorsMiddleware', - "whitenoise.middleware.WhiteNoiseMiddleware", + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', - #'django.middleware.csrf.CsrfViewMiddleware', + # 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', @@ -83,26 +65,14 @@ WSGI_APPLICATION = 'notesapp.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/4.1/ref/settings/#databases - +# ✅ Use SQLite for local/Docker testing DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': os.getenv("DB_NAME"), - 'USER': os.getenv("DB_USER"), - 'PASSWORD': os.getenv("DB_PASSWORD"), - 'HOST': os.getenv("DB_HOST"), - 'PORT': os.getenv("DB_PORT"), + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', } } - -# Password validation -# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators - AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', @@ -118,35 +88,17 @@ }, ] - -# Internationalization -# https://docs.djangoproject.com/en/4.1/topics/i18n/ - LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'UTC' - USE_I18N = True - USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.1/howto/static-files/ - STATIC_URL = 'static/' -# STATICFILES_DIRS = [ -# BASE_DIR / 'mynotes/build/static' -# ] - STATICFILES_DIRS = [os.path.join(BASE_DIR, 'mynotes/build/static')] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') -# Default primary key field type -# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field - DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' CORS_ORIGIN_ALLOW_ALL = True