# base image
FROM python:3.8
# setup environment variable
ENV DockerHOME=/home/app/webapp
# set work directory
RUN mkdir -p $DockerHOME
# where your code lives
WORKDIR $DockerHOME
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install --upgrade pip
# copy whole project to your docker home directory.
COPY . $DockerHOME
# run this command to install all dependencies
RUN pip install -r requirements.txt
# port where the Django app runs
EXPOSE 8000
# start server
CMD python manage.py runserver 0.0.0.0:3000
Sample requirements.txt file:
autopep8==1.5.7 psycopg2==2.9.1 Django==3.2
Build image:
docker build . -t uday1kiran/todoapp:1.0
To run it after creation:
docker run -d -p 8000:8000 uday1kiran/todoapp:1.0
Upload to hub:
docker push uday1kiran/todoapp:1.0
Reference
No comments:
Post a Comment