-
Notifications
You must be signed in to change notification settings - Fork 311
feat(docker): add Docker setup #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .venv/ | ||
| .github/ | ||
| __pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| .travis.yml | ||
| .pre-commit-config.yaml | ||
| db.sqlite3 | ||
| README.md | ||
| .git/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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/ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This copies installed packages from |
||
|
|
||
| COPY . . | ||
|
|
||
| RUN python manage.py migrate | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Executing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have the required |
||
|
|
||
| FROM python:${PYTHON_VERSION}-slim AS run | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY --from=build /usr/local /usr/local | ||
| COPY --from=build /app /app | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You copy the whole |
||
| EXPOSE 8080 | ||
|
|
||
| CMD [ "python", "manage.py", "runserver", "0.0.0.0:8080" ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The file contains a Docker Hub link There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Docker Hub link here points to the sample repository There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This link still uses the sample username |
||
|
|
||
| ## 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 . | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| ``` | ||
|
|
||
| 4. Run the container: | ||
|
|
||
| ``` | ||
| docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| ``` | ||
|
|
||
| ## 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example tag command uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| ``` | ||
|
|
||
| 3. Push the image to Docker Hub: | ||
|
|
||
| ``` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| docker push prostoponchik/todoapp:1.0.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The push command references |
||
| ``` | ||
|
|
||
|
|
||
| ## Instructions for running the container from Docker Hub image | ||
|
|
||
| 1. Pull the image from Docker Hub: | ||
|
|
||
| ``` | ||
| docker pull prostoponchik/todoapp:1.0.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pull command below still points at the sample repository. Update this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| ``` | ||
|
|
||
| 2. Run the container: | ||
|
|
||
| ``` | ||
| docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The run-from-hub example uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
| ``` | ||
|
|
||
| ## 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/`. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be your actual Docker Hub username, not the template user
prostoponchik. Replace with your real account (e.g.,yourusername/todoapp).