Skip to content

Commit d7999a5

Browse files
committed
adding build system
1 parent 419ca62 commit d7999a5

5 files changed

Lines changed: 137 additions & 0 deletions

File tree

‎.github/workflows/build.yaml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy Images to GHCR
2+
3+
4+
5+
on:
6+
pull_request:
7+
types: [labeled]
8+
9+
jobs:
10+
cancel_outstanding:
11+
name: Detect and cancel outstanding runs of this workflow
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 10
14+
steps:
15+
- name: Cancel Previous Runs
16+
if: ${{ (github.event.label.name == 'release') && !contains(github.event.pull_request.labels.*.name, 'skip-cancel') }}
17+
uses: styfle/cancel-workflow-action@0.11.0
18+
with:
19+
access_token: ${{ secrets.GITHUB_TOKEN }}
20+
21+
22+
push-store-image:
23+
permissions: write-all
24+
runs-on: ubuntu-latest
25+
if: ${{ (github.event.label.name == 'release' ) && !contains(github.event.pull_request.labels.*.name, 'skip-cancel') }}
26+
steps:
27+
- name: 'Checkout GitHub Action'
28+
uses: actions/checkout@main
29+
- name: envvars
30+
run: |
31+
echo "RELEASE=$(cat build/vars/BUILD_TAG)" >> $GITHUB_ENV
32+
echo "REGISTRY=$(cat build/vars/REGISTRY)" >> $GITHUB_ENV
33+
34+
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v2
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
43+
- name: free space
44+
run: |
45+
bash .github/workflows/freespace.sh
46+
##https://github.com/orgs/community/discussions/25678
47+
- name: 'free up space'
48+
49+
run: |
50+
rm -rf /opt/hostedtoolcache
51+
52+
- name: 'Build sd-web-ui image'
53+
run: |
54+
cd build && \
55+
RELEASE=${{ env.RELEASE }} \
56+
REGISTRY=${{ env.REGISTRY }} \
57+
docker buildx bake sd-web-ui -f docker-bake.hcl --push

‎build/docker-bake.hcl‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
variable "RELEASE" {
3+
default = "v1.0.0"
4+
}
5+
6+
variable "REGISTRY" {
7+
default = ""
8+
}
9+
10+
group "default" {
11+
targets = ["sd-web-ui"]
12+
}
13+
14+
target "sd-web-ui" {
15+
dockerfile = "sd.Dockerfile"
16+
tags = ["${REGISTRY}${target.sd-web-ui.name}:${RELEASE}"]
17+
context = "."
18+
labels = {
19+
"org.opencontainers.image.source" = "https://github.com/webcoderz/stable-diffusion-webui"
20+
}
21+
}
22+
23+
24+
#RELEASE=$(cat build/vars/BUILD_TAG) REGISTRY=$(cat build/vars/REGISTRY) docker buildx bake --print

‎build/sd.Dockerfile‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM nvidia/cuda:12.2.0-base-ubuntu22.04
2+
ENV DEBIAN_FRONTEND noninteractive
3+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4+
5+
6+
ENV DEBIAN_FRONTEND noninteractive
7+
RUN apt-get update -y \
8+
&& apt-get upgrade -y \
9+
&& apt-get install -y --no-install-recommends \
10+
curl \
11+
git \
12+
git-lfs \
13+
python3.10 \
14+
python3.10-venv \
15+
python3-pip \
16+
libgl1 \
17+
libglib2.0-0
18+
RUN apt-get clean -y && rm -rf /var/lib/apt/lists/*
19+
20+
# user and workdir
21+
RUN useradd -m user
22+
RUN mkdir /work && chown -R user:user /work
23+
USER user
24+
WORKDIR /work
25+
26+
27+
################################
28+
# setup
29+
################################
30+
31+
RUN git clone https://github.com/webcoderz/stable-diffusion-webui.git
32+
WORKDIR /work/stable-diffusion-webui
33+
34+
35+
36+
# setup
37+
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
38+
39+
40+
41+
################################
42+
# entrypoint
43+
################################
44+
45+
46+
47+
48+
EXPOSE 7860
49+
EXPOSE 8000
50+
EXPOSE 8265
51+
EXPOSE 6388
52+
EXPOSE 10001
53+
54+
CMD ["./webui.sh", "--xformers --cors-allow-origins=* --api"]

‎build/vars/BUILD_TAG‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.0.1

‎build/vars/REGISTRY‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ghcr.io/webcoderz/stable-diffusion-webui/

0 commit comments

Comments
 (0)