37
loading...
This website collects cookies to deliver better user experience
#Pull the base image
FROM python:3.7-slim
# who is the maintainer/author of this file
LABEL org.opencontainers.image.authors="PAYALSASMAL, [email protected]"
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DEBUG 0
#upgrading pip for python
RUN python -m pip install --upgrade pip
#install tkinter for my application requirement, you can skip this for your application
RUN apt-get update && apt-get install -y tcl tk
#creating this dir for my application, you can skip this for your application
RUN mkdir -p /usr/share/man/man1
#installing libreoffice for my application, you can skip this for your application
RUN apt-get update && apt-get install -y \
libreoffice-base default-jre
#copying requirements.txt file
COPY ./requirements.txt /app/requirements.txt
#install those requirements before copying the project
RUN pip install -r /app/requirements.txt
#copy the project
COPY . .
#run gunicorn. here pdfconverter is the project name
CMD gunicorn -b 0.0.0.0:$PORT pdfconverter.wsgi:application
ALLOWED_HOSTS = ['127.0.0.1']
docker build -t pdfconverter:latest .
docker run --name pdfconverter -e "PORT=8000" -p 8007:8000 pdfconverter:latest
Django==3.2
djangoconvertvdoctopdf==1.0.1
gunicorn==20.1.0
pdf2docx==0.5.2
whitenoise==5.2.0
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'pdfconverter/static')
]
ALLOWED_HOSTS = ['127.0.0.1','pdfconverter-by-payal.herokuapp.com']
build:
docker:
web: Dockerfile
run:
web: gunicorn pdfconverter.wsgi:application --bind 0.0.0.0:$PORT
git push repo master
Please note few things for my website:-