Skip to content

Commit

Permalink
adding build system
Browse files Browse the repository at this point in the history
  • Loading branch information
webcoderz committed Nov 17, 2023
1 parent 419ca62 commit d7999a5
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Deploy Images to GHCR



on:
pull_request:
types: [labeled]

jobs:
cancel_outstanding:
name: Detect and cancel outstanding runs of this workflow
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Cancel Previous Runs
if: ${{ (github.event.label.name == 'release') && !contains(github.event.pull_request.labels.*.name, 'skip-cancel') }}
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}


push-store-image:
permissions: write-all
runs-on: ubuntu-latest
if: ${{ (github.event.label.name == 'release' ) && !contains(github.event.pull_request.labels.*.name, 'skip-cancel') }}
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: envvars
run: |
echo "RELEASE=$(cat build/vars/BUILD_TAG)" >> $GITHUB_ENV
echo "REGISTRY=$(cat build/vars/REGISTRY)" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: free space
run: |
bash .github/workflows/freespace.sh
##https://github.com/orgs/community/discussions/25678
- name: 'free up space'

run: |
rm -rf /opt/hostedtoolcache
- name: 'Build sd-web-ui image'
run: |
cd build && \
RELEASE=${{ env.RELEASE }} \
REGISTRY=${{ env.REGISTRY }} \
docker buildx bake sd-web-ui -f docker-bake.hcl --push
24 changes: 24 additions & 0 deletions build/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

variable "RELEASE" {
default = "v1.0.0"
}

variable "REGISTRY" {
default = ""
}

group "default" {
targets = ["sd-web-ui"]
}

target "sd-web-ui" {
dockerfile = "sd.Dockerfile"
tags = ["${REGISTRY}${target.sd-web-ui.name}:${RELEASE}"]
context = "."
labels = {
"org.opencontainers.image.source" = "https://github.com/webcoderz/stable-diffusion-webui"
}
}


#RELEASE=$(cat build/vars/BUILD_TAG) REGISTRY=$(cat build/vars/REGISTRY) docker buildx bake --print
54 changes: 54 additions & 0 deletions build/sd.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM nvidia/cuda:12.2.0-base-ubuntu22.04
ENV DEBIAN_FRONTEND noninteractive
SHELL ["/bin/bash", "-o", "pipefail", "-c"]


ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
curl \
git \
git-lfs \
python3.10 \
python3.10-venv \
python3-pip \
libgl1 \
libglib2.0-0
RUN apt-get clean -y && rm -rf /var/lib/apt/lists/*

# user and workdir
RUN useradd -m user
RUN mkdir /work && chown -R user:user /work
USER user
WORKDIR /work


################################
# setup
################################

RUN git clone https://github.com/webcoderz/stable-diffusion-webui.git
WORKDIR /work/stable-diffusion-webui



# setup
RUN python3 -mvenv venv && /work/stable-diffusion-webui/venv/bin/python -c "from launch import *; prepare_environment()" --skip-torch-cuda-test --no-download-sd-model



################################
# entrypoint
################################




EXPOSE 7860
EXPOSE 8000
EXPOSE 8265
EXPOSE 6388
EXPOSE 10001

CMD ["./webui.sh", "--xformers --cors-allow-origins=* --api"]
1 change: 1 addition & 0 deletions build/vars/BUILD_TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
1 change: 1 addition & 0 deletions build/vars/REGISTRY
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ghcr.io/webcoderz/stable-diffusion-webui/

0 comments on commit d7999a5

Please sign in to comment.