From e53c7947e331ae77cc9206858ca8b1b969964282 Mon Sep 17 00:00:00 2001 From: andy1407k Date: Fri, 16 Jun 2023 11:18:15 +0800 Subject: [PATCH] Add project setup to run with Docker --- README.md | 15 ++++++++++++++- packages/stablestudio-ui/Dockerfile | 13 +++++++++++++ packages/stablestudio-ui/nginx-default.conf | 17 +++++++++++++++++ setup.sh | 13 +++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 packages/stablestudio-ui/Dockerfile create mode 100644 packages/stablestudio-ui/nginx-default.conf create mode 100755 setup.sh diff --git a/README.md b/README.md index b7e38278..047a2c33 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

๐Ÿ‘‹ Welcome to StableStudio, the open-source version of DreamStudio!

-**๐Ÿ—บ Contents โ€“ [๐Ÿš€ Quick Start](#quick-start) ยท [โ„น๏ธ About](#about) ยท [๐Ÿ™‹ FAQ](#faq) ยท [๐Ÿง‘โ€๐Ÿ’ป Contributing](#contributing)** +**๐Ÿ—บ Contents โ€“ [๐Ÿš€ Quick Start](#quick-start) ยท [๐Ÿณ Docker Start](#docker-start) ยท [โ„น๏ธ About](#about) ยท [๐Ÿ™‹ FAQ](#faq) ยท [๐Ÿง‘โ€๐Ÿ’ป Contributing](#contributing)** **๐Ÿ“š Documentation โ€“ [๐ŸŽจ UI](./packages/stablestudio-ui/README.md) ยท [๐Ÿ”Œ Plugins](./packages/stablestudio-plugin/README.md) ยท โšก๏ธ platform.stability.ai** @@ -43,6 +43,19 @@ StableStudio will be running at [localhost:3000](http://localhost:3000) by defau > If you are using the default Stability API plugin, You'll need to have your [API key](https://platform.stability.ai/docs/getting-started/authentication) handy. Otherwise, you should be good to go! +# ๐Ÿณ Docker Start + +The easiest way to launch StableStudio locally is by using docker. +A convenient setup script is provided to help you get started. + +```bash +./setup.sh --docker +``` + +_**That's it! ๐ŸŽ‰**_ + +StableStudio will be running at [localhost:3000](http://localhost:3000) by default. + # About
diff --git a/packages/stablestudio-ui/Dockerfile b/packages/stablestudio-ui/Dockerfile new file mode 100644 index 00000000..ea80d12d --- /dev/null +++ b/packages/stablestudio-ui/Dockerfile @@ -0,0 +1,13 @@ +# Use the official nginx image as the base image +FROM nginx:1.18.0 + +# Set the working directory +WORKDIR /stablestudio-ui + +# Copy the stablestudio-ui application code +COPY ./dist ./ + +COPY ./nginx-default.conf /etc/nginx/conf.d/default.conf + +# Expose the port the app will run on +EXPOSE 80 \ No newline at end of file diff --git a/packages/stablestudio-ui/nginx-default.conf b/packages/stablestudio-ui/nginx-default.conf new file mode 100644 index 00000000..94df9387 --- /dev/null +++ b/packages/stablestudio-ui/nginx-default.conf @@ -0,0 +1,17 @@ +server{ + listen 80; + server_name localhost; + root /stablestudio-ui; + index index.html; + charset utf-8; + # By default, Nginx has a limit of 1MB on file uploads. To set file upload size + client_max_body_size 100M; + + location / { + if ($request_filename ~* ^.*?.(html|htm)$){ + expires -1s; + add_header Cache-Control no-cache,no-store,must-revalidate; + } + try_files $uri $uri/ /index.html; + } +} diff --git a/setup.sh b/setup.sh new file mode 100755 index 00000000..f7ff30ee --- /dev/null +++ b/setup.sh @@ -0,0 +1,13 @@ +#!/bin/bash +cd "$(dirname "$0")" || exit + +if [ "$1" = "--docker" ]; then + APP_NAME="stablestudio-ui" + yarn install + yarn build + docker image build -t $APP_NAME -f ./packages/$APP_NAME/Dockerfile ./packages/$APP_NAME/ + docker run -d --name $APP_NAME -p 3000:80 $APP_NAME +else + yarn install + yarn dev +fi \ No newline at end of file