From ad295a0e6dd7c6ff07073e6e726caee93e0e30e4 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 3 Dec 2023 00:08:10 +0800 Subject: [PATCH] Add docker-related files --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ requirements.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..59f831b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use the official Python 3.11 image +# FROM --platform=arm64 python:3.11.4-bookworm +# ARG BUILDPLATFORM +FROM python:3.11.4-bookworm + +ENV PYTHONBUFFERED 1 + +# Create directory +RUN mkdir /code + +# Set the working directory to /code +WORKDIR /code + +# Mirror the current directory to the working directory for hotreloading +ADD . /code/ + +# Install pipenv +RUN pip install --no-cache-dir -r linux-requirements.txt + +# Make migrations +RUN python equipment_tracker/manage.py makemigrations + +# Run custom migrate +RUN python equipment_tracker/manage.py migrate + +# Generate DRF Spectacular Documentation +RUN python equipment_tracker/manage.py spectacular --color --file stude/schema.yml + +# Expose port 8000 for the web server +EXPOSE 8000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c73ff8e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3.9" + +services: + # Django App + django_backend: + build: + context: . + dockerfile: Dockerfile + image: equipmenttracker_backend:latest + ports: + - "8094:8000" # Expose port 8094 for the web server + environment: + - PYTHONBUFFERED=1 + command: + [ + "sh", + "-c", + "python equipment_tracker/manage.py spectacular --color --file stude/schema.yml && python equipment_tracker/manage.py collectstatic --noinput && python equipment_tracker/manage.py makemigrations && python equipment_tracker/manage.py migrate && python equipment_tracker/manage.py runserver", + ] + volumes: + - .:/code # For hotreloading +volumes: + equipment_tracker: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7e55fe0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,43 @@ +-i https://pypi.org/simple +asgiref==3.7.2; python_version >= '3.7' +attrs==23.1.0; python_version >= '3.7' +certifi==2023.11.17; python_version >= '3.6' +cffi==1.16.0; python_version >= '3.8' +charset-normalizer==3.3.2; python_full_version >= '3.7.0' +cryptography==41.0.7; python_version >= '3.7' +defusedxml==0.8.0rc2; python_version >= '3.6' +django==4.2.7 +django-cors-headers==4.3.1 +django-extra-fields==3.0.2 +django-simple-history==3.4.0 +django-templated-mail==1.1.1 +django-unfold==0.17.1 +djangorestframework==3.14.0 +djangorestframework-simplejwt==5.3.0; python_version >= '3.7' +djoser==2.2.2 +drf-spectacular[sidecar]==0.26.5 +drf-spectacular-sidecar==2023.10.1 +idna==3.6; python_version >= '3.5' +inflection==0.5.1; python_version >= '3.5' +jsonschema==4.20.0; python_version >= '3.8' +jsonschema-specifications==2023.11.2; python_version >= '3.8' +oauthlib==3.2.2; python_version >= '3.6' +pillow==10.1.0 +psycopg2==2.9.9 +pycparser==2.21 +pyjwt==2.8.0; python_version >= '3.7' +python-dotenv==1.0.0 +python3-openid==3.2.0 +pytz==2023.3.post1 +pyyaml==6.0.1; python_version >= '3.6' +referencing==0.31.1; python_version >= '3.8' +requests==2.31.0; python_version >= '3.7' +requests-oauthlib==1.3.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +rpds-py==0.13.2; python_version >= '3.8' +social-auth-app-django==5.4.0; python_version >= '3.8' +social-auth-core==4.5.1; python_version >= '3.8' +sqlparse==0.4.4; python_version >= '3.5' +tzdata==2023.3; sys_platform == 'win32' +uritemplate==4.1.1; python_version >= '3.6' +urllib3==2.1.0; python_version >= '3.8' +whitenoise==6.6.0