Closed tuanhcmute closed 1 year ago
# Sử dụng một docker có sắn
FROM python:3.9-bullseye
# Tạo một folder root cho project
WORKDIR /api-dashboard
# Copy file requirements.txt vào folder api-dashboard
COPY requirements.txt .
# Install lib
RUN pip install -r requirements.txt
COPY ./app ./app
# Set env
ENV FLASK_ENV=development
ENV FLASK_DEBUG=1
ENV FLASK_APP=app/app.py
ENV FLASK_RUN_PORT=50000
ENV FLASK_RUN_HOST=0.0.0.0
ENV SECRET_KEY=your_secret_key
ENV MAIL_USERNAME=zzro333@gmail.com
ENV MAIL_PASSWORD=wiibdoxuisaydfnb
ENV SQLALCHEMY_DATABASE_URI=postgresql://postgres:1@localhost:5433/ApiDashboardDB
CMD [ "flask", "run" ]
version: '3.8'
services:
flask:
image: flask-python/api-dashboard:v1.0.0
container_name: flask
environment:
- SQLALCHEMY_DATABASE_URI=postgresql://postgres:1@postgresdb:5433/ApiDashboardDB
ports:
- 50001:50000
depends_on:
postgres:
condition: service_healthy
# networks:
# - postgres-python-network
postgres:
image: postgres
restart: always
container_name: postgresdb
environment:
POSTGRES_DB: ApiDashboardDB
POSTGRES_PASSWORD: 1
PGPORT: 5433
ports:
- 5434:5433
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s
# volumes:
# - pgdata-volume:/var/lib/postgresql
adminer:
image: adminer
restart: always
ports:
- 8081:8080
services: flask: image: flask-python/api-dashboard:v1.0.0 container_name: flask environment:
50001:50000 depends_on: postgres: condition: service_healthy
networks:
- postgres-python-network
postgres: image: postgres restart: always container_name: postgresdb environment: POSTGRES_DB: ApiDashboardDB POSTGRES_PASSWORD: 1 PGPORT: 5433 ports:
5434:5433 healthcheck: test: ["CMD-SHELL", "pg_isready"] interval: 1m30s timeout: 30s retries: 5 start_period: 30s
volumes:
- pgdata-volume:/var/lib/postgresql
adminer: image: adminer restart: always ports:
8081:8080
networks:
postgres-python-network:
name: postgres-python-network
volumes:
pgdata-volume:
Sử dụng một docker có sắn
FROM python:3.9-bullseye
Tạo một folder root cho project
WORKDIR /api-dashboard
Copy file requirements.txt vào folder api-dashboard
COPY requirements.txt .
Install lib
RUN pip install -r requirements.txt COPY ./app ./app
Set env
ENV FLASK_ENV=development ENV FLASK_DEBUG=1 ENV FLASK_APP=app/app.py ENV FLASK_RUN_PORT=50000 ENV FLASK_RUN_HOST=0.0.0.0 ENV SECRET_KEY=your_secret_key ENV MAIL_USERNAME=zzro333@gmail.com ENV MAIL_PASSWORD=wiibdoxuisaydfnb ENV SQLALCHEMY_DATABASE_URI=postgresql://postgres:1@localhost:5433/ApiDashboardDB
CMD [ "flask", "run" ]