forked from devopshobbies/docker-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request devopshobbies#55 from AliMehraji/main
Update: Reduce Layers in dockerfile in Django
- Loading branch information
Showing
5 changed files
with
35 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# Python With PostgreSQL | ||
|
||
## Introduction | ||
This dockercompose file creates a python application server alongside a PostgreSQL server and pgadmin server as database management tool | ||
This docker-compose file creates a python application server alongside a PostgreSQL server and pgadmin server as database management tool | ||
|
||
## How to use | ||
You can simply use project folder as your project main folder and this docker file updates Python project and run your new code everytime you restart python container | ||
You can simply use project folder as your project main folder and this docker file updates Python project and run your new code every time you restart python container | ||
|
||
## Required information | ||
You can access to postgreSQL username and password inside dockercompose.yaml file. | ||
You can access to postgreSQL username and password inside docker-compose.yaml file. | ||
|
||
Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,48 @@ | ||
 | ||
 | ||
# Learning Dockerfile for Beginners | ||
|
||
# Dockerfile for Beginners | ||
|
||
This project contains a simple and practical example of a Dockerfile to help beginners learn how to use Docker. | ||
|
||
## Prerequisites | ||
|
||
- Docker installed on your system | ||
- Basic knowledge of the Linux command line | ||
- Docker installed on your OS. [Docker Installation](https://docs.docker.com/engine/install/) | ||
- Basic knowledge of the Linux command line. | ||
|
||
## Here's what each line does | ||
## Each Line Explanation in Dockerfile | ||
|
||
- ``FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9-slim``: Use the official fastapi image as our base image. We're using the slim version to keep the image small. | ||
|
||
- ``WORKDIR /app``: Set the working directory in the container to /app. | ||
|
||
- ``COPY requirements.txt .``: Copy the requierments file from the current directory to the container. | ||
- ``WORKDIR /app``: Set the working directory in the container to `/app`. | ||
|
||
- ``COPY requirements.txt .``: Copy the `requirements.txt` file from the current directory to the container which is `/app` directory, because in the previous step we have used `WORKDIR` this directive makes `/app` directory and goes in it. | ||
|
||
- ``RUN pip install --no-cache-dir -r requirements.txt``: Install the project dependencies using pip. | ||
|
||
- ``COPY main.py .``: Copy the rest of the application code to the container. | ||
- ``COPY main.py .``: Copy the rest of the application code to the container which is `/app` | ||
|
||
- ``CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]``: Set the command to start the application. | ||
|
||
## Usage | ||
|
||
1. Clone the repository: | ||
|
||
```sh | ||
git clone https://github.com/devopshobbies/docker-templates.git | ||
``` | ||
```sh | ||
git clone https://github.com/devopshobbies/docker-templates.git | ||
``` | ||
|
||
2. Build the Docker image: | ||
|
||
```sh | ||
cd docker-templates/12-FastApi | ||
docker build -t hello-fastapi . | ||
``` | ||
```sh | ||
cd docker-templates/13-FastApi | ||
docker build -t hello-fastapi . | ||
``` | ||
|
||
3. Run the Docker container: | ||
|
||
```sh | ||
docker container run -d hello-fastapi -p 80:80 | ||
``` | ||
```sh | ||
docker container run --detach --publish 80:80 hello-fastapi | ||
``` | ||
> -d,--detach      Run container in background and print container ID </br> | ||
> -p, --publish list    Publish a container's port(s) to the host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters