update repository references and improve script handling
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ENV=local
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -220,3 +220,5 @@ FodyWeavers.xsd
|
|||||||
*.msp
|
*.msp
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
*/.venv/
|
||||||
|
*/venv/
|
||||||
|
|||||||
47
Makefile
Normal file
47
Makefile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
SHELL := /bin/bash
|
||||||
|
DOCKER_USER=mesteriis
|
||||||
|
DOCKER_REPO=hassio
|
||||||
|
GIT_SHA=$(shell git rev-parse --short HEAD)
|
||||||
|
BASE_IMAGE_DOCKERFILES=$(shell find ./base_docker_images/ -name 'Dockerfile')
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ("$(wildcard .env)", "")
|
||||||
|
include .env
|
||||||
|
export $(shell sed 's/=.*//' .env)
|
||||||
|
|
||||||
|
else
|
||||||
|
$(shell cp .env.example .env)
|
||||||
|
include .env
|
||||||
|
export $(shell sed 's/=.*//' .env)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ("$(wildcard .env)", "")
|
||||||
|
$(info $(shell echo "Loading environment variables from .env file..."))
|
||||||
|
$(info $(shell cat .env))
|
||||||
|
$(info $(shell echo "***********************************************"))
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: build push all
|
||||||
|
|
||||||
|
all: build push
|
||||||
|
|
||||||
|
build:
|
||||||
|
@echo "Собираем все Docker образы..."
|
||||||
|
@for dockerfile in $(BASE_IMAGE_DOCKERFILES); do \
|
||||||
|
dir=$$(dirname $$dockerfile); \
|
||||||
|
tag_name=$$(echo $$dir | sed 's|^\./||' | tr '/' '-' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]'); \
|
||||||
|
base_tag="$(DOCKER_USER)/$(DOCKER_REPO)-$$tag_name"; \
|
||||||
|
echo "Собираем образ $$base_tag:$(GIT_SHA)"; \
|
||||||
|
docker build -t $$base_tag:$(GIT_SHA) -t $$base_tag:latest $$dir; \
|
||||||
|
done
|
||||||
|
|
||||||
|
push:
|
||||||
|
@echo "Отправляем образы в Docker Hub..."
|
||||||
|
@for dockerfile in $(BASE_IMAGE_DOCKERFILES); do \
|
||||||
|
dir=$$(dirname $$dockerfile); \
|
||||||
|
tag_name=$$(echo $$dir | sed 's|^\./||' | tr '/' '-' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]'); \
|
||||||
|
base_tag="$(DOCKER_USER)/$(DOCKER_REPO)-$$tag_name"; \
|
||||||
|
echo "Пушим образ $$base_tag:$(GIT_SHA)"; \
|
||||||
|
docker push $$base_tag:$(GIT_SHA); \
|
||||||
|
docker push $$base_tag:latest; \
|
||||||
|
done
|
||||||
18
base_docker_images/build_local.sh
Executable file
18
base_docker_images/build_local.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DOCKER_USER="mesteriis"
|
||||||
|
DOCKER_REPO="hassio"
|
||||||
|
|
||||||
|
find . -name 'Dockerfile' | while read dockerfile; do
|
||||||
|
dir=$(dirname "$dockerfile")
|
||||||
|
tag_name=$(echo "$dir" | sed 's|^\./||' | tr '/' '-' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
|
||||||
|
git_sha=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
base_tag="${DOCKER_USER}/${DOCKER_REPO}-${tag_name}"
|
||||||
|
command="docker build -t ${base_tag}:${git_sha} -t ${base_tag}:latest $dir"
|
||||||
|
echo $command
|
||||||
|
docker build -t ${base_tag}:${git_sha} -t ${base_tag}:latest $dir
|
||||||
|
docker push ${base_tag}:${git_sha}
|
||||||
|
docker push ${base_tag}:latest
|
||||||
|
|
||||||
|
done
|
||||||
3
base_docker_images/python/3.11/Makefile
Normal file
3
base_docker_images/python/3.11/Makefile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
build:
|
||||||
|
@echo "Building base docker images..."
|
||||||
|
@docker build Dockerfile_python -t base_python:latest
|
||||||
70
blank-fastapi-vue-hassio/Dockerfile
Executable file → Normal file
70
blank-fastapi-vue-hassio/Dockerfile
Executable file → Normal file
@@ -1,49 +1,25 @@
|
|||||||
ARG BUILD_FROM=hassioaddons/base-python:5.2.0
|
FROM python:3.11-buster
|
||||||
# hadolint ignore=DL3006
|
|
||||||
FROM ${BUILD_FROM}
|
|
||||||
|
|
||||||
# Set shell
|
RUN apt-get update && \
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
libssl-dev \
|
||||||
|
libffi-dev \
|
||||||
|
python3-dev \
|
||||||
|
libpq-dev \
|
||||||
|
libjpeg-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libtiff5-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libxslt1-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
libsasl2-dev \
|
||||||
|
libmysqlclient-dev \
|
||||||
|
default-libmysqlclient-dev && \
|
||||||
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy Python requirements file
|
RUN pip install --upgrade pip
|
||||||
COPY hello_flask/requirements.txt /tmp/
|
RUN pip install --upgrade setuptools
|
||||||
COPY hello_flask/app.py /
|
RUN pip install --upgrade wheel
|
||||||
|
RUN pip install uv
|
||||||
# Setup base
|
|
||||||
ARG BUILD_ARCH=amd64
|
|
||||||
RUN \
|
|
||||||
apk add --no-cache --virtual .build-dependencies \
|
|
||||||
g++=9.2.0-r4 \
|
|
||||||
gcc=9.2.0-r4 \
|
|
||||||
make=4.2.1-r2 \
|
|
||||||
\
|
|
||||||
&& apk add --no-cache \
|
|
||||||
nginx-mod-http-lua=1.16.1-r6 \
|
|
||||||
lua-resty-http=0.15-r0 \
|
|
||||||
nginx=1.16.1-r6 \
|
|
||||||
cython=0.29.14-r0 \
|
|
||||||
\
|
|
||||||
&& pip3 install \
|
|
||||||
--no-cache-dir \
|
|
||||||
--prefer-binary \
|
|
||||||
--find-links "https://wheels.hass.io/alpine-3.11/${BUILD_ARCH}/" \
|
|
||||||
-r /tmp/requirements.txt \
|
|
||||||
\
|
|
||||||
&& find /usr/local \
|
|
||||||
\( -type d -a -name test -o -name tests -o -name '__pycache__' \) \
|
|
||||||
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
|
|
||||||
-exec rm -rf '{}' + \
|
|
||||||
\
|
|
||||||
&& apk del --purge .build-dependencies \
|
|
||||||
&& rm -f -r \
|
|
||||||
/etc/nginx \
|
|
||||||
/tmp/*
|
|
||||||
|
|
||||||
# Copy data for add-on
|
|
||||||
COPY run.sh /
|
|
||||||
COPY hello_flask/requirements.txt /tmp/
|
|
||||||
# Install requirements for add-on
|
|
||||||
RUN pip install -r /tmp/requirements.txt
|
|
||||||
|
|
||||||
RUN chmod a+x /run.sh
|
|
||||||
CMD [ "/run.sh" ]
|
|
||||||
@@ -28,3 +28,6 @@ run:
|
|||||||
@echo "Running server..."
|
@echo "Running server..."
|
||||||
uvicorn app.main:app --host localhost --port 8000
|
uvicorn app.main:app --host localhost --port 8000
|
||||||
@echo "Server running at http://localhost:8000"
|
@echo "Server running at http://localhost:8000"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
49
blank-fastapi-vue-hassio/_Dockerfile
Executable file
49
blank-fastapi-vue-hassio/_Dockerfile
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#ARG BUILD_FROM=hassioaddons/base-python:5.2.0
|
||||||
|
# hadolint ignore=DL3006
|
||||||
|
FROM hassioaddons/base-python:5.2.0
|
||||||
|
|
||||||
|
# Set shell
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
|
# Copy Python requirements file
|
||||||
|
COPY requirements.txt /tmp/
|
||||||
|
COPY src /app
|
||||||
|
|
||||||
|
# Setup base
|
||||||
|
ARG BUILD_ARCH=amd64
|
||||||
|
RUN \
|
||||||
|
apk add --no-cache --virtual .build-dependencies \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
make \
|
||||||
|
\
|
||||||
|
&& apk add --no-cache \
|
||||||
|
nginx-mod-http-lua=1.16.1-r6 \
|
||||||
|
lua-resty-http=0.15-r0 \
|
||||||
|
nginx=1.16.1-r6 \
|
||||||
|
cython=0.29.14-r0 \
|
||||||
|
\
|
||||||
|
&& pip3 install \
|
||||||
|
--no-cache-dir \
|
||||||
|
--prefer-binary \
|
||||||
|
--find-links "https://wheels.hass.io/alpine-3.11/${BUILD_ARCH}/" \
|
||||||
|
-r /tmp/requirements.txt \
|
||||||
|
\
|
||||||
|
&& find /usr/local \
|
||||||
|
\( -type d -a -name test -o -name tests -o -name '__pycache__' \) \
|
||||||
|
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
|
||||||
|
-exec rm -rf '{}' + \
|
||||||
|
\
|
||||||
|
&& apk del --purge .build-dependencies \
|
||||||
|
&& rm -f -r \
|
||||||
|
/etc/nginx \
|
||||||
|
/tmp/*
|
||||||
|
|
||||||
|
# Copy data for add-on
|
||||||
|
COPY run.sh /
|
||||||
|
COPY requirements.txt /tmp/
|
||||||
|
# Install requirements for add-on
|
||||||
|
RUN pip install -r /tmp/requirements.txt
|
||||||
|
|
||||||
|
RUN chmod a+x /run.sh
|
||||||
|
CMD [ "/run.sh" ]
|
||||||
@@ -1,147 +1,16 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
|
||||||
image: postgres:13-alpine
|
|
||||||
container_name: social_db
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
|
||||||
volumes:
|
|
||||||
- ./docker/data/db/data:/var/lib/postgresql/data
|
|
||||||
- ./docker/data/db/backup:/backup
|
|
||||||
- ./etc/init-user.sql:/docker-entrypoint-initdb.d/init-user.sql
|
|
||||||
ports:
|
|
||||||
- "8432:5432"
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
DEV: "true"
|
DEV: "true"
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8000:8000"
|
||||||
restart: always
|
restart: always
|
||||||
container_name: social_app
|
container_name: social_app
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
links:
|
command: sh -c "uvicorn main:app --reload --host 0.0.0.0 --port 8000"
|
||||||
- db
|
|
||||||
depends_on:
|
|
||||||
db:
|
|
||||||
condition: service_healthy
|
|
||||||
command: sh -c "aerich upgrade && uvicorn main:app --reload --host 0.0.0.0 --port 8080"
|
|
||||||
volumes:
|
|
||||||
- ./src:/src/
|
|
||||||
|
|
||||||
rabbitmq:
|
|
||||||
container_name: social_rabbitmq
|
|
||||||
image: rabbitmq:3-management-alpine
|
|
||||||
ports:
|
|
||||||
- "3672:5672"
|
|
||||||
- "14672:15672"
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "rabbitmqctl", "status"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
taskiq-worker:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: social_taskiq
|
|
||||||
container_name: social_taskiq
|
|
||||||
env_file: .env
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./src:/src
|
|
||||||
links:
|
|
||||||
- db
|
|
||||||
- rabbitmq
|
|
||||||
depends_on:
|
|
||||||
db:
|
|
||||||
condition: service_healthy
|
|
||||||
rabbitmq:
|
|
||||||
condition: service_healthy
|
|
||||||
command: [ taskiq, worker, core.tkq:broker, -fsd]
|
|
||||||
ports: []
|
|
||||||
|
|
||||||
taskiq-faststream-scheduler:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: social_taskiq_faststream_scheduler
|
|
||||||
container_name: social_taskiq_faststream_scheduler
|
|
||||||
env_file: .env
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./src:/src
|
|
||||||
links:
|
|
||||||
- db
|
|
||||||
- rabbitmq
|
|
||||||
depends_on:
|
|
||||||
db:
|
|
||||||
condition: service_healthy
|
|
||||||
rabbitmq:
|
|
||||||
condition: service_healthy
|
|
||||||
command: [ taskiq, scheduler, core.tkq_faststream:scheduler, -fsd]
|
|
||||||
ports: []
|
|
||||||
|
|
||||||
taskiq-scheduler:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: social_taskiq_scheduler
|
|
||||||
container_name: social_taskiq_scheduler
|
|
||||||
env_file: .env
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./src:/src
|
|
||||||
links:
|
|
||||||
- db
|
|
||||||
- rabbitmq
|
|
||||||
depends_on:
|
|
||||||
db:
|
|
||||||
condition: service_healthy
|
|
||||||
rabbitmq:
|
|
||||||
condition: service_healthy
|
|
||||||
command: [ taskiq, scheduler, core.tkq:scheduler, -fsd]
|
|
||||||
ports: []
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:6.0-alpine
|
|
||||||
container_name: social_redis
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./docker/data/redis:/data
|
|
||||||
ports:
|
|
||||||
- 6377:6379
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
faststream_worker:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
env_file: .env
|
|
||||||
links:
|
|
||||||
- db
|
|
||||||
- redis
|
|
||||||
depends_on:
|
|
||||||
app:
|
|
||||||
condition: service_started
|
|
||||||
db:
|
|
||||||
condition: service_healthy
|
|
||||||
redis:
|
|
||||||
condition: service_healthy
|
|
||||||
command: python core/faststream_worker.py
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ pre-commit==4.1.0
|
|||||||
pydantic==2.10.6
|
pydantic==2.10.6
|
||||||
pydantic-core==2.27.2
|
pydantic-core==2.27.2
|
||||||
pytest==8.3.5
|
pytest==8.3.5
|
||||||
|
pytest-asyncio==0.25.3
|
||||||
pytest-cov==6.0.0
|
pytest-cov==6.0.0
|
||||||
pytest-mock==3.14.0
|
pytest-mock==3.14.0
|
||||||
pyyaml==6.0.2
|
pyyaml==6.0.2
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
|
|
||||||
echo Running flask hello world
|
echo Running flask hello world
|
||||||
uvicorn app.main:app --host localhost --port 8000
|
uvicorn main:app --host localhost --port 8000
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user