Compare commits
No commits in common. "71964355b7d630ad992840a3effe6f46d964baa1" and "8e6b0a39b20d0e8c73a0375f64f701d81ff1ddce" have entirely different histories.
71964355b7
...
8e6b0a39b2
9 changed files with 10 additions and 58 deletions
3
.env
3
.env
|
@ -1,6 +1,3 @@
|
|||
APP_HOST=0.0.0.0
|
||||
APP_PORT=8000
|
||||
|
||||
DB_HOST=${REPO_NAME_SNAKE}_db
|
||||
DB_PORT=3306
|
||||
DB_USER=${REPO_NAME_SNAKE}
|
||||
|
|
2
.env_db
2
.env_db
|
@ -1,5 +1,5 @@
|
|||
MYSQL_HOST=${REPO_NAME_SNAKE}_db
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_RANDOM_ROOT_PASSWORD=true
|
||||
MYSQL_USER=${REPO_NAME_SNAKE}
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_DATABASE=${REPO_NAME_SNAKE}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
DEBUG=true
|
||||
|
||||
SESSION_KEY=debug
|
||||
CSRF_KEY=debug
|
||||
|
||||
APP_HOST=127.0.0.1
|
||||
APP_PORT=8000
|
||||
|
||||
DB_HOST=localhost
|
||||
DB_PORT=3306
|
||||
DB_USER=darkcat09
|
||||
|
|
14
Dockerfile
14
Dockerfile
|
@ -1,15 +1,7 @@
|
|||
FROM alpine:latest as build
|
||||
RUN apk add --no-cache python3 python3-dev py3-pip mariadb-dev build-base
|
||||
RUN pip install --no-cache-dir wheel
|
||||
FROM python:3-alpine
|
||||
RUN apk update && apk upgrade && apk add py-pip make
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip wheel --no-cache-dir -w /app/wheels -r requirements.txt
|
||||
|
||||
FROM alpine:latest as run
|
||||
RUN apk add --no-cache python3 py3-pip make mariadb-connector-c-dev
|
||||
COPY --from=build /app /app
|
||||
WORKDIR /app
|
||||
RUN pip install --no-cache-dir --find-links /app/wheels -r requirements.txt
|
||||
RUN apk del py3-pip && rm -rf /app/wheels
|
||||
RUN pip install -r requirements.txt
|
||||
CMD make prod
|
||||
EXPOSE 8000
|
||||
|
|
21
Makefile
21
Makefile
|
@ -1,14 +1,9 @@
|
|||
APP_HOST ?= 0.0.0.0
|
||||
APP_PORT ?= 8000
|
||||
|
||||
dev:
|
||||
python3 -m dotenv -f .env_debug run \
|
||||
make cmd-dev
|
||||
python3 -m uvicorn main:app --reload
|
||||
|
||||
prod:
|
||||
python3 -m gunicorn \
|
||||
-w 4 -k uvicorn.workers.UvicornWorker \
|
||||
-b $${APP_HOST}:$${APP_PORT} main:app
|
||||
python3 -m uvicorn main:app
|
||||
|
||||
format:
|
||||
python3 -m autopep8 -r --in-place app/
|
||||
|
@ -35,16 +30,8 @@ clean:
|
|||
rm -rf __pycache__
|
||||
rm -rf .mypy_cache
|
||||
|
||||
cmd-dev:
|
||||
python3 -m uvicorn main:app \
|
||||
--reload \
|
||||
--host $${APP_HOST} \
|
||||
--port $${APP_PORT}
|
||||
|
||||
cmd-docker-build:
|
||||
docker build \
|
||||
-t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:latest \
|
||||
-t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$${VERSION} .
|
||||
docker build -t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$${VERSION} .
|
||||
|
||||
cmd-docker-push:
|
||||
docker push -a ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}
|
||||
docker push ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$$VERSION
|
||||
|
|
|
@ -20,8 +20,6 @@ class Settings(BaseSettings):
|
|||
debug: bool = False
|
||||
session_key: str = secrets.token_hex(32)
|
||||
csrf_key: str = secrets.token_hex(32)
|
||||
app_host: str = '127.0.0.1'
|
||||
app_port: int = 8000
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
${REPO_NAME_SNAKE}:
|
||||
image: ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:latest
|
||||
container_name: ${REPO_NAME_SNAKE}
|
||||
|
@ -11,20 +10,10 @@ services:
|
|||
links:
|
||||
- ${REPO_NAME_SNAKE}_db
|
||||
env_file: .env
|
||||
depends_on:
|
||||
${REPO_NAME_SNAKE}_db:
|
||||
condition: service_healthy
|
||||
|
||||
${REPO_NAME_SNAKE}_db:
|
||||
image: mariadb:latest
|
||||
container_name: ${REPO_NAME_SNAKE}_db
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- "./database:/var/lib/mysql"
|
||||
env_file: .env_db
|
||||
healthcheck:
|
||||
test: sh -c "mysqladmin ping -u$$$$MYSQL_USER -p$$$$MYSQL_PASSWORD"
|
||||
interval: 1s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
start_period: 10s
|
||||
env_file: .env
|
||||
|
|
7
main.py
7
main.py
|
@ -3,12 +3,7 @@
|
|||
import uvicorn
|
||||
|
||||
from app.main import app
|
||||
from app.common import settings
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run(
|
||||
app=app,
|
||||
host=settings.app_host,
|
||||
port=settings.app_port,
|
||||
)
|
||||
uvicorn.run(app)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
fastapi==0.92.0
|
||||
uvicorn[standard]==0.20.0
|
||||
gunicorn==20.1.0
|
||||
jinja2==3.1.2
|
||||
starlette-wtf==0.4.3
|
||||
sqlalchemy==2.0.4
|
||||
|
|
Loading…
Add table
Reference in a new issue