ramyma / a8r8

A8R8 (Alternate Reality), an opinionated interface for Stable Diffusion image generation, and more.
MIT License
106 stars 4 forks source link

Using with docker #26

Open Daniel9D opened 1 week ago

Daniel9D commented 1 week ago

here is a update Dockerfile and custom sh to build , works with 0.8 , tested on windows 11

"Dockerfile"

# Use the official Ubuntu image as the base
FROM ubuntu:22.04

# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive
ENV UPDATE=true
ENV WSL=false
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

# Install necessary packages
RUN apt-get update && apt-get install -y wget zstd unzip iproute2 dos2unix curl

# Set the working directory
WORKDIR /app

# Copy everything from the current directory to /app in the container
COPY . /app

# Convert line endings to Unix style (in case the files were created on Windows)
RUN dos2unix /app/run-packaged.sh /app/install_and_update.sh /app/user.sh

# Make the scripts executable
RUN chmod +x /app/run-packaged.sh /app/install_and_update.sh /app/user.sh

# Run the install_and_update.sh script during the Docker build
RUN /app/install_and_update.sh

# Set the entrypoint to run the run-packaged.sh script
ENTRYPOINT ["/app/run-packaged.sh"]

"install_and_update.sh"

#!/bin/bash

current_version=$(cat version.txt)

echo

if [ "$UPDATE" = true ]; then
    echo "Checking latest version"
    latest_version=$(wget -qO- https://github.com/ramyma/a8r8/releases/latest/download/version.txt) || {
        echo "Failed to fetch latest version!"
        exit 1
    }

    if [ "$latest_version" = "$current_version" ]; then
        echo "Already up to date!"
        exit 0
    else
        if [ "$WSL" = true ]; then
            echo "Fetching latest installer"
            wget https://github.com/ramyma/a8r8/releases/latest/download/A8R8_One-Click-Installer.zip -O A8R8_One-Click-Installer.zip || {
                echo "Failed to fetch latest One-Click-Installer! Try downloading it manually."
                exit 1
            }

            unzip -o A8R8_One-Click-Installer.zip

            UPDATE=false sh install-packaged.sh
            exit 0
        fi

        echo "Fetching latest version"
        wget https://github.com/ramyma/a8r8/releases/latest/download/A8R8_ubuntu-22-04_build.tar.zst -O A8R8_ubuntu-22-04_build.tar.zst || {
            echo "Failed to fetch latest version!"
            exit 1
        }
    fi
else
    echo "Fetching ${current_version}"
    wget "https://github.com/ramyma/a8r8/releases/download/${current_version}/A8R8_ubuntu-22-04_build.tar.zst" -O A8R8_ubuntu-22-04_build.tar.zst || {
        echo "Failed to fetch build for ${current_version}!"
        exit 1
    }
fi

tar -xvf A8R8_ubuntu-22-04_build.tar.zst

if [ "$UPDATE" = true ]; then
    echo "Update complete!"
else
    echo "Installation complete!"
fi

exit 0

if you have issues of a8r8 not detecting may need to upadte run-package.sh

[!IMPORTANT] For linux may need to test running with network in host mode

FROM

export HOST_IP="localhost"

if [[ $(grep -i Microsoft /proc/version) ]]; then
    echo "Bash is running on WSL"
    export HOST_IP=$(ip route show | grep -i default | awk '{ print $3}')
fi

TO

export HOST_IP="host.docker.internal"

or change the user.sh and update "localhost" to "host.docker.internal"

#!/bin/bash

# Create a user.sh copy to set your custom values

# Set custom address or port here
# export AUTO_URL="http://localhost:7860"

# Set custom address or port here
# export COMFY_URL="http://localhost:8188"
Daniel9D commented 1 week ago

works with comfyui

ramyma commented 1 week ago

Hey @Daniel9D, thanks for your contribution!

I haven't been updating the Docker support for a while, since not many people showed interest in using Docker.

WSL is a sensible middle ground ( imho :) ), the update and install scripts are integrated with the release packages as well, so it's super easy to switch between versions or update to latest.