Skip to content

7 Docker Deploy

CarlosSouza87 edited this page Jun 5, 2023 · 1 revision

🐳 Docker Deploy

Deploy is the practice of making the application available for use, whether in a development, test, or production environment. Docker is a tool that, through the use of containers, facilitates the deployment of an application. With it it is possible to create images that contain everything necessary for the operation of the application, such as dependencies and libraries. Using docker is a way to deploy an application to a server.

It is a docker tool, used to build and configure multiple Docker containers simultaneously. You can start all your services through a configuration file (docker-compose.yml) with just one command. It can be used in all environments: production, testing, development, etc.

Docker Compose
version: "3"

services:
  backend-app:
    container_name: midall-backend-app
    image: midall-backend-app
    build:
      context: ../
      dockerfile: ./docker/flask.dockerfile
    restart: always
    ports:
      - "5000:5000"
    volumes:
      - ${FLASKR_BACK_DEV_DIR}:/flaskr
    env_file:
      - .env

networks:
  network:
    driver: bridge
    external: false
    name: midall-network

FLASKR_BACK_DEV_DIR is an environment variable defined in the .env file. This variable is the path where the application volume is.

FLASKR_BACK_DEV_DIR = project volume path
It is a configuration file, like docker-compose.yml, used to give instructions during the creation of containers. We can use it to download files, install packages, execute shell commands, etc.

DockerFile
FROM python:3.10.6-slim-buster

WORKDIR /flaskr/

COPY ./requirements.txt /flaskr/

WORKDIR /flaskr/

RUN pip install -r requirements.txt

CMD ["python", "-m", "flask", "run"]
It is a file that serves to exclude unnecessary directories or files in the build context.

DockerIgnore
tests
.vscode
.coveragerc
.pytest.ini
*.iml
**/__pycache__
**/migrations/*
*.md
.git
.gitignore
!README*.md
README-secret.md

Clone this wiki locally