caddy proxy path

This commit is contained in:
hay-kot 2021-04-29 17:40:48 -08:00
commit ef5a9b203b
9 changed files with 57 additions and 57 deletions

View file

@ -30,7 +30,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get remove -y curl apt-transport-https debian-keyring g++ gnupg gnupg2 gnupg1
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION"
#! Future

33
Dockerfile.dev Normal file
View file

@ -0,0 +1,33 @@
FROM python:3.9-slim-buster
ENV PRODUCTION false
ENV POETRY_VERSION 1.1.6
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ \
curl \
gnupg gnupg2 gnupg1 \
apt-transport-https \
debian-archive-keyring \
debian-keyring \
libwebp-dev \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | apt-key add - \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee -a /etc/apt/sources.list.d/caddy-stable.list \
&& apt-get update && apt-get install -y --no-install-recommends \
&& apt autoremove \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get remove -y curl apt-transport-https debian-keyring g++ gnupg gnupg2 gnupg1
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION"
WORKDIR /app/
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml /app/
COPY ./mealie /app/mealie
RUN poetry config virtualenvs.create false \
&& poetry install
RUN chmod +x /app/mealie/run.sh
CMD ["/app/mealie/run.sh", "reload"]

View file

@ -6,7 +6,7 @@ services:
container_name: mealie-frontend
image: mealie-frontend:dev
build:
context: ../frontend
context: ./frontend
dockerfile: frontend.Dockerfile
restart: always
ports:
@ -14,7 +14,7 @@ services:
environment:
VUE_APP_API_BASE_URL: "http://mealie-api:9000"
volumes:
- ../frontend/:/app
- ./frontend/:/app
- /app/node_modules
# Fast API
@ -22,8 +22,8 @@ services:
container_name: mealie-api
image: mealie-api:dev
build:
context: ../
dockerfile: ./docker/Dockerfile.dev
context: ./
dockerfile: Dockerfile.dev
restart: always
ports:
- 9921:9000
@ -31,8 +31,8 @@ services:
db_type: sqlite
TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly.
volumes:
- ../dev/data:/app/dev/data
- ../mealie:/app/mealie
- ./dev/data:/app/dev/data
- ./mealie:/app/mealie
# Mkdocs
mealie-docs:
@ -42,5 +42,4 @@ services:
ports:
- 9922:8000
volumes:
- ../docs:/docs
- ./docs:/docs

View file

@ -2,8 +2,8 @@ version: "3.1"
services:
mealie:
build:
context: ../
dockerfile: ./docker/Dockerfile
context: ./
dockerfile: Dockerfile
container_name: mealie
restart: always
ports:

View file

@ -1,24 +0,0 @@
FROM python:3
WORKDIR /app/
ENV PRODUCTION false
RUN apt-get update -y && \
apt-get install -y python-pip python-dev
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml /app/
COPY ./mealie /app/mealie
RUN poetry install
RUN chmod +x /app/mealie/run.sh
CMD ["/app/mealie/run.sh", "reload"]

View file

@ -71,10 +71,10 @@ docs: ## Start Mkdocs Development Server
cd docs && poetry run python -m mkdocs serve
docker-dev: ## Build and Start Docker Development Stack
docker-compose -f ./docker/docker-compose.dev.yml -p dev-mealie up --build
docker-compose -f docker-compose.dev.yml -p dev-mealie up --build
docker-prod: ## Build and Start Docker Production Stack
docker-compose -f ./docker/docker-compose.yml -p mealie up --build -d
docker-compose -f docker-compose.yml -p mealie up --build -d
code-gen: ## Run Code-Gen Scripts
poetry run python dev/scripts/app_routes_gen.py

View file

@ -2,6 +2,8 @@ from enum import Enum
from fastapi import APIRouter, Depends, File, Form, HTTPException
from fastapi.responses import FileResponse
from mealie.core.config import app_dirs
from mealie.core.root_logger import get_logger
from mealie.db.database import db
from mealie.db.db_setup import generate_session
from mealie.routes.deps import get_current_user
@ -12,6 +14,7 @@ from mealie.services.scraper.scraper import create_from_url
from sqlalchemy.orm.session import Session
router = APIRouter(prefix="/api/recipes", tags=["Recipe CRUD"])
logger = get_logger()
@router.post("/create", status_code=201, response_model=str)
@ -106,22 +109,15 @@ def delete_recipe(
class ImageType(str, Enum):
original = "original"
small = "small"
tiny = "tiny"
original = "original.webp"
small = "min-original.webp"
tiny = "tiny-original.webp"
@router.get("/{recipe_slug}/image")
async def get_recipe_img(recipe_slug: str, image_type: ImageType = ImageType.original):
@router.get("/image/{recipe_slug}/{file_name}")
async def get_recipe_img(recipe_slug: str, file_name: ImageType = ImageType.original):
""" Takes in a recipe slug, returns the static image """
if image_type == ImageType.original:
which_image = IMG_OPTIONS.ORIGINAL_IMAGE
elif image_type == ImageType.small:
which_image = IMG_OPTIONS.MINIFIED_IMAGE
elif image_type == ImageType.tiny:
which_image = IMG_OPTIONS.TINY_IMAGE
recipe_image = read_image(recipe_slug, image_type=which_image)
recipe_image = app_dirs.IMG_DIR.joinpath(recipe_slug, file_name.value)
if recipe_image:
return FileResponse(recipe_image)
else:

View file

@ -1,11 +1,8 @@
#!/bin/sh
#!/bin/bash
# Get Reload Arg `run.sh reload` for dev server
ARG1=${1:-production}
# Set Script Directory - Used for running the script from a different directory.
# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# # Initialize Database Prerun
poetry run python /app/mealie/db/init_db.py
poetry run python /app/mealie/services/image/minify.py
@ -15,12 +12,12 @@ poetry run python /app/mealie/services/image/minify.py
# Migrations
# Set Port from ENV Variable
if [[ "$ARG1" = "reload" ]]
if [ "$ARG1" == "reload" ]
then
echo "Hot Reload!"
# Start API
uvicorn mealie.app:app --host 0.0.0.0 --port 9000 --reload
python /app/mealie/app.py
else
echo "Production"
# Web Server