Switch docker to debian

This commit is contained in:
Antoine Bertin 2021-04-28 12:53:30 +02:00
commit e8d7b1f177
No known key found for this signature in database
GPG key ID: 09851B52754E2327
8 changed files with 69 additions and 76 deletions

View file

@ -1,3 +1,4 @@
.git/
*/node_modules
*/dist
*/data/db

View file

@ -18,5 +18,4 @@
try_files {path}.html {path} /
file_server
}
}

View file

@ -1,3 +1,4 @@
# build
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY ./frontend/package*.json ./
@ -5,51 +6,46 @@ RUN npm install
COPY ./frontend/ .
RUN npm run build
FROM python:3.9-alpine
RUN apk add --no-cache libxml2-dev \
libxslt-dev \
libxml2 caddy \
libffi-dev \
python3 \
python3-dev \
jpeg-dev \
lcms2-dev \
openjpeg-dev \
zlib-dev
# run
FROM python:3.9-buster
ENV PRODUCTION true
EXPOSE 80
WORKDIR /app/
ENV POETRY_VERSION 1.1.6
COPY ./pyproject.toml /app/
RUN apt-get update && apt-get install -y \
apt-transport-https \
debian-archive-keyring \
debian-keyring \
&& 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 \
caddy \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --update --no-cache --virtual .build-deps \
curl \
g++ \
python3-dev \
musl-dev \
gcc \
build-base && \
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 && \
cd /app/ && poetry install --no-root --no-dev && \
apk --purge del .build-deps
# poetry
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION"
# database drivers
RUN pip install --no-cache-dir "psycopg2-binary==2.8.6"
# project dependencies
WORKDIR /app
COPY pyproject.toml poetry.lock /app/
RUN poetry config virtualenvs.create false
RUN poetry install --no-root --no-dev --no-interaction --no-ansi
# project code
COPY ./mealie /app/mealie
RUN poetry install --no-dev
# add database drivers
RUN pip install psycopg2-binary
COPY ./alembic /app
COPY alembic.ini /app
COPY ./Caddyfile /app
COPY ./dev/data/templates /app/data/templates
# frontend build
COPY --from=build-stage /app/dist /app/dist
VOLUME [ "/app/data/" ]
RUN chmod +x /app/mealie/run.sh
EXPOSE 80
CMD /app/mealie/run.sh

View file

@ -1,24 +1,23 @@
FROM python:3
WORKDIR /app/
FROM python:3.9-buster
ENV PRODUCTION false
ENV POETRY_VERSION 1.1.6
RUN apt-get update -y && \
apt-get install -y python-pip python-dev
# poetry
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION"
# 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
# database drivers
RUN pip install --no-cache-dir "psycopg2-binary==2.8.6"
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml /app/
# project dependencies
WORKDIR /app
COPY pyproject.toml poetry.lock /app/
RUN poetry config virtualenvs.create false
RUN poetry install --no-root --no-dev --no-interaction --no-ansi
# project code
COPY ./mealie /app/mealie
COPY ./alembic /app/alembic
COPY alembic.ini /app
RUN poetry install
RUN chmod +x /app/mealie/run.sh
CMD ["/app/mealie/run.sh", "reload"]
CMD [ "/app/mealie/run.sh", "development" ]

View file

@ -240,21 +240,20 @@ def upgrade():
op.bulk_insert(site_settings2categories_table, [
{
"sidebar_id": 1,
"category_slug", "thanksgiving",
"category_slug": "thanksgiving",
},
{
"sidebar_id": 1,
"category_slug", "homechef",
"category_slug": "homechef",
},
{
"sidebar_id": 1,
"category_slug", "potatoes",
"category_slug": "potatoes",
},
])
op.bulk_insert(site_theme_table, [
op.bulk_insert(theme_colors_table, [
{
"name": "default",
"colors": {
"parent_id": "default",
"primary": "#E58325",
"accent": "#00457A",
"secondary": "#973542",
@ -263,6 +262,10 @@ def upgrade():
"warning": "#FF4081",
"error": "#EF5350",
},
])
op.bulk_insert(site_theme_table, [
{
"name": "default",
},
])
op.bulk_insert(groups_table, [

View file

@ -27,7 +27,6 @@ services:
- 9921:9000
environment:
TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly.
DB_URL: sqlite:///mealie.db
volumes:
- ./dev/data:/app/dev/data
- ./mealie:/app/mealie

View file

@ -8,5 +8,3 @@ services:
restart: always
ports:
- 9090:80
environment:
DB_URL: sqlite:///mealie.db

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Get Reload Arg `run.sh reload` for dev server
ARG1=${1:-production}
@ -10,17 +10,15 @@ ARG1=${1:-production}
poetry run alembic upgrade head
poetry run python /app/mealie/services/image/minify.py
# Migrations
# TODO
# Migrations
# Set Port from ENV Variable
if [[ "$ARG1" = "reload" ]]
if [[ "$ARG1" = "development" ]]
then
echo "Hot Reload!"
echo "Development"
# Start API
uvicorn mealie.app:app --host 0.0.0.0 --port 9000 --reload
uvicorn mealie.app:app --host 0.0.0.0 --port 9000
else
echo "Production"
# Web Server