aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile42
-rw-r--r--docker-compose.yml12
-rw-r--r--entrypoint.sh17
3 files changed, 32 insertions, 39 deletions
diff --git a/Dockerfile b/Dockerfile
index 45802a52..f6838e5b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,54 +16,18 @@ RUN mkdir -p /shifoo
WORKDIR /shifoo
-# Bind database and images folders as read write.
-# /home/ubuntu/database -> db.sqlite3 :: bind to /database -> db.sqlite3 in container
-# /home/ubuntu/database/images -> images :: bind to /WORKDIR/images in container
-
-VOLUME ["/database", "/shifoo/images"]
-
-COPY requirements.txt .
+COPY requirements.txt /shifoo/
RUN pip install -r requirements.txt
-COPY . .
+COPY . /shifoo/
RUN python manage.py collectstatic --noinput
-RUN python manage.py makemigrations
-
-RUN python manage.py migrate
-
-EXPOSE 8080
-
-CMD ["gunicorn", "--bind", ":8080", "--workers", "2", "thatcomputerscientist.wsgi"]
-
-# # OUTDATED
-# ARG PYTHON_VERSION=3.9
-
-# FROM python:${PYTHON_VERSION}
-
-# RUN apt-get update && apt-get install -y \
-# python3-pip \
-# python3-venv \
-# python3-dev \
-# python3-setuptools \
-# python3-wheel
-
-# RUN mkdir -p /app
-# WORKDIR /app
-
-# COPY requirements.txt .
-# RUN pip install -r requirements.txt
-
-# COPY . .
-
-# RUN python manage.py collectstatic --noinput
+# RUN python manage.py makemigrations
# RUN python manage.py migrate
-
# EXPOSE 8080
-# # replace APP_NAME with module name
# CMD ["gunicorn", "--bind", ":8080", "--workers", "2", "thatcomputerscientist.wsgi"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..fe64b234
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,12 @@
+version: '3'
+
+services:
+ web:
+ build: .
+ command: entrypoint.sh
+ volumes:
+ - .:/shifoo
+ - /home/ubuntu/database/db.sqlite3:/database/db.sqlite3
+ - /home/ubuntu/database/images:/shifoo/images
+ ports:
+ - "8080:8000" \ No newline at end of file
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100644
index 00000000..9760a84d
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Collect static files
+echo "Collect static files"
+python manage.py collectstatic --noinput
+
+# Create database migrations
+echo "Create database migrations"
+python manage.py makemigrations
+
+# Apply database migrations
+echo "Apply database migrations"
+python manage.py migrate
+
+# Start server
+echo "Starting server"
+python manage.py runserver 0.0.0.0:8000 \ No newline at end of file