Skip to content

Commit

Permalink
containerised the website
Browse files Browse the repository at this point in the history
Signed-off-by: Raghav Sharma <[email protected]>
  • Loading branch information
raghavTinker committed Feb 2, 2022
1 parent cdf07cb commit 986422c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY requirements.txt .
RUN pip install gunicorn[gevent]
RUN python -m pip install -r requirements.txt

WORKDIR /app
COPY . /app
RUN mkdir officialWebsite/database

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER root


# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["sh", "run.sh"]
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.4'

services:
officialwebsiteapi:
image: officialwebsiteapi
build:
context: .
dockerfile: ./Dockerfile
ports:
- "8000:8000"
volumes:
- ./database/:/app/officialWebsite/database/
restart: always
3 changes: 3 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python manage.py migrate
python manage.py collectstatic
gunicorn --worker-class gevent --certfile=cert.pem --keyfile=privkey.pem --bind 0.0.0.0:8000 officialWebsite.config.wsgi:application

0 comments on commit 986422c

Please sign in to comment.