From c3ac8efa571274cff4b9b6161c2e32b6c11b3db0 Mon Sep 17 00:00:00 2001 From: Xopino Date: Sat, 4 May 2024 03:11:15 +0200 Subject: [PATCH] add docker --- .gitignore | 2 +- Dockerfile | 18 ++++++++++++++++++ Makefile | 17 +++++++++++++++++ shopify_django_app/settings.py | 5 ++++- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 3025cb9..eee5e41 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # Created by https://www.gitignore.io - ### OSX ### .DS_Store .AppleDouble @@ -88,3 +87,4 @@ local_settings.py .env db.sqlite3 +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2dc2746 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:20.04 + +RUN apt-get update && \ + apt-get install -y python3.8 python3-pip && \ + pip install pipenv + +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 && \ + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 + +COPY . /app + +WORKDIR /app + +RUN pipenv install --deploy --ignore-pipfile + +EXPOSE 8000 + +CMD ["pipenv", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c43faff --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +IMAGE_NAME=shopify_django_app + +build: + docker build -t $(IMAGE_NAME) . + +run: + docker run -d --name $(IMAGE_NAME) -v $(PWD):/app -p 8000:8000 $(IMAGE_NAME) + +stop: + docker stop $(IMAGE_NAME) + docker rm $(IMAGE_NAME) + +shell: + docker run -it $(IMAGE_NAME) /bin/bash + +migration: + docker run -it -v $(PWD):/app $(IMAGE_NAME) pipenv run python manage.py migrate diff --git a/shopify_django_app/settings.py b/shopify_django_app/settings.py index 0e71f4a..7123d6a 100644 --- a/shopify_django_app/settings.py +++ b/shopify_django_app/settings.py @@ -26,7 +26,10 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = [ + 'localhost', + '127.0.0.1', +] # Application definition