diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2308bf1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.venv/ +.github/ +__pycache__/ +*.pyc +*.pyo +.travis.yml +.pre-commit-config.yaml +db.sqlite3 +README.md +.git/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0693fb1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +ARG PYTHON_VERSION=3.9 + +FROM python:${PYTHON_VERSION}-slim AS build + +ENV PYTHONUNBUFFERED=1 +WORKDIR /app + +COPY requirements.txt ./ + +RUN pip install --no-cache-dir --prefix=/install -r requirements.txt +RUN cp -a /install/. /usr/local/ + +COPY . . + +RUN python manage.py migrate + +FROM python:${PYTHON_VERSION}-slim AS run +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +COPY --from=build /usr/local /usr/local +COPY --from=build /app /app +EXPOSE 8080 + +CMD [ "python", "manage.py", "runserver", "0.0.0.0:8080" ] diff --git a/INSTRUCTION.md b/INSTRUCTION.md new file mode 100644 index 0000000..39d227f --- /dev/null +++ b/INSTRUCTION.md @@ -0,0 +1,70 @@ +## Todo list application in Docker + +This is a to-do list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI. + +Link to the Docker Hub repository with the app image: [prostoponchik/todoapp](https://hub.docker.com/r/prostoponchik/todoapp) + +## Instructions for building and running the container from GitHub repository + +1. Clone the repository: + +``` +git clone https://github.com/ProstoPonchik/devops_todolist +``` + +2. Navigate to the project directory: + +``` +cd devops_todolist +``` + +3. Build the Docker image and tag it for Docker Hub: + +``` +docker build -t todoapp:1.0.0 -t prostoponchik/todoapp:1.0.0 . +``` + +4. Run the container: + +``` +docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0 +``` + +## Publishing the image to Docker Hub + +1. Log in to your Docker Hub account: + +``` +docker login +``` + +2. Tag the image for your Docker Hub repository: + +``` +docker tag todoapp:1.0.0 prostoponchik/todoapp:1.0.0 +``` + +3. Push the image to Docker Hub: + +``` +docker push prostoponchik/todoapp:1.0.0 +``` + + +## Instructions for running the container from Docker Hub image + +1. Pull the image from Docker Hub: + +``` +docker pull prostoponchik/todoapp:1.0.0 +``` + +2. Run the container: + +``` +docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0 +``` + +## Accessing the application via a browser + +Open your web browser and navigate to `http://localhost:8080/` to access the landing page of the ToDo application. You can also access the API at `http://localhost:8080/api/`.