diff --git a/zzz_test/Dockerfile b/zzz_test/Dockerfile index eddad3c43..b21f8ee4c 100644 --- a/zzz_test/Dockerfile +++ b/zzz_test/Dockerfile @@ -1,3 +1,36 @@ +# Stage 1: Build Frontend with SUB_PATH +FROM node:16 AS builder + +# Set the SUB_PATH environment variable +ARG SUB_PATH="/mealie/" +ENV SUB_PATH=$SUB_PATH + +WORKDIR /app + +# Clone the Mealie repository to get the frontend source code +RUN git clone https://github.com/mealie-recipes/mealie.git . + +WORKDIR /app/frontend + +# Install frontend dependencies +RUN yarn install \ + --prefer-offline \ + --frozen-lockfile \ + --non-interactive \ + --production=false \ + --network-timeout 1000000 + +# Build the frontend with the specified SUB_PATH +RUN yarn generate + +# Stage 2: Build the Final Image +ARG BUILD_FROM +FROM ${BUILD_FROM} + +# Copy the rebuilt frontend files into the final image +COPY --from=builder /app/frontend/dist /spa/static + +# Proceed with your existing modifications and installations #============================# # ALEXBELGIUM'S DOCKERFILE # #============================# @@ -14,9 +47,9 @@ # 1 Build Image # ################# -ARG BUILD_FROM -ARG BUILD_VERSION -FROM ${BUILD_FROM} AS base-addon +# The base image is already specified above +# ARG BUILD_FROM +# FROM ${BUILD_FROM} ################## # 2 Modify Image # @@ -33,13 +66,13 @@ RUN grep -rl "/app/data" /app | xargs sed -i 's|/app/data|/config/addons_config/ sed -i "s|change_user$|# change_user|g" /app/run.sh ################## -# 3 Install Apps # +# 3 Install apps # ################## # Add rootfs COPY rootfs/ / -# Ensure /bin/sh and /bin/bash exist for compatibility +# Uses /bin for compatibility purposes # hadolint ignore=DL4005 RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \ if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi @@ -58,175 +91,27 @@ ENV PACKAGES="nginx" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh" RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh -############################################### -# 4 Integrate Mealie Dockerfile - Frontend Build -############################################### +################ +# 4 Entrypoint # +################ -# Define build arguments for SUB_PATH -ARG SUB_PATH=/hllo/ -ENV SUB_PATH=${SUB_PATH} +# Add entrypoint +ENV S6_STAGE2_HOOK=/ha_entrypoint.sh +ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" "/ha_entrypoint.sh" -# Frontend Builder Stage -FROM node:16 AS mealie-frontend-builder +# Entrypoint modifications +ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" +RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh -WORKDIR /app/frontend - -# Copy frontend source code -COPY ./frontend . - -# Install dependencies -RUN yarn install \ - --prefer-offline \ - --frozen-lockfile \ - --non-interactive \ - --production=false \ - --network-timeout 1000000 - -# Pass SUB_PATH to the build environment -ENV SUB_PATH=${SUB_PATH} - -# Build the frontend -RUN yarn generate - -############################################### -# 5 Integrate Mealie Dockerfile - Python Base and Dependencies -############################################### - -FROM python:3.10-slim AS mealie-python-base - -ENV MEALIE_HOME="/app" - -ENV PYTHONUNBUFFERED=1 \ - PYTHONDONTWRITEBYTECODE=1 \ - PIP_NO_CACHE_DIR=off \ - PIP_DISABLE_PIP_VERSION_CHECK=on \ - PIP_DEFAULT_TIMEOUT=100 \ - POETRY_HOME="/opt/poetry" \ - POETRY_VIRTUALENVS_IN_PROJECT=true \ - POETRY_NO_INTERACTION=1 \ - PYSETUP_PATH="/opt/pysetup" \ - VENV_PATH="/opt/pysetup/.venv" - -# Prepend poetry and venv to PATH -ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" - -# Create user account -RUN useradd -u 911 -U -d $MEALIE_HOME -s /bin/bash abc \ - && usermod -G users abc \ - && mkdir -p $MEALIE_HOME - -# Builder Base Image -FROM mealie-python-base AS mealie-builder-base - -RUN apt-get update \ - && apt-get install --no-install-recommends -y \ - curl \ - build-essential \ - libpq-dev \ - libwebp-dev \ - # LDAP Dependencies - libsasl2-dev libldap2-dev libssl-dev \ - gnupg gnupg2 gnupg1 \ - && rm -rf /var/lib/apt/lists/* \ - && pip install -U --no-cache-dir pip - -# Install Poetry -ENV POETRY_VERSION=1.3.1 -RUN curl -sSL https://install.python-poetry.org | python3 - - -# Copy project requirement files -WORKDIR $PYSETUP_PATH -COPY ./poetry.lock ./pyproject.toml ./ - -# Install runtime dependencies -RUN poetry install -E pgsql --only main - -# CRFPP Image (Assuming it's needed) -FROM hkotel/crfpp AS crfpp - -RUN echo "crfpp-container" - -# Production Image -FROM mealie-python-base AS mealie-production - -LABEL org.opencontainers.image.source="https://github.com/mealie-recipes/mealie" - -ENV PRODUCTION=true -ENV TESTING=false - -ARG COMMIT -ENV GIT_COMMIT_HASH=${COMMIT} - -RUN apt-get update \ - && apt-get install --no-install-recommends -y \ - gosu \ - iproute2 \ - libldap-common \ - libldap-2.5 \ - && rm -rf /var/lib/apt/lists/* - -# Create directory for Docker Secrets -RUN mkdir -p /run/secrets - -# Copy Poetry and virtual environment from builder-base -COPY --from=mealie-builder-base $POETRY_HOME $POETRY_HOME -COPY --from=mealie-builder-base $PYSETUP_PATH $PYSETUP_PATH - -ENV LD_LIBRARY_PATH=/usr/local/lib - -# Copy CRF++ binaries -COPY --from=crfpp /usr/local/lib/ /usr/local/lib -COPY --from=crfpp /usr/local/bin/crf_learn /usr/local/bin/crf_learn -COPY --from=crfpp /usr/local/bin/crf_test /usr/local/bin/crf_test - -# Copy backend application -COPY ./mealie $MEALIE_HOME/mealie -COPY ./poetry.lock ./pyproject.toml $MEALIE_HOME/ - -# Alembic migrations -COPY ./alembic $MEALIE_HOME/alembic -COPY ./alembic.ini $MEALIE_HOME/ - -# Install Python runtime dependencies -WORKDIR $MEALIE_HOME -RUN . $VENV_PATH/bin/activate && poetry install -E pgsql --only main -WORKDIR / - -# Install CRF++ Models -RUN python $MEALIE_HOME/mealie/scripts/install_model.py - -# Define volumes and environment variables -VOLUME [ "$MEALIE_HOME/data/" ] -ENV APP_PORT=9000 - -EXPOSE ${APP_PORT} - -# Healthcheck -HEALTHCHECK CMD python $MEALIE_HOME/mealie/scripts/healthcheck.py || exit 1 - -# ---------------------------------- -# 6 Integrate Mealie Dockerfile - Copy Frontend - -ENV STATIC_FILES=/spa/static -COPY --from=mealie-frontend-builder /app/frontend/dist ${STATIC_FILES} - -ENV HOST=0.0.0.0 - -EXPOSE ${APP_PORT} - -# ---------------------------------- -# 7 Entrypoint and Scripts - -# Add entrypoint script from Mealie repository -ADD "https://raw.githubusercontent.com/mealie-recipes/mealie/mealie-next/docker/entry.sh" "/app/run.sh" - -# Ensure the entry.sh is executable -RUN chmod +x /app/run.sh - -ENTRYPOINT ["/app/run.sh"] +RUN \ + # Add custom instructions to run.sh on armv7 + sed -i '1d' /app/run.sh \ + && cat /app/run.sh >> /run.txt \ + && cat /run.txt > /app/run.sh \ + && chmod +x /app/run.sh ############ -# 8 Labels # +# 5 Labels # ############ ARG BUILD_ARCH @@ -256,8 +141,13 @@ LABEL \ org.opencontainers.image.version=${BUILD_VERSION} ################# -# 9 Healthcheck # +# 6 Healthcheck # ################# -# Healthcheck is already defined earlier in the production stage -# If additional healthchecks are needed, add them here. +# Use upstream + +# Expose necessary ports +EXPOSE 9000 + +# Set the entrypoint +ENTRYPOINT ["/app/run.sh"] diff --git a/zzz_test/config.json b/zzz_test/config.json index 2b488e407..c489f38b8 100644 --- a/zzz_test/config.json +++ b/zzz_test/config.json @@ -112,6 +112,6 @@ "slug": "test", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons", - "version": "v2.0-beta_ingress_test5", + "version": "v2.0-beta_ingress_test6", "webui": "[PROTO:ssl]://[HOST]:[PORT:9001]" }